diff --git a/oxrdflib/_converter.py b/oxrdflib/_converter.py index e3c8ca6..bc957c2 100644 --- a/oxrdflib/_converter.py +++ b/oxrdflib/_converter.py @@ -116,7 +116,7 @@ def rdflib_to_mime_type(rdflib_type: str) -> str: """Convert an rdflib type to a MIME type.""" if rdflib_type in ("ttl", "turtle"): return "text/turtle" - if rdflib_type == "n3": + if rdflib_type in ("nt", "ntriples"): return "application/n-triples" if rdflib_type == "xml": return "application/rdf+xml" @@ -131,8 +131,8 @@ def ox_to_rdflib_type(ox_format: str) -> str: """Convert an Oxigraph format to a rdflib parser format.""" if ox_format in ("ox-turtle", "ox-ttl"): return "turtle" - if ox_format == "ox-n3": - return "n3" + if ox_format in ("ox-nt", "ox-ntriples"): + return "nt" if ox_format == "ox-xml": return "xml" raise ValueError(f"Unsupported Oxigraph type: {ox_format}") diff --git a/oxrdflib/parser.py b/oxrdflib/parser.py index a384358..d839da9 100644 --- a/oxrdflib/parser.py +++ b/oxrdflib/parser.py @@ -88,7 +88,7 @@ def parse( self, source: InputSource, sink: Graph, - format: str = "ox-n3", + format: str = "ox-nt", encoding: Optional[str] = None, **kwargs: Any, ) -> None: diff --git a/pyproject.toml b/pyproject.toml index 378daff..96eb452 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,8 @@ OxSled = "oxrdflib.store:OxigraphStore" [project.entry-points."rdf.plugins.parser"] ox-turtle = "oxrdflib.parser:OxigraphTurtleParser" ox-ttl = "oxrdflib.parser:OxigraphTurtleParser" -ox-n3 = "oxrdflib.parser:OxigraphNTriplesParser" +ox-ntriples = "oxrdflib.parser:OxigraphNTriplesParser" +ox-nt = "oxrdflib.parser:OxigraphNTriplesParser" ox-xml = "oxrdflib.parser:OxigraphRdfXmlParser" diff --git a/tests/data/test.n3 b/tests/data/test.n3 deleted file mode 100644 index 0f097e6..0000000 --- a/tests/data/test.n3 +++ /dev/null @@ -1,6 +0,0 @@ - . - "Example Document" . - . - . - "John Doe" . - . diff --git a/tests/test_parser.py b/tests/test_parser.py index e20b7a2..e7c18c6 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -42,21 +42,21 @@ def test_parsing_ox_url_turtle(self): ) self.assertIsNotNone(graph) - def test_parsing_ox_n3_bulk_load(self): + def test_parsing_ox_ntriples_bulk_load(self): graph = rdflib.Graph(store="Oxigraph") - graph.parse(_TEST_DIR / "data/test.n3", format="ox-n3", transactional=False) + graph.parse(_TEST_DIR / "data/test.nt", format="ox-ntriples", transactional=False) self.assertEqual(len(graph), 6) - def test_parsing_ox_n3_load(self): + def test_parsing_ox_ntriples_load(self): graph = rdflib.Graph(store="Oxigraph") - graph.parse(_TEST_DIR / "data/test.n3", format="ox-n3", transactional=True) + graph.parse(_TEST_DIR / "data/test.nt", format="ox-ntriples", transactional=True) self.assertEqual(len(graph), 6) - def test_parsing_ox_n3_fallback(self): + def test_parsing_ox_ntriples_fallback(self): graph = rdflib.Graph() with warnings.catch_warnings(record=True) as warning: - graph.parse(_TEST_DIR / "data/test.n3", format="ox-n3", transactional=False) + graph.parse(_TEST_DIR / "data/test.nt", format="ox-ntriples", transactional=False) self.assertEqual( warning[0].message.args[0], @@ -67,11 +67,11 @@ def test_parsing_ox_n3_fallback(self): ) self.assertEqual(len(graph), 6) - def test_parsing_ox_url_n3(self): + def test_parsing_ox_url_ntriples(self): graph = rdflib.Graph(store="Oxigraph") graph.parse( "https://i-adopt.github.io/ontology/ontology.nt", - format="ox-n3", + format="ox-ntriples", transactional=True, ) self.assertIsNotNone(graph)