Skip to content

Commit

Permalink
use match rather than merge
Browse files Browse the repository at this point in the history
  • Loading branch information
yindaheng98 committed Apr 27, 2024
1 parent abd74bc commit 6b14ba2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions citation_crawler/summarizers/neo4j.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ async def add_paper(tx, paper: Paper):


async def add_reference(tx, a: Paper, b: Paper):
await tx.run("MERGE (a:Publication {title_hash: $a}) "
"MERGE (b:Publication {title_hash: $b}) "
await tx.run("MATCH (a:Publication {title_hash: $a}) "
"MATCH (b:Publication {title_hash: $b}) "
"MERGE (a)-[:CITE]->(b)",
a=a.title_hash(), b=b.title_hash())

Expand All @@ -69,7 +69,7 @@ async def match_authors_kv(tx, k, v):


async def link_author(tx, paper: Paper, author_kv, write_fields):
await tx.run("MERGE (p:Publication {title_hash: $title_hash}) " +
await tx.run("MATCH (p:Publication {title_hash: $title_hash}) " +
('MERGE (a:Person {%s}) ' % (",".join([f'{k}: ${k}' for k in author_kv]))) +
(f'SET {",".join([f"a.{k}=${k}" for k in write_fields])}' if len(write_fields) > 0 else "") +
" MERGE (a)-[:WRITE]->(p)",
Expand All @@ -83,7 +83,7 @@ async def divide_author(tx, paper: Paper, author_kv, write_fields, division_kv):
"DELETE r" % (",".join([f'{k}: ${k}' for k in division_kv])),
title_hash=paper.title_hash(), **division_kv)
write_fields = {**author_c, **write_fields, **author_kv}
await tx.run("MERGE (p:Publication {title_hash: $title_hash}) " +
await tx.run("MATCH (p:Publication {title_hash: $title_hash}) " +
('MERGE (a:Person {%s}) ' % (",".join([f'{k}: ${k}' for k in author_kv]))) +
(f'SET {",".join([f"a.{k}=${k}" for k in write_fields])}' if len(write_fields) > 0 else "") +
" MERGE (a)-[:WRITE]->(p)",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name='citation_crawler',
version='2.9.4.1',
version='2.10',
author='yindaheng98',
author_email='[email protected]',
url='https://github.com/yindaheng98/citation-crawler',
Expand Down

0 comments on commit 6b14ba2

Please sign in to comment.