Skip to content

langchain.graph RDFGraph does not read .owl extension files #13115

Closed
@will23332

Description

@will23332

System Info

Langchain version: 0.0.332
Python version: 3.11.5

Who can help?

@hwchase17

When loading a local .owl file (the standard example pizza.owl) the operation breaks and gives the following error for all the URI:
does not look like a valid URI, trying to serialize this will break.

Here's the traceback

Traceback (most recent call last):

  File ~\AppData\Roaming\Python\Python311\site-packages\IPython\core\interactiveshell.py:3526 in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  Cell In[13], line 4
    graph = RdfGraph(

  File C:\Python311\Lib\site-packages\langchain\graphs\rdf_graph.py:159 in __init__
    self.graph.parse(source_file, format=self.serialization)

  File C:\Python311\Lib\site-packages\rdflib\graph.py:1501 in parse
    raise se

  File C:\Python311\Lib\site-packages\rdflib\graph.py:1492 in parse
    parser.parse(source, self, **args)

  File C:\Python311\Lib\site-packages\rdflib\plugins\parsers\notation3.py:2021 in parse
    p.loadStream(stream)

  File C:\Python311\Lib\site-packages\rdflib\plugins\parsers\notation3.py:479 in loadStream
    return self.loadBuf(stream.read())  # Not ideal

  File C:\Python311\Lib\site-packages\rdflib\plugins\parsers\notation3.py:485 in loadBuf
    self.feed(buf)

  File C:\Python311\Lib\site-packages\rdflib\plugins\parsers\notation3.py:511 in feed
    i = self.directiveOrStatement(s, j)

  File C:\Python311\Lib\site-packages\rdflib\plugins\parsers\notation3.py:532 in directiveOrStatement
    return self.checkDot(argstr, j)

  File C:\Python311\Lib\site-packages\rdflib\plugins\parsers\notation3.py:1214 in checkDot
    self.BadSyntax(argstr, j, "expected '.' or '}' or ']' at end of statement")

  File C:\Python311\Lib\site-packages\rdflib\plugins\parsers\notation3.py:1730 in BadSyntax
    raise BadSyntax(self._thisDoc, self.lines, argstr, i, msg)

  File <string>
BadSyntax

Information

  • The official example notebooks/scripts
  • My own modified scripts

Related Components

  • LLMs/Chat Models
  • Embedding Models
  • Prompts / Prompt Templates / Prompt Selectors
  • Output Parsers
  • Document Loaders
  • Vector Stores / Retrievers
  • Memory
  • Agents / Agent Executors
  • Tools / Toolkits
  • Chains
  • Callbacks/Tracing
  • Async

Reproduction

Steps to reproduce the behaviour:

  1. Get the source file from : https://protege.stanford.edu/ontologies/pizza/pizza.owl and place it where the code runs
  2. Use the following code:
from langchain.chains import GraphSparqlQAChain
from langchain.graphs import RdfGraph

graph = RdfGraph(
    source_file="pizza.owl",
    standard="owl"
)

graph.load_schema()

print(graph.get_schema)

Expected behavior

For the graph to load and for graph.get_schema to show the classes and object properties.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Ɑ: doc loaderRelated to document loader module (not documentation)🤖:bugRelated to a bug, vulnerability, unexpected error with an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions