File size: 1,070 Bytes
497f49b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import asyncio
import sys

sys.path.insert(0, ".")

from services.neo4j_service import Neo4jService
from services.paper_recommender import PaperRecommender


async def main():
    neo4j = Neo4jService()
    rows = neo4j.run(
        "MATCH (c:Claim {doc_id: $doc_id}) RETURN c.text AS text, c.claim_id AS cid "
        "ORDER BY c.composite_score DESC LIMIT 5",
        doc_id="doc_65382c73",
    )
    kw = [
        r["term"]
        for r in neo4j.run(
            "MATCH (k:Keyword {doc_id: $doc_id}) RETURN k.term AS term "
            "ORDER BY k.score DESC LIMIT 15",
            doc_id="doc_65382c73",
        )
        if r.get("term")
    ]
    print("KEYWORDS:", kw[:10])
    pr = PaperRecommender()
    for row in rows:
        t = row["text"]
        print("---", row["cid"], "|", t[:90])
        recs = await pr.search_web(t, limit=4, keywords=kw)
        print("    search_web:", len(recs))
        for r in recs[:3]:
            print("      >", r.get("source"), "|", (r.get("title") or "")[:55], "| abs:", bool(r.get("abstract")))


asyncio.run(main())