Skip to content

Commit

Permalink
fix: declobber multiple labeled iri values when flattering
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Aug 24, 2023
1 parent 47db09f commit 4930124
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions share/search/index_strategy/trove_indexcard_flats.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,19 +248,25 @@ def _iri_nested_sourcedoc(self, iri_key: '_NestedIriKey', iris, rdfdoc):
}
return _sourcedoc

def _flattened_iris_by_path(self, nested_iris: dict['_NestedIriKey', set[str]]):
_by_path = defaultdict(set)
for _iri_key, _iris in nested_iris.items():
_by_path[_iri_key.path].update(_iris)
return _by_path

def _flattened_iris(self, nested_iris: dict['_NestedIriKey', set[str]]):
return {
_iri_path_as_flattened_key(_iri_key.path): list(_iris)
for _iri_key, _iris in nested_iris.items()
_iri_path_as_flattened_key(_path): list(_iris)
for _path, _iris in self._flattened_iris_by_path(nested_iris).items()
}

def _flattened_iris_suffuniq(self, nested_iris: dict['_NestedIriKey', set[str]]):
return {
_iri_path_as_flattened_key(_iri_key.path): [
_iri_path_as_flattened_key(_path): [
get_sufficiently_unique_iri(_iri)
for _iri in _iris
]
for _iri_key, _iris in nested_iris.items()
for _path, _iris in self._flattened_iris_by_path(nested_iris).items()
}

def build_elastic_actions(self, messages_chunk: messages.MessagesChunk):
Expand Down

0 comments on commit 4930124

Please sign in to comment.