Skip to content

Commit f2a800d

Browse files
rectified code to not include Document node while graph_consolidation (#1007)
1 parent e1db6ce commit f2a800d

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
@@ -346,14 +346,15 @@ async def post_processing(uri=Form(), userName=Form(), password=Form(), database
346346
await asyncio.to_thread(create_communities, uri, userName, password, database)
347347

348348
logging.info(f'created communities')
349-
graph = create_graph_database_connection(uri, userName, password, database)
350-
graphDb_data_Access = graphDBdataAccess(graph)
351-
document_name = ""
352-
count_response = graphDb_data_Access.update_node_relationship_count(document_name)
353-
if count_response:
354-
count_response = [{"filename": filename, **counts} for filename, counts in count_response.items()]
355-
logging.info(f'Updated source node with community related counts')
356-
349+
350+
351+
graph = create_graph_database_connection(uri, userName, password, database)
352+
graphDb_data_Access = graphDBdataAccess(graph)
353+
document_name = ""
354+
count_response = graphDb_data_Access.update_node_relationship_count(document_name)
355+
if count_response:
356+
count_response = [{"filename": filename, **counts} for filename, counts in count_response.items()]
357+
logging.info(f'Updated source node with community related counts')
357358

358359
end = time.time()
359360
elapsed_time = end - start

backend/src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ def get_labels_and_relationtypes(graph):
676676
query = """
677677
RETURN collect {
678678
CALL db.labels() yield label
679-
WHERE NOT label IN ['Chunk','_Bloom_Perspective_', '__Community__', '__Entity__']
679+
WHERE NOT label IN ['Document','Chunk','_Bloom_Perspective_', '__Community__', '__Entity__']
680680
return label order by label limit 100 } as labels,
681681
collect {
682682
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)