-
Notifications
You must be signed in to change notification settings - Fork 0
/
witt.py
48 lines (37 loc) · 1.33 KB
/
witt.py
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
39
40
41
42
43
44
45
46
47
48
import requests
import json
import os
import spacy
import en_core_web_sm
nlp = en_core_web_sm.load()
nlp = spacy.load("en_core_web_sm")
doc = nlp("Apple is looking at buying U.K. startup for $1 billion")
for token in doc:
print(token.text, token.pos_, token.dep_)
automat = "http://automat.renci.org/biolink/query"
aragorn = "https://aragorn-ranker.renci.org/score?jaccard_like=false"
strider = "http://robokop.renci.org:5781/query"
aras = [ automat, aragorn, strider ]
class Go:
def fetch (self, message, url):
response = requests.post (
url = url,
json = message)
if response.status_code != 200:
print (f"{url} - status: {response.status_code}")
#raise ValueError (f"broken request: {response.status_code}")
return response.json ()
def fetch_multiple (self, message):
for ara in aras:
response = self.fetch (message, ara)
print (json.dumps(response, indent=2))
def main ():
with open ("query.json", "r") as stream:
request = json.load (stream)
go = Go ()
response = go.fetch_multiple (request)
print (json.dumps(response, indent=2))
response = go.fetch_multiple (request)
print (json.dumps(response, indent=2))
if __name__ == '__main__':
main ()