Skip to content

Instantly share code, notes, and snippets.

@keithrozario
Created April 17, 2019 17:30
Show Gist options
  • Save keithrozario/9f60058bd28e2e15bafa61813da25914 to your computer and use it in GitHub Desktop.
Save keithrozario/9f60058bd28e2e15bafa61813da25914 to your computer and use it in GitHub Desktop.
using_spacy
import json
import spacy
def lambda_handler(event, context):
nlp = spacy.load('/opt/en_core_web_sm-2.1.0')
doc = nlp(u"Apple is looking at buying U.K. startup for $1 billion. Keith Rozario doesn't have $1 billion.")
for ent in doc.ents:
print(ent.text, ent.start_char, ent.end_char, ent.label_)
return {
'statusCode': 200,
'body': json.dumps('Done')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment