Skip to content

Commit 20cc148

Browse files
committed
fixing language tags
1 parent ba17cfc commit 20cc148

6 files changed

Lines changed: 60 additions & 5 deletions

File tree

src/rdf_sql_bulkloader/loaders/bulkloader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
re_untyped_literal = re.compile(r'^"(.*)"$')
1414
re_typed_literal = re.compile(r'^"(.*)"\^\^<([\S^"]+)>$')
15-
re_lang_literal = re.compile(r'^"(.*)"@(\w+)$')
15+
re_lang_literal = re.compile(r'^"(.*)"@([\-\w]+)$')
1616
re_blank_node = re.compile(r'^riog(\d+)$')
1717

1818

tests/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
TEST_BASE = "go-nucleus"
1313
TEST_INPUT_OWL = INPUT_DIR / f"{TEST_BASE}.owl"
14+
TEST_LANG_BASE = "lang-example"
15+
TEST_LANG_INPUT_OWL = INPUT_DIR / f"{TEST_LANG_BASE}.owl"
16+
TEST_LANG_INPUT_TTL = INPUT_DIR / f"{TEST_LANG_BASE}.ttl"
1417

1518
def output_path(fn: str) -> str:
1619
return str(Path(OUTPUT_DIR) / fn)

tests/input/go-nucleus.owl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<!-- http://purl.obolibrary.org/obo/IAO_0000115 -->
3131

3232
<owl:AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000115">
33-
<rdfs:label xml:lang="en">definition</rdfs:label>
33+
<rdfs:label xml:lang="en-US">definition</rdfs:label>
3434
</owl:AnnotationProperty>
3535

3636

tests/input/lang-example.owl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
3+
xmlns:dc="http://purl.org/dc/elements/1.1/">
4+
5+
<rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar">
6+
<dc:title>RDF 1.1 XML Syntax</dc:title>
7+
<dc:title xml:lang="en">RDF 1.1 XML Syntax</dc:title>
8+
<dc:title xml:lang="en-US">RDF 1.1 XML Syntax</dc:title>
9+
</rdf:Description>
10+
11+
<rdf:Description rdf:about="http://example.org/buecher/baum" xml:lang="de">
12+
<dc:title>Der Baum</dc:title>
13+
<dc:description>Das Buch ist außergewöhnlich</dc:description>
14+
<dc:title xml:lang="en">The Tree</dc:title>
15+
</rdf:Description>
16+
17+
</rdf:RDF>
18+

tests/input/lang-example.ttl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
3+
xmlns:dc="http://purl.org/dc/elements/1.1/">
4+
<rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar">
5+
<dc:title>RDF/XML Syntax Specification (Revised)</dc:title>
6+
<dc:title xml:lang="en">RDF/XML Syntax Specification (Revised)</dc:title>
7+
<dc:title xml:lang="en-US">RDF/XML Syntax Specification (Revised)</dc:title>
8+
</rdf:Description>
9+
10+
<rdf:Description rdf:about="http://example.org/buecher/baum" xml:lang="de">
11+
<dc:title>Der Baum</dc:title>
12+
<dc:description>Das Buch ist außergewöhnlich</dc:description>
13+
<dc:title xml:lang="en">The Tree</dc:title>
14+
</rdf:Description>
15+
</rdf:RDF>

tests/test_sqlite3_bulkloader.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import unittest
44

55
from rdf_sql_bulkloader import SqliteBulkloader
6-
from tests import TEST_INPUT_OWL, NUCLEUS, TEST_PREFIX_MAP
7-
6+
from tests import TEST_INPUT_OWL, NUCLEUS, TEST_PREFIX_MAP, TEST_LANG_INPUT_OWL, TEST_LANG_INPUT_TTL
87

98
CASES =[
109
(None, 'GO:0005634', 'RO:0002161', 'NCBITaxon:2', None, None, None, None),
@@ -26,5 +25,25 @@ def test_bulkload(self):
2625
print(s)
2726
for case in CASES:
2827
self.assertIn(case, stmts)
29-
28+
29+
def test_lang_tags(self):
30+
"""
31+
Test language tags
32+
33+
https://www.w3.org/TR/rdf-syntax-grammar/#section-Syntax-languages
34+
:return:
35+
"""
36+
loader = SqliteBulkloader(path=":memory:")
37+
loader.bulkload(TEST_LANG_INPUT_OWL)
38+
39+
def test_lang_tags_ttl(self):
40+
"""
41+
Test language tags
42+
43+
https://www.w3.org/TR/rdf-syntax-grammar/#section-Syntax-languages
44+
:return:
45+
"""
46+
loader = SqliteBulkloader(path=":memory:")
47+
loader.bulkload(TEST_LANG_INPUT_TTL)
48+
3049

0 commit comments

Comments
 (0)