Skip to content

Instantly share code, notes, and snippets.

@hmehta4
Created April 27, 2019 00:25
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save hmehta4/b8f3b657f14db95a4a079d296289b303 to your computer and use it in GitHub Desktop.
Gist of REST-annotator code
from PDF2bs4 import *
import requests as r
import pprint
def send_text(a):
txt = a
txt2annotate = txt[0:500]
#Link: http://docs.python-requests.org/en/master/user/quickstart/
data = {'apikey': '25c05e76-1580-4f46-abea-dd60c0a0596a', 'text':txt2annotate}
req = 'https://bioportal.bioontology.org/annotator'
r1 = r.post(req, data)
#print(r1.content)
print(r1.status_code)
#print(r1.url)
pp = pprint.PrettyPrinter(indent=2)
pp.pprint(r1.text)
if __name__ == '__main__':
case = 'text'
filePDF = 'StdLabData.pdf'
if case == 'text' :
convertedPDF = convert('text', filePDF, pages=[0,1])
#print(convertedPDF)
send_text(convertedPDF)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment