mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-23 04:01:02 +02:00
Lower case
This commit is contained in:
parent
65b3a6ee12
commit
2d357889a2
5 changed files with 62 additions and 62 deletions
|
|
@ -93,7 +93,7 @@ class TestEntityCentricKnowledgeGraph:
|
||||||
p='http://example.org/knows',
|
p='http://example.org/knows',
|
||||||
o='http://example.org/Bob',
|
o='http://example.org/Bob',
|
||||||
g='http://example.org/graph1',
|
g='http://example.org/graph1',
|
||||||
otype='U'
|
otype='u'
|
||||||
)
|
)
|
||||||
|
|
||||||
# Verify batch was executed
|
# Verify batch was executed
|
||||||
|
|
@ -111,7 +111,7 @@ class TestEntityCentricKnowledgeGraph:
|
||||||
p='http://www.w3.org/2000/01/rdf-schema#label',
|
p='http://www.w3.org/2000/01/rdf-schema#label',
|
||||||
o='Alice Smith',
|
o='Alice Smith',
|
||||||
g=None,
|
g=None,
|
||||||
otype='L',
|
otype='l',
|
||||||
dtype='xsd:string',
|
dtype='xsd:string',
|
||||||
lang='en'
|
lang='en'
|
||||||
)
|
)
|
||||||
|
|
@ -131,7 +131,7 @@ class TestEntityCentricKnowledgeGraph:
|
||||||
p='http://example.org/knows',
|
p='http://example.org/knows',
|
||||||
o='http://example.org/Bob',
|
o='http://example.org/Bob',
|
||||||
g=None,
|
g=None,
|
||||||
otype='U'
|
otype='u'
|
||||||
)
|
)
|
||||||
|
|
||||||
mock_session.execute.assert_called()
|
mock_session.execute.assert_called()
|
||||||
|
|
@ -169,7 +169,7 @@ class TestEntityCentricKnowledgeGraph:
|
||||||
# Mock the query result
|
# Mock the query result
|
||||||
mock_result = [
|
mock_result = [
|
||||||
MagicMock(p='http://example.org/knows', o='http://example.org/Bob',
|
MagicMock(p='http://example.org/knows', o='http://example.org/Bob',
|
||||||
d='', otype='U', dtype='', lang='', s='http://example.org/Alice')
|
d='', otype='u', dtype='', lang='', s='http://example.org/Alice')
|
||||||
]
|
]
|
||||||
mock_session.execute.return_value = mock_result
|
mock_session.execute.return_value = mock_result
|
||||||
|
|
||||||
|
|
@ -190,7 +190,7 @@ class TestEntityCentricKnowledgeGraph:
|
||||||
|
|
||||||
mock_result = [
|
mock_result = [
|
||||||
MagicMock(s='http://example.org/Alice', o='http://example.org/Bob',
|
MagicMock(s='http://example.org/Alice', o='http://example.org/Bob',
|
||||||
d='', otype='U', dtype='', lang='', p='http://example.org/knows')
|
d='', otype='u', dtype='', lang='', p='http://example.org/knows')
|
||||||
]
|
]
|
||||||
mock_session.execute.return_value = mock_result
|
mock_session.execute.return_value = mock_result
|
||||||
|
|
||||||
|
|
@ -205,7 +205,7 @@ class TestEntityCentricKnowledgeGraph:
|
||||||
|
|
||||||
mock_result = [
|
mock_result = [
|
||||||
MagicMock(s='http://example.org/Alice', p='http://example.org/knows',
|
MagicMock(s='http://example.org/Alice', p='http://example.org/knows',
|
||||||
d='', otype='U', dtype='', lang='', o='http://example.org/Bob')
|
d='', otype='u', dtype='', lang='', o='http://example.org/Bob')
|
||||||
]
|
]
|
||||||
mock_session.execute.return_value = mock_result
|
mock_session.execute.return_value = mock_result
|
||||||
|
|
||||||
|
|
@ -219,7 +219,7 @@ class TestEntityCentricKnowledgeGraph:
|
||||||
kg, mock_session = entity_kg
|
kg, mock_session = entity_kg
|
||||||
|
|
||||||
mock_result = [
|
mock_result = [
|
||||||
MagicMock(o='http://example.org/Bob', d='', otype='U', dtype='', lang='')
|
MagicMock(o='http://example.org/Bob', d='', otype='u', dtype='', lang='')
|
||||||
]
|
]
|
||||||
mock_session.execute.return_value = mock_result
|
mock_session.execute.return_value = mock_result
|
||||||
|
|
||||||
|
|
@ -234,7 +234,7 @@ class TestEntityCentricKnowledgeGraph:
|
||||||
kg, mock_session = entity_kg
|
kg, mock_session = entity_kg
|
||||||
|
|
||||||
mock_result = [
|
mock_result = [
|
||||||
MagicMock(s='http://example.org/Alice', d='', otype='U', dtype='', lang='',
|
MagicMock(s='http://example.org/Alice', d='', otype='u', dtype='', lang='',
|
||||||
o='http://example.org/Bob')
|
o='http://example.org/Bob')
|
||||||
]
|
]
|
||||||
mock_session.execute.return_value = mock_result
|
mock_session.execute.return_value = mock_result
|
||||||
|
|
@ -250,7 +250,7 @@ class TestEntityCentricKnowledgeGraph:
|
||||||
kg, mock_session = entity_kg
|
kg, mock_session = entity_kg
|
||||||
|
|
||||||
mock_result = [
|
mock_result = [
|
||||||
MagicMock(p='http://example.org/knows', d='', otype='U', dtype='', lang='',
|
MagicMock(p='http://example.org/knows', d='', otype='u', dtype='', lang='',
|
||||||
s='http://example.org/Alice', o='http://example.org/Bob')
|
s='http://example.org/Alice', o='http://example.org/Bob')
|
||||||
]
|
]
|
||||||
mock_session.execute.return_value = mock_result
|
mock_session.execute.return_value = mock_result
|
||||||
|
|
@ -266,7 +266,7 @@ class TestEntityCentricKnowledgeGraph:
|
||||||
kg, mock_session = entity_kg
|
kg, mock_session = entity_kg
|
||||||
|
|
||||||
mock_result = [
|
mock_result = [
|
||||||
MagicMock(d='', otype='U', dtype='', lang='',
|
MagicMock(d='', otype='u', dtype='', lang='',
|
||||||
o='http://example.org/Bob')
|
o='http://example.org/Bob')
|
||||||
]
|
]
|
||||||
mock_session.execute.return_value = mock_result
|
mock_session.execute.return_value = mock_result
|
||||||
|
|
@ -283,7 +283,7 @@ class TestEntityCentricKnowledgeGraph:
|
||||||
|
|
||||||
mock_result = [
|
mock_result = [
|
||||||
MagicMock(s='http://example.org/Alice', p='http://example.org/knows',
|
MagicMock(s='http://example.org/Alice', p='http://example.org/knows',
|
||||||
o='http://example.org/Bob', otype='U', dtype='', lang='')
|
o='http://example.org/Bob', otype='u', dtype='', lang='')
|
||||||
]
|
]
|
||||||
mock_session.execute.return_value = mock_result
|
mock_session.execute.return_value = mock_result
|
||||||
|
|
||||||
|
|
@ -297,7 +297,7 @@ class TestEntityCentricKnowledgeGraph:
|
||||||
|
|
||||||
mock_result = [
|
mock_result = [
|
||||||
MagicMock(d='', s='http://example.org/Alice', p='http://example.org/knows',
|
MagicMock(d='', s='http://example.org/Alice', p='http://example.org/knows',
|
||||||
o='http://example.org/Bob', otype='U', dtype='', lang='')
|
o='http://example.org/Bob', otype='u', dtype='', lang='')
|
||||||
]
|
]
|
||||||
mock_session.execute.return_value = mock_result
|
mock_session.execute.return_value = mock_result
|
||||||
|
|
||||||
|
|
@ -312,10 +312,10 @@ class TestEntityCentricKnowledgeGraph:
|
||||||
|
|
||||||
mock_result = [
|
mock_result = [
|
||||||
MagicMock(p='http://example.org/knows', d='http://example.org/graph1',
|
MagicMock(p='http://example.org/knows', d='http://example.org/graph1',
|
||||||
otype='U', dtype='', lang='', s='http://example.org/Alice',
|
otype='u', dtype='', lang='', s='http://example.org/Alice',
|
||||||
o='http://example.org/Bob'),
|
o='http://example.org/Bob'),
|
||||||
MagicMock(p='http://example.org/knows', d='http://example.org/graph2',
|
MagicMock(p='http://example.org/knows', d='http://example.org/graph2',
|
||||||
otype='U', dtype='', lang='', s='http://example.org/Alice',
|
otype='u', dtype='', lang='', s='http://example.org/Alice',
|
||||||
o='http://example.org/Charlie')
|
o='http://example.org/Charlie')
|
||||||
]
|
]
|
||||||
mock_session.execute.return_value = mock_result
|
mock_session.execute.return_value = mock_result
|
||||||
|
|
@ -331,10 +331,10 @@ class TestEntityCentricKnowledgeGraph:
|
||||||
|
|
||||||
mock_result = [
|
mock_result = [
|
||||||
MagicMock(p='http://example.org/knows', d='http://example.org/graph1',
|
MagicMock(p='http://example.org/knows', d='http://example.org/graph1',
|
||||||
otype='U', dtype='', lang='', s='http://example.org/Alice',
|
otype='u', dtype='', lang='', s='http://example.org/Alice',
|
||||||
o='http://example.org/Bob'),
|
o='http://example.org/Bob'),
|
||||||
MagicMock(p='http://example.org/knows', d='http://example.org/graph2',
|
MagicMock(p='http://example.org/knows', d='http://example.org/graph2',
|
||||||
otype='U', dtype='', lang='', s='http://example.org/Alice',
|
otype='u', dtype='', lang='', s='http://example.org/Alice',
|
||||||
o='http://example.org/Charlie')
|
o='http://example.org/Charlie')
|
||||||
]
|
]
|
||||||
mock_session.execute.return_value = mock_result
|
mock_session.execute.return_value = mock_result
|
||||||
|
|
@ -384,7 +384,7 @@ class TestEntityCentricKnowledgeGraph:
|
||||||
# Mock reading quads from collection
|
# Mock reading quads from collection
|
||||||
mock_quads = [
|
mock_quads = [
|
||||||
MagicMock(d='', s='http://example.org/Alice', p='http://example.org/knows',
|
MagicMock(d='', s='http://example.org/Alice', p='http://example.org/knows',
|
||||||
o='http://example.org/Bob', otype='U')
|
o='http://example.org/Bob', otype='u')
|
||||||
]
|
]
|
||||||
mock_session.execute.return_value = mock_quads
|
mock_session.execute.return_value = mock_quads
|
||||||
|
|
||||||
|
|
@ -416,7 +416,7 @@ class TestQuadResult:
|
||||||
p='http://example.org/knows',
|
p='http://example.org/knows',
|
||||||
o='http://example.org/Bob',
|
o='http://example.org/Bob',
|
||||||
g='http://example.org/graph1',
|
g='http://example.org/graph1',
|
||||||
otype='U',
|
otype='u',
|
||||||
dtype='',
|
dtype='',
|
||||||
lang=''
|
lang=''
|
||||||
)
|
)
|
||||||
|
|
@ -425,7 +425,7 @@ class TestQuadResult:
|
||||||
assert result.p == 'http://example.org/knows'
|
assert result.p == 'http://example.org/knows'
|
||||||
assert result.o == 'http://example.org/Bob'
|
assert result.o == 'http://example.org/Bob'
|
||||||
assert result.g == 'http://example.org/graph1'
|
assert result.g == 'http://example.org/graph1'
|
||||||
assert result.otype == 'U'
|
assert result.otype == 'u'
|
||||||
assert result.dtype == ''
|
assert result.dtype == ''
|
||||||
assert result.lang == ''
|
assert result.lang == ''
|
||||||
|
|
||||||
|
|
@ -440,7 +440,7 @@ class TestQuadResult:
|
||||||
g=''
|
g=''
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.otype == 'U' # Default otype
|
assert result.otype == 'u' # Default otype
|
||||||
assert result.dtype == ''
|
assert result.dtype == ''
|
||||||
assert result.lang == ''
|
assert result.lang == ''
|
||||||
|
|
||||||
|
|
@ -453,12 +453,12 @@ class TestQuadResult:
|
||||||
p='http://www.w3.org/2000/01/rdf-schema#label',
|
p='http://www.w3.org/2000/01/rdf-schema#label',
|
||||||
o='Alice Smith',
|
o='Alice Smith',
|
||||||
g='',
|
g='',
|
||||||
otype='L',
|
otype='l',
|
||||||
dtype='xsd:string',
|
dtype='xsd:string',
|
||||||
lang='en'
|
lang='en'
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.otype == 'L'
|
assert result.otype == 'l'
|
||||||
assert result.dtype == 'xsd:string'
|
assert result.dtype == 'xsd:string'
|
||||||
assert result.lang == 'en'
|
assert result.lang == 'en'
|
||||||
|
|
||||||
|
|
@ -511,42 +511,42 @@ class TestWriteHelperFunctions:
|
||||||
"""Test cases for helper functions in write.py"""
|
"""Test cases for helper functions in write.py"""
|
||||||
|
|
||||||
def test_get_term_otype_for_iri(self):
|
def test_get_term_otype_for_iri(self):
|
||||||
"""Test get_term_otype returns 'U' for IRI terms"""
|
"""Test get_term_otype returns 'u' for IRI terms"""
|
||||||
from trustgraph.storage.triples.cassandra.write import get_term_otype
|
from trustgraph.storage.triples.cassandra.write import get_term_otype
|
||||||
from trustgraph.schema import Term, IRI
|
from trustgraph.schema import Term, IRI
|
||||||
|
|
||||||
term = Term(type=IRI, iri='http://example.org/Alice')
|
term = Term(type=IRI, iri='http://example.org/Alice')
|
||||||
assert get_term_otype(term) == 'U'
|
assert get_term_otype(term) == 'u'
|
||||||
|
|
||||||
def test_get_term_otype_for_literal(self):
|
def test_get_term_otype_for_literal(self):
|
||||||
"""Test get_term_otype returns 'L' for LITERAL terms"""
|
"""Test get_term_otype returns 'l' for LITERAL terms"""
|
||||||
from trustgraph.storage.triples.cassandra.write import get_term_otype
|
from trustgraph.storage.triples.cassandra.write import get_term_otype
|
||||||
from trustgraph.schema import Term, LITERAL
|
from trustgraph.schema import Term, LITERAL
|
||||||
|
|
||||||
term = Term(type=LITERAL, value='Alice Smith')
|
term = Term(type=LITERAL, value='Alice Smith')
|
||||||
assert get_term_otype(term) == 'L'
|
assert get_term_otype(term) == 'l'
|
||||||
|
|
||||||
def test_get_term_otype_for_blank(self):
|
def test_get_term_otype_for_blank(self):
|
||||||
"""Test get_term_otype returns 'U' for BLANK terms"""
|
"""Test get_term_otype returns 'u' for BLANK terms"""
|
||||||
from trustgraph.storage.triples.cassandra.write import get_term_otype
|
from trustgraph.storage.triples.cassandra.write import get_term_otype
|
||||||
from trustgraph.schema import Term, BLANK
|
from trustgraph.schema import Term, BLANK
|
||||||
|
|
||||||
term = Term(type=BLANK, id='_:b1')
|
term = Term(type=BLANK, id='_:b1')
|
||||||
assert get_term_otype(term) == 'U'
|
assert get_term_otype(term) == 'u'
|
||||||
|
|
||||||
def test_get_term_otype_for_triple(self):
|
def test_get_term_otype_for_triple(self):
|
||||||
"""Test get_term_otype returns 'T' for TRIPLE terms"""
|
"""Test get_term_otype returns 't' for TRIPLE terms"""
|
||||||
from trustgraph.storage.triples.cassandra.write import get_term_otype
|
from trustgraph.storage.triples.cassandra.write import get_term_otype
|
||||||
from trustgraph.schema import Term, TRIPLE
|
from trustgraph.schema import Term, TRIPLE
|
||||||
|
|
||||||
term = Term(type=TRIPLE)
|
term = Term(type=TRIPLE)
|
||||||
assert get_term_otype(term) == 'T'
|
assert get_term_otype(term) == 't'
|
||||||
|
|
||||||
def test_get_term_otype_for_none(self):
|
def test_get_term_otype_for_none(self):
|
||||||
"""Test get_term_otype returns 'U' for None"""
|
"""Test get_term_otype returns 'u' for None"""
|
||||||
from trustgraph.storage.triples.cassandra.write import get_term_otype
|
from trustgraph.storage.triples.cassandra.write import get_term_otype
|
||||||
|
|
||||||
assert get_term_otype(None) == 'U'
|
assert get_term_otype(None) == 'u'
|
||||||
|
|
||||||
def test_get_term_dtype_for_literal(self):
|
def test_get_term_dtype_for_literal(self):
|
||||||
"""Test get_term_dtype extracts datatype from LITERAL"""
|
"""Test get_term_dtype extracts datatype from LITERAL"""
|
||||||
|
|
@ -591,21 +591,21 @@ class TestServiceHelperFunctions:
|
||||||
"""Test cases for helper functions in service.py"""
|
"""Test cases for helper functions in service.py"""
|
||||||
|
|
||||||
def test_create_term_with_uri_otype(self):
|
def test_create_term_with_uri_otype(self):
|
||||||
"""Test create_term creates IRI Term for otype='U'"""
|
"""Test create_term creates IRI Term for otype='u'"""
|
||||||
from trustgraph.query.triples.cassandra.service import create_term
|
from trustgraph.query.triples.cassandra.service import create_term
|
||||||
from trustgraph.schema import IRI
|
from trustgraph.schema import IRI
|
||||||
|
|
||||||
term = create_term('http://example.org/Alice', otype='U')
|
term = create_term('http://example.org/Alice', otype='u')
|
||||||
|
|
||||||
assert term.type == IRI
|
assert term.type == IRI
|
||||||
assert term.iri == 'http://example.org/Alice'
|
assert term.iri == 'http://example.org/Alice'
|
||||||
|
|
||||||
def test_create_term_with_literal_otype(self):
|
def test_create_term_with_literal_otype(self):
|
||||||
"""Test create_term creates LITERAL Term for otype='L'"""
|
"""Test create_term creates LITERAL Term for otype='l'"""
|
||||||
from trustgraph.query.triples.cassandra.service import create_term
|
from trustgraph.query.triples.cassandra.service import create_term
|
||||||
from trustgraph.schema import LITERAL
|
from trustgraph.schema import LITERAL
|
||||||
|
|
||||||
term = create_term('Alice Smith', otype='L', dtype='xsd:string', lang='en')
|
term = create_term('Alice Smith', otype='l', dtype='xsd:string', lang='en')
|
||||||
|
|
||||||
assert term.type == LITERAL
|
assert term.type == LITERAL
|
||||||
assert term.value == 'Alice Smith'
|
assert term.value == 'Alice Smith'
|
||||||
|
|
@ -613,11 +613,11 @@ class TestServiceHelperFunctions:
|
||||||
assert term.language == 'en'
|
assert term.language == 'en'
|
||||||
|
|
||||||
def test_create_term_with_triple_otype(self):
|
def test_create_term_with_triple_otype(self):
|
||||||
"""Test create_term creates IRI Term for otype='T'"""
|
"""Test create_term creates IRI Term for otype='t'"""
|
||||||
from trustgraph.query.triples.cassandra.service import create_term
|
from trustgraph.query.triples.cassandra.service import create_term
|
||||||
from trustgraph.schema import IRI
|
from trustgraph.schema import IRI
|
||||||
|
|
||||||
term = create_term('http://example.org/statement1', otype='T')
|
term = create_term('http://example.org/statement1', otype='t')
|
||||||
|
|
||||||
assert term.type == IRI
|
assert term.type == IRI
|
||||||
assert term.iri == 'http://example.org/statement1'
|
assert term.iri == 'http://example.org/statement1'
|
||||||
|
|
|
||||||
|
|
@ -219,11 +219,11 @@ class TestCassandraStorageProcessor:
|
||||||
assert mock_tg_instance.insert.call_count == 2
|
assert mock_tg_instance.insert.call_count == 2
|
||||||
mock_tg_instance.insert.assert_any_call(
|
mock_tg_instance.insert.assert_any_call(
|
||||||
'collection1', 'subject1', 'predicate1', 'object1',
|
'collection1', 'subject1', 'predicate1', 'object1',
|
||||||
g=DEFAULT_GRAPH, otype='L', dtype='', lang=''
|
g=DEFAULT_GRAPH, otype='l', dtype='', lang=''
|
||||||
)
|
)
|
||||||
mock_tg_instance.insert.assert_any_call(
|
mock_tg_instance.insert.assert_any_call(
|
||||||
'collection1', 'subject2', 'predicate2', 'object2',
|
'collection1', 'subject2', 'predicate2', 'object2',
|
||||||
g=DEFAULT_GRAPH, otype='L', dtype='', lang=''
|
g=DEFAULT_GRAPH, otype='l', dtype='', lang=''
|
||||||
)
|
)
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
|
@ -428,7 +428,7 @@ class TestCassandraStorageProcessor:
|
||||||
'predicate:with/colons',
|
'predicate:with/colons',
|
||||||
'object with "quotes" and unicode: ñáéíóú',
|
'object with "quotes" and unicode: ñáéíóú',
|
||||||
g=DEFAULT_GRAPH,
|
g=DEFAULT_GRAPH,
|
||||||
otype='L',
|
otype='l',
|
||||||
dtype='',
|
dtype='',
|
||||||
lang=''
|
lang=''
|
||||||
)
|
)
|
||||||
|
|
@ -544,7 +544,7 @@ class TestCassandraPerformanceOptimizations:
|
||||||
# Verify insert was called for the triple (implementation details tested in KnowledgeGraph)
|
# Verify insert was called for the triple (implementation details tested in KnowledgeGraph)
|
||||||
mock_tg_instance.insert.assert_called_once_with(
|
mock_tg_instance.insert.assert_called_once_with(
|
||||||
'collection1', 'test_subject', 'test_predicate', 'test_object',
|
'collection1', 'test_subject', 'test_predicate', 'test_object',
|
||||||
g=DEFAULT_GRAPH, otype='L', dtype='', lang=''
|
g=DEFAULT_GRAPH, otype='l', dtype='', lang=''
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_environment_variable_controls_mode(self):
|
def test_environment_variable_controls_mode(self):
|
||||||
|
|
|
||||||
|
|
@ -732,7 +732,7 @@ class EntityCentricKnowledgeGraph:
|
||||||
p: Predicate (string value)
|
p: Predicate (string value)
|
||||||
o: Object (string value)
|
o: Object (string value)
|
||||||
g: Graph/dataset (None for default graph)
|
g: Graph/dataset (None for default graph)
|
||||||
otype: Object type - 'U' (URI), 'L' (literal), 'T' (triple)
|
otype: Object type - 'u' (URI), 'l' (literal), 't' (triple)
|
||||||
Auto-detected from o value if not provided
|
Auto-detected from o value if not provided
|
||||||
dtype: XSD datatype (for literals)
|
dtype: XSD datatype (for literals)
|
||||||
lang: Language tag (for literals)
|
lang: Language tag (for literals)
|
||||||
|
|
@ -744,9 +744,9 @@ class EntityCentricKnowledgeGraph:
|
||||||
# Auto-detect otype if not provided (backwards compatibility)
|
# Auto-detect otype if not provided (backwards compatibility)
|
||||||
if otype is None:
|
if otype is None:
|
||||||
if o.startswith("http://") or o.startswith("https://"):
|
if o.startswith("http://") or o.startswith("https://"):
|
||||||
otype = "U"
|
otype = "u"
|
||||||
else:
|
else:
|
||||||
otype = "L"
|
otype = "l"
|
||||||
|
|
||||||
batch = BatchStatement()
|
batch = BatchStatement()
|
||||||
|
|
||||||
|
|
@ -761,7 +761,7 @@ class EntityCentricKnowledgeGraph:
|
||||||
))
|
))
|
||||||
|
|
||||||
# Write row for object entity (role='O') - only for URIs, not literals
|
# Write row for object entity (role='O') - only for URIs, not literals
|
||||||
if otype == 'U' or otype == 'T':
|
if otype == 'u' or otype == 't':
|
||||||
batch.add(self.insert_entity_stmt, (
|
batch.add(self.insert_entity_stmt, (
|
||||||
collection, o, 'O', p, otype, s, o, g, dtype, lang
|
collection, o, 'O', p, otype, s, o, g, dtype, lang
|
||||||
))
|
))
|
||||||
|
|
@ -1005,7 +1005,7 @@ class EntityCentricKnowledgeGraph:
|
||||||
entities.add(p)
|
entities.add(p)
|
||||||
|
|
||||||
# Object is an entity only for URIs
|
# Object is an entity only for URIs
|
||||||
if otype == 'U' or otype == 'T':
|
if otype == 'u' or otype == 't':
|
||||||
entities.add(o)
|
entities.add(o)
|
||||||
|
|
||||||
# Graph is an entity for non-default graphs
|
# Graph is an entity for non-default graphs
|
||||||
|
|
@ -1073,12 +1073,12 @@ class QuadResult:
|
||||||
p: Predicate value
|
p: Predicate value
|
||||||
o: Object value
|
o: Object value
|
||||||
g: Graph/dataset value
|
g: Graph/dataset value
|
||||||
otype: Object type - 'U' (URI), 'L' (literal), 'T' (triple)
|
otype: Object type - 'u' (URI), 'l' (literal), 't' (triple)
|
||||||
dtype: XSD datatype (for literals)
|
dtype: XSD datatype (for literals)
|
||||||
lang: Language tag (for literals)
|
lang: Language tag (for literals)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, s, p, o, g, otype='U', dtype='', lang=''):
|
def __init__(self, s, p, o, g, otype='u', dtype='', lang=''):
|
||||||
self.s = s
|
self.s = s
|
||||||
self.p = p
|
self.p = p
|
||||||
self.o = o
|
self.o = o
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ def create_term(value, otype=None, dtype=None, lang=None):
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
value: The string value
|
value: The string value
|
||||||
otype: Object type - 'U' (URI), 'L' (literal), 'T' (triple)
|
otype: Object type - 'u' (URI), 'l' (literal), 't' (triple)
|
||||||
dtype: XSD datatype (for literals)
|
dtype: XSD datatype (for literals)
|
||||||
lang: Language tag (for literals)
|
lang: Language tag (for literals)
|
||||||
|
|
||||||
|
|
@ -47,16 +47,16 @@ def create_term(value, otype=None, dtype=None, lang=None):
|
||||||
Otherwise falls back to URL detection heuristic.
|
Otherwise falls back to URL detection heuristic.
|
||||||
"""
|
"""
|
||||||
if otype is not None:
|
if otype is not None:
|
||||||
if otype == 'U':
|
if otype == 'u':
|
||||||
return Term(type=IRI, iri=value)
|
return Term(type=IRI, iri=value)
|
||||||
elif otype == 'L':
|
elif otype == 'l':
|
||||||
return Term(
|
return Term(
|
||||||
type=LITERAL,
|
type=LITERAL,
|
||||||
value=value,
|
value=value,
|
||||||
datatype=dtype or "",
|
datatype=dtype or "",
|
||||||
language=lang or ""
|
language=lang or ""
|
||||||
)
|
)
|
||||||
elif otype == 'T':
|
elif otype == 't':
|
||||||
# Triple/reification - treat as IRI for now
|
# Triple/reification - treat as IRI for now
|
||||||
return Term(type=IRI, iri=value)
|
return Term(type=IRI, iri=value)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -43,21 +43,21 @@ def get_term_otype(term):
|
||||||
Get object type code from a Term for entity-centric storage.
|
Get object type code from a Term for entity-centric storage.
|
||||||
|
|
||||||
Maps Term.type to otype:
|
Maps Term.type to otype:
|
||||||
- IRI ("i") → "U" (URI)
|
- IRI ("i") → "u" (URI)
|
||||||
- BLANK ("b") → "U" (treated as URI)
|
- BLANK ("b") → "u" (treated as URI)
|
||||||
- LITERAL ("l") → "L" (Literal)
|
- LITERAL ("l") → "l" (Literal)
|
||||||
- TRIPLE ("t") → "T" (Triple/reification)
|
- TRIPLE ("t") → "t" (Triple/reification)
|
||||||
"""
|
"""
|
||||||
if term is None:
|
if term is None:
|
||||||
return "U"
|
return "u"
|
||||||
if term.type == IRI or term.type == BLANK:
|
if term.type == IRI or term.type == BLANK:
|
||||||
return "U"
|
return "u"
|
||||||
elif term.type == LITERAL:
|
elif term.type == LITERAL:
|
||||||
return "L"
|
return "l"
|
||||||
elif term.type == TRIPLE:
|
elif term.type == TRIPLE:
|
||||||
return "T"
|
return "t"
|
||||||
else:
|
else:
|
||||||
return "U"
|
return "u"
|
||||||
|
|
||||||
|
|
||||||
def get_term_dtype(term):
|
def get_term_dtype(term):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue