Skip to content

Commit 472096d

Browse files
kaustubh-darekarkartikpersistent
authored andcommitted
rectified code to not include Document node while graph_consolidation (#1007)
1 parent 198020d commit 472096d

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

backend/score.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,14 +352,15 @@ async def post_processing(uri=Form(), userName=Form(), password=Form(), database
352352
await asyncio.to_thread(create_communities, uri, userName, password, database)
353353

354354
logging.info(f'created communities')
355-
graph = create_graph_database_connection(uri, userName, password, database)
356-
graphDb_data_Access = graphDBdataAccess(graph)
357-
document_name = ""
358-
count_response = graphDb_data_Access.update_node_relationship_count(document_name)
359-
if count_response:
360-
count_response = [{"filename": filename, **counts} for filename, counts in count_response.items()]
361-
logging.info(f'Updated source node with community related counts')
362-
355+
356+
357+
graph = create_graph_database_connection(uri, userName, password, database)
358+
graphDb_data_Access = graphDBdataAccess(graph)
359+
document_name = ""
360+
count_response = graphDb_data_Access.update_node_relationship_count(document_name)
361+
if count_response:
362+
count_response = [{"filename": filename, **counts} for filename, counts in count_response.items()]
363+
logging.info(f'Updated source node with community related counts')
363364

364365
end = time.time()
365366
elapsed_time = end - start

backend/src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ def get_labels_and_relationtypes(graph):
700700
query = """
701701
RETURN collect {
702702
CALL db.labels() yield label
703-
WHERE NOT label IN ['Chunk','_Bloom_Perspective_', '__Community__', '__Entity__']
703+
WHERE NOT label IN ['Document','Chunk','_Bloom_Perspective_', '__Community__', '__Entity__']
704704
return label order by label limit 100 } as labels,
705705
collect {
706706
CALL db.relationshipTypes() yield relationshipType as type

backend/src/post_processing.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ def graph_schema_consolidation(graph):
203203
node_labels.extend(nodes_and_relations[0]['labels'])
204204
relation_labels.extend(nodes_and_relations[0]['relationshipTypes'])
205205

206+
exclude_node_labels = ['Document','Chunk','_Bloom_Perspective_', '__Community__', '__Entity__']
207+
exclude_relationship_labels = ['PART_OF', 'NEXT_CHUNK', 'HAS_ENTITY', '_Bloom_Perspective_','FIRST_CHUNK','SIMILAR','IN_COMMUNITY','PARENT_COMMUNITY']
208+
209+
node_labels = [i for i in node_labels if i not in exclude_node_labels ]
210+
relation_labels = [i for i in relation_labels if i not in exclude_relationship_labels]
211+
206212
parser = JsonOutputParser()
207213
prompt = ChatPromptTemplate(messages=[("system",GRAPH_CLEANUP_PROMPT),("human", "{input}")],
208214
partial_variables={"format_instructions": parser.get_format_instructions()})
@@ -225,8 +231,10 @@ def graph_schema_consolidation(graph):
225231
if new_label != old_label:
226232
relation_match[old_label]=new_label
227233

228-
logging.info(f"updated node labels : {node_match}")
234+
logging.info(f"updated node labels : {node_match}")
235+
logging.info(f"Reduced node counts from {len(node_labels)} to {len(node_match.items())}")
229236
logging.info(f"updated relationship labels : {relation_match}")
237+
logging.info(f"Reduced relationship counts from {len(relation_labels)} to {len(relation_match.items())}")
230238

231239
# Update node labels in graph
232240
for old_label, new_label in node_match.items():

0 commit comments

Comments
 (0)