andrecastro0o / ontology2smw

automating an RDF ontology import into Semantic Mediawiki
GNU General Public License v3.0
16 stars 5 forks source link

failing to handle erros in ontology #46

Closed andrecastro0o closed 3 years ago

andrecastro0o commented 3 years ago

When running

There error below, appears in this area of the code.

https://github.com/TIBHannover/ontology2smw/blob/8b64e85f9b9fb0190af6fcb634bb102c997c80f4/ontology2smw/classes.py#L237-L251

[[Category:Imported vocabulary]] [[Category:OBO]]
http://purl.obolibrary.org/obo/ ttl
http://ontologies.berkeleybop.org/?xml version="1.0" encoding="UTF-8"? does not look like a valid URI, trying to serialize this will break.
ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/" does not look like a valid URI, trying to serialize this will break.
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/andre/Documents/TIB/projects/confiDent/code/ontology2smw/ontology2smw/__main__.py", line 25, in <module>
    main()
  File "/home/andre/Documents/TIB/projects/confiDent/code/ontology2smw/ontology2smw/__main__.py", line 20, in main
    source=args.ontology,
  File "/home/andre/Documents/TIB/projects/confiDent/code/ontology2smw/ontology2smw/functions.py", line 63, in sparql2smwpage
    ontology_format=format_)
  File "/home/andre/Documents/TIB/projects/confiDent/code/ontology2smw/ontology2smw/classes.py", line 218, in __init__
    self.title, self.version, self.description = self.query_ontology()
  File "/home/andre/Documents/TIB/projects/confiDent/code/ontology2smw/ontology2smw/classes.py", line 241, in query_ontology
    format=self.ontology_format)
  File "/home/andre/Documents/TIB/projects/confiDent/code/ontology2smw/venv/lib/python3.7/site-packages/rdflib-5.0.0-py3.7.egg/rdflib/graph.py", line 1078, in parse
    parser.parse(source, self, **args)
  File "/home/andre/Documents/TIB/projects/confiDent/code/ontology2smw/venv/lib/python3.7/site-packages/rdflib-5.0.0-py3.7.egg/rdflib/plugins/parsers/notation3.py", line 1886, in parse
    p.loadStream(source.getByteStream())
  File "/home/andre/Documents/TIB/projects/confiDent/code/ontology2smw/venv/lib/python3.7/site-packages/rdflib-5.0.0-py3.7.egg/rdflib/plugins/parsers/notation3.py", line 442, in loadStream
    return self.loadBuf(stream.read())    # Not ideal
  File "/home/andre/Documents/TIB/projects/confiDent/code/ontology2smw/venv/lib/python3.7/site-packages/rdflib-5.0.0-py3.7.egg/rdflib/plugins/parsers/notation3.py", line 448, in loadBuf
    self.feed(buf)
  File "/home/andre/Documents/TIB/projects/confiDent/code/ontology2smw/venv/lib/python3.7/site-packages/rdflib-5.0.0-py3.7.egg/rdflib/plugins/parsers/notation3.py", line 474, in feed
    i = self.directiveOrStatement(s, j)
  File "/home/andre/Documents/TIB/projects/confiDent/code/ontology2smw/venv/lib/python3.7/site-packages/rdflib-5.0.0-py3.7.egg/rdflib/plugins/parsers/notation3.py", line 497, in directiveOrStatement
    return self.checkDot(argstr, j)
  File "/home/andre/Documents/TIB/projects/confiDent/code/ontology2smw/venv/lib/python3.7/site-packages/rdflib-5.0.0-py3.7.egg/rdflib/plugins/parsers/notation3.py", line 1167, in checkDot
    "expected '.' or '}' or ']' at end of statement")
  File "/home/andre/Documents/TIB/projects/confiDent/code/ontology2smw/venv/lib/python3.7/site-packages/rdflib-5.0.0-py3.7.egg/rdflib/plugins/parsers/notation3.py", line 1623, in BadSyntax
    raise BadSyntax(self._thisDoc, self.lines, argstr, i, msg)
rdflib.plugins.parsers.notation3.BadSyntax: at line 2 of <>:
Bad syntax (expected '.' or '}' or ']' at end of statement) at ^ in:
"...b'esult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>'^b'bbop-ontologies</Name><Prefix></Prefix><Marker></Marker><Max'..."

How to avoid it? Perhaps via check if it looks like a valid URI first.

But is also intregging to know what changed to make it break

andrecastro0o commented 3 years ago

issue handled in #45 by using requests to test content negation of included ontologies in imported ontology