File tree Expand file tree Collapse file tree
bt_nodes/hri/src/hri/dialog Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,29 +88,23 @@ std::string obtain_guest_id(const std::string & json)
8888
8989static std::string sanitize_turtle_literal (const std::string & s)
9090{
91- // Strip ALL backslashes unconditionally — LLM-generated descriptions never need
92- // legitimate escape sequences, and the KB parser (OWL/Turtle) chokes on anything
93- // that isn't one of the five valid escapes (\t \n \r \\ \").
94- // Also strip dots (.) which break Turtle statement terminators.
91+ // Strip ALL backslashes and dots unconditionally
9592 std::string result;
9693 result.reserve (s.size ());
9794
9895 for (size_t i = 0 ; i < s.size (); ++i) {
9996 char c = s[i];
10097 if (c == ' \\ ' ) {
101- // Drop ALL backslashes unconditionally — skip the backslash.
102- // If there is a following character, keep it (it's the intended content).
103- if (i + 1 < s.size ()) {
104- ++i;
105- result += s[i];
106- }
107- // Trailing backslash at end of string: just drop it
98+ // Completely drop backslashes
99+ continue ;
108100 } else if (c == ' "' ) {
109101 result += " \\\" " ; // escape bare double quotes for Turtle
110102 } else if (c == ' \n ' ) {
111- result += ' ' ; // newlines → space (cleaner than \n inside a single-line literal)
103+ result += ' ' ; // newlines → space
112104 } else if (c == ' \r ' ) {
113105 // skip carriage returns
106+ } else if (c == ' .' ) {
107+ // skip dots
114108 } else {
115109 result += c;
116110 }
You can’t perform that action at this time.
0 commit comments