-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Please consider updating the parse_triple function in the Neo4jTriple class. This function doesn't take into account the language properties of the object it's assigned to in a configuration like this.
config = Neo4jStoreConfig(auth_data=auth_data,
handle_vocab_uri_strategy= HANDLE_VOCAB_URI_STRATEGY.MAP,
handle_multival_strategy= HANDLE_MULTIVAL_STRATEGY.ARRAY,
multival_props_names=[("skos","prefLabel"), ("skos","altLabel")],
batching=True)I made this code modification to correct this.
def parse_triple(self, triple, mappings):
"""
Parses a triple and updates the Neo4jTriple object accordingly.
Args:
triple: The triple to parse.
mappings: A dictionary of mappings for predicate URIs.
"""
(subject, predicate, object) = triple
# Getting a property
if isinstance(object, Literal):
# Neo4j Python driver does not support decimal params
value = float(object.toPython()) if type(object.toPython()) == Decimal else object.toPython()
prop_name = self.handle_vocab_uri(mappings, predicate)
# If at least a name is defined and the predicate is one of the properties defined by the user
if self.handle_multival_strategy == HANDLE_MULTIVAL_STRATEGY.ARRAY and \
str(predicate) in self.multival_props_names:
if object.language is not None:
value = object.value + '@' + object.language
self.add_prop(prop_name, value, True)
# If the user doesn't define any predicate to manage as an array, then everything is an array
elif self.handle_multival_strategy == HANDLE_MULTIVAL_STRATEGY.ARRAY and not self.multival_props_names:
if object.language is not None:
value = object.value + '@' + object.language
self.add_prop(prop_name, value, True)
else:
self.add_prop(prop_name, value)
# Getting a label
elif predicate == RDF.type:
self.add_label(self.handle_vocab_uri(mappings, object))
# Getting its relationships
else:
rel_type = self.handle_vocab_uri(mappings, predicate)
self.add_rel(rel_type, object)Metadata
Metadata
Assignees
Labels
No labels