Skip to content
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

Bug: Annotation starting with quotes fail upon conversion to rdf #66

Open
c0ldst0n3 opened this issue Oct 24, 2023 · 0 comments
Open

Bug: Annotation starting with quotes fail upon conversion to rdf #66

c0ldst0n3 opened this issue Oct 24, 2023 · 0 comments

Comments

@c0ldst0n3
Copy link

When a Literal string value starts with a quote, but does not end with a quote, the subsequent conversion to rdf fails.

The issue can be repeated by applying this piece code:

from funowl.converters.functional_converter import to_python
from rdflib import Graph

ofn = """AnnotationAssertion(rdfs:comment onto:ONTO_123 "'Some string', string continuation")"""
x = f"Ontology(<http://test/onto> {ofn})"

conv = to_python(x.encode("utf-8"))
g = Graph()
conv.to_rdf(g)

This issue happens in the Literal._to_n3 staticmethod, where only a check occurs if the string starts with a quote, but not if it ends with one. As a result, a BadSyntax error results in None to be returned.

...
# Add quotes if necessary
if len(v) == 0 or v[0] not in ['"', "'"]:
    v = '"' + v + '"'
# Create a turtle triple to use the n3 parser
# TODO: make the constructor static and use clear
stmt = f'@prefix : <{DUMMY_PREFIX}> . @prefix xsd: <{XSD}> . :f a {v} .'
g = Graph(bind_namespaces="core")
try:
    g.parse(data=stmt, format="turtle")
except BadSyntax:
    pass
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant