Skip to content

Commit 9e9ce15

Browse files
authored
Merge pull request #3 from INCATools/fix-lang-tags
fixing language tags
2 parents 17de84b + 86eaadc commit 9e9ce15

6 files changed

Lines changed: 66 additions & 4 deletions

File tree

src/rdf_sql_bulkloader/loaders/bulkloader.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414

1515
re_untyped_literal = re.compile(r'^"(.*)"$')
1616
re_typed_literal = re.compile(r'^"(.*)"\^\^<([\S^"]+)>$')
17-
re_lang_literal = re.compile(r'^"(.*)"@(\w+)$')
18-
re_blank_node = re.compile(r"^riog(\d+)$")
17+
re_lang_literal = re.compile(r'^"(.*)"@([\-\w]+)$')
18+
re_blank_node = re.compile(r'^riog(\d+)$')
19+
1920

2021

2122
DDL = """

tests/__init__.py

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

1010
TEST_BASE = "go-nucleus"
1111
TEST_INPUT_OWL = INPUT_DIR / f"{TEST_BASE}.owl"
12+
TEST_LANG_BASE = "lang-example"
13+
TEST_LANG_INPUT_OWL = INPUT_DIR / f"{TEST_LANG_BASE}.owl"
14+
TEST_LANG_INPUT_TTL = INPUT_DIR / f"{TEST_LANG_BASE}.ttl"
1215

1316

1417
def output_path(fn: str) -> str:

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: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import unittest
44

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

89
DEFN = (
910
"A membrane-bounded organelle of eukaryotic cells in which chromosomes "
@@ -13,6 +14,7 @@
1314
+ "RNA metabolism or DNA replication may be absent."
1415
)
1516

17+
1618
CASES = [
1719
(None, "GO:0005634", "RO:0002161", "NCBITaxon:2", None, None, None, None),
1820
(
@@ -43,3 +45,26 @@ def test_bulkload(self):
4345
print(s)
4446
for case in CASES:
4547
self.assertIn(case, stmts)
48+
49+
def test_lang_tags(self):
50+
"""
51+
Test language tags
52+
53+
https://www.w3.org/TR/rdf-syntax-grammar/#section-Syntax-languages
54+
:return:
55+
"""
56+
loader = SqliteBulkloader(path=":memory:")
57+
loader.bulkload(TEST_LANG_INPUT_OWL)
58+
59+
def test_lang_tags_ttl(self):
60+
"""
61+
Test language tags
62+
63+
https://www.w3.org/TR/rdf-syntax-grammar/#section-Syntax-languages
64+
:return:
65+
"""
66+
loader = SqliteBulkloader(path=":memory:")
67+
loader.bulkload(TEST_LANG_INPUT_TTL)
68+
69+
70+

0 commit comments

Comments
 (0)