-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird behavior for string operations with escaped characters #115
Comments
Thank you very much for your fix which is more or less done in the latest eye and lingua. |
Thank you for your fast commit. It seems however that there are still few failures. I've written a small test suite in Notation3 (extended to other I've uploaded here: string_test.n3.txt You may run it with: eye --quiet --nope string_test.n3
Here are the failing properties as exposed by the test suite alongside the involved tests (see the test suite for reference) (some core builtin rules are still there) with @prefix string: <http://www.w3.org/2000/10/swap/string#>.
@prefix : <http://example.com/string_test.n3#>.
string:greaterThan :fail (:t090 :t091 :t092 :t093 :t094 :t095).
string:lessThan :fail (:t110 :t111 :t112 :t113 :t114 :t115).
string:matches :fail (:t140).
string:notContainsRoughly :fail (:t150).
string:notGreaterThan :fail (:t173 :t174 :t175 :t170 :t171 :t172).
string:notLessThan :fail (:t183 :t184 :t185 :t180 :t181 :t182).
string:notMatches :fail (:t190).
string:replaceAll :fail (:t210 :t211 :t215).
string:scrapeAll :fail (:t231 :t232).
string:search :fail (:t244).
string:substring :fail (:t261 :t262).
string:upperCase :fail (:t270).
string:contains :fail (:t020).
string:containsIgnoringCase :fail (:t030).
string:containsRoughly :fail (:t040).
string:endsWith :fail (:t050).
string:format :error (:t081). Best regards |
Thank you for your fast test development👍 The remaining ones are now
|
We are now at
|
It appears that raised errors are independent of tests success or failure. Errors such as:
.. are raised with the following passing tests:
While the following failing tests do not raise any error:
I see no problem for regular expressions expressed with wrong syntax to have errors turned into warning messages, provided it follows the SNAF rule, as it provides substantial information (even if hard to debug). However for consistency reasons, the same behavior should be adopted in any case. |
I guess those exceptions might have to do with SWI-Prolog/packages-pcre#24 so will stay tuned.
|
I may be wrong but some
eye
reasoner behaviors may be incorrect.Escaped characters issue
Some builtin
string: <http://www.w3.org/2000/10/swap/string#>
operations have unexpected behaviors when used with strings containing backslashes ("\\"
,"\t"
...) characters, especially when regular expressions are involved.For example:
"\n" string:length ?v
?v
is1
?v
is2
("a\\b" "(\\\\)" "-") string:replace ?v
?v
is"a-b"
?v
is"a--b"
("a\\b" "(.*)") string:scrape "a\\b"
A quick fix may be implemented for specific builtin core string functions.
However, it seems that the internal representation of literals relies on the N3 strings serialization syntax:
"\t"
is represented as\
andt
which produces these weird behaviors (even "segfault"s in some more complex cases).So the quick fix may not be way to go: it introduces supplementary computational efforts, and only addresses partially the issue.
Thanks for your attention (and all the work you have already done).
Quick & dirty fix (
v10.19.7
- for illustration purpose only).string:scrape
,string:replace
,string:length
)escape_atoms
rule ensure the conversionSample test cases
The text was updated successfully, but these errors were encountered: