MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / semantic_query

Function semantic_query

bmtools/tools/meta_analysis/api.py:55–74  ·  view source on GitHub ↗
(term, retmax=100)

Source from the content-addressed store, hash-verified

53 return doc_sim
54
55def semantic_query(term, retmax=100):
56 if retmax>100:
57 print('semantic searching fewer than 100!')
58 retmax = 100
59 for cnt in range(10):
60 url = 'https://api.semanticscholar.org/graph/v1/paper/search?query='+term.replace(' ', '+')+'&limit='+str(retmax)+'&fields=title,authors,abstract'
61 re = requests.get(url)
62 results = json.loads(re.text)
63 docs = {}
64 if 'data' in results:
65 break
66 tmp = 0
67 while tmp<10000:
68 tmp+=1
69 if 'data' not in results:
70 return docs
71 for item in results['data']:
72 if item['abstract'] is not None:
73 docs[item['title']] = item['abstract']
74 return docs
75
76def draw_term(topic):
77 prp = """Concatenate the searching keywords (fewer than 5) in the topic with '+'. For example, when given 'experiments about the harmness of using insulin for teenagers to treat diabetes', answer me with 'insulin+harmness+diabetes+teenager'; when given 'The Operational Situation of Bookstores after Digitalization of Reading', answer me with 'bookstore+digitalization'. Topic: """+topic+'. Give me the answer with no extra words. '

Callers 1

initialFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected