FLORA parser workflows have optional-file guard and dataset-shape inconsistencies
1. OpenEA attribute file guard is inverted
Location: ontoaligner/ontology/kg.py:1028
Current code:
if not attribute_path:
with open(attribute_path, 'r', encoding='UTF-8') as attribute_file:
This skips valid attribute files and tries to open None when no attribute file is provided.
Observed before fix:
Case 1: attribute path is provided
BUG: no FileNotFoundError, so attribute_path was ignored
Case 2: attribute path is None
BUG: TypeError expected str, bytes or os.PathLike object, not NoneType
Fix:
if attribute_path:
with open(attribute_path, 'r', encoding='UTF-8') as attribute_file:
2. OpenEA dataset output shape breaks FLORAEncoder
Location: ontoaligner/ontology/kg.py:1644-1645
Current code:
"source": source_kg,
"target": target_kg,
But FLORAEncoder expects:
kwargs["source"][0]["graph"]
kwargs["target"][0]["graph"]
Observed before fix:
source type: <class 'dict'>
target type: <class 'dict'>
FAIL: KeyError 0
Fix:
"source": [source_kg],
"target": [target_kg],
Verified after fix:
source type: <class 'list'>
target type: <class 'list'>
PASS: FLORAEncoder accepted OpenEA dataset output
encoded length: 2
encoded[0] type: <class 'ontoaligner.ontology.kg.Graph'>
encoded[1] type: <class 'ontoaligner.ontology.kg.Graph'>
3. DBpedia optional translated names and attributes use inverted guards
Locations: ontoaligner/ontology/kg.py:1188, ontoaligner/ontology/kg.py:1222
Current code:
if (not translated_name_path) and ent_ids_path.endswith('_1'):
ent_name_trans = {}
with open(translated_name_path, encoding='UTF-8') as f2:
and:
if not att_triples_path:
for triple in parse_turtle_triples(att_triples_path):
This ignores provided optional files and crashes when optional paths are missing.
Observed before fix:
translated label loaded: False
attribute triple loaded: False
FAIL: TypeError expected str, bytes or os.PathLike object, not NoneType
Fix:
if translated_name_path and ent_ids_path.endswith('_1'):
and:
Verified after fix:
translated label loaded: True
attribute triple loaded: True
PASS: optional paths did not crash
4. Graph attribute detection checks subjects instead of literal objects
Location: ontoaligner/ontology/kg.py:298-300
Current code:
def is_attribute(self, pred):
"""
Return ``True`` if at least one object of ``pred`` is a literal.
Args:
pred (str): Predicate IRI to test.
Returns:
bool: ``True`` if the predicate has any literal objects.
"""
if pred in self.relindex:
for literal in self.relindex[pred]:
if is_literal(literal):
return True
return False
Graph.relindex is structured as:
{predicate: {subject: {objects}}}
So this loop:
for literal in self.relindex[pred]:
actually iterates over the subjects, not the object values. The variable name literal is misleading.
Observed before fix:
relindex[predicate]: {'http://example.org/material1': {'"Steel"'}}
is_attribute(predicate): False
AssertionError: BUG: Graph.is_attribute() returned False even though the predicate has a literal object.
The graph contains a literal object:
but is_attribute() checks the subject:
http://example.org/material1
so the predicate is incorrectly treated as non-attribute.
Fix:
Iterate one level deeper and test the actual objects:
def is_attribute(self, pred):
"""
Return ``True`` if at least one object of ``pred`` is a literal.
Args:
pred (str): Predicate IRI to test.
Returns:
bool: ``True`` if the predicate has any literal objects.
"""
if pred in self.relindex:
for subject in self.relindex[pred]:
for literal in self.relindex[pred][subject]:
if is_literal(literal):
return True
return False
Verified after fix:
relindex[predicate]: {'http://example.org/material1': {'"Steel"'}}
is_attribute(predicate): True
PASS: Graph.is_attribute() correctly detects literal objects.
FLORA parser workflows have optional-file guard and dataset-shape inconsistencies
1. OpenEA attribute file guard is inverted
Location:
ontoaligner/ontology/kg.py:1028Current code:
This skips valid attribute files and tries to open
Nonewhen no attribute file is provided.Observed before fix:
Fix:
2. OpenEA dataset output shape breaks FLORAEncoder
Location:
ontoaligner/ontology/kg.py:1644-1645Current code:
But
FLORAEncoderexpects:Observed before fix:
Fix:
Verified after fix:
3. DBpedia optional translated names and attributes use inverted guards
Locations:
ontoaligner/ontology/kg.py:1188,ontoaligner/ontology/kg.py:1222Current code:
and:
This ignores provided optional files and crashes when optional paths are missing.
Observed before fix:
Fix:
and:
Verified after fix:
4. Graph attribute detection checks subjects instead of literal objects
Location:
ontoaligner/ontology/kg.py:298-300Current code:
Graph.relindexis structured as:{predicate: {subject: {objects}}}So this loop:
actually iterates over the subjects, not the object values. The variable name
literalis misleading.Observed before fix:
The graph contains a literal object:
but
is_attribute()checks the subject:so the predicate is incorrectly treated as non-attribute.
Fix:
Iterate one level deeper and test the actual objects:
Verified after fix: