Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions knowledge_graph/querying_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ def neighbors_reversed(
graph: triplets_index.TripletsWithIndex,
node: triplet.Element,
) -> FrozenSet[triplet.Element]:
return gamla.pipe(
triplets_index.retrieve(relation, triplets_index.object_relation_index)(
graph, node
),
gamla.map(triplet.subject),
frozenset,
return frozenset(
map(
triplet.subject,
triplets_index.retrieve(relation, triplets_index.object_relation_index)(
graph, node
),
)
)


Expand All @@ -33,12 +34,13 @@ def neighbors(
graph: triplets_index.TripletsWithIndex,
node: triplet.Element,
) -> FrozenSet[triplet.Element]:
return gamla.pipe(
triplets_index.retrieve(relation, triplets_index.subject_relation_index)(
graph, node
),
gamla.map(triplet.object),
frozenset,
return frozenset(
map(
triplet.object,
triplets_index.retrieve(relation, triplets_index.subject_relation_index)(
graph, node
),
)
)


Expand Down
9 changes: 4 additions & 5 deletions knowledge_graph/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,11 @@ def inner(node: Node):


def run_on_kg_and_node(f):
f_any_output = run_on_kg_and_node_any_output(f)

def inner(node: Node) -> Nodes:
return gamla.pipe(
node,
run_on_kg_and_node_any_output(f),
gamla.map(lambda result_node: Node(node.graph_id, result_node)),
frozenset,
return frozenset(
Node(node.graph_id, result_node) for result_node in f_any_output(node)
)

return inner
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ build-backend = "setuptools.build_meta"

[project]
name = "knowledge-graph"
version = "0.0.34"
version = "0.0.35"
description = "A library to store data in a knowledge graph"
readme = "README.md"
requires-python = ">=3.14"
authors = [{ name = "Hyro AI", email = "contact@hyro.ai" }]
keywords = ["tag1", "tag2"]
dependencies = [
"dataclasses_json==0.5.7",
"gamla==164",
"immutables",
"phonenumbers",
"pytest",
Expand Down
Loading