OCRreadingtextFromImage / textUtility.py
sunny333's picture
pos update
bbac268
raw
history blame contribute delete
501 Bytes
import spacy
def get_entity_from_text(text):
res = "--details--"+"\n"
nlp = spacy.load("en_core_web_sm")
docs = nlp(text)
for ent in docs.ents:
res = res + ent.text +" - "+ ent.label_+"\n"
#print(ent.text, ent.label_)
return res
def get_pos_from_text(text):
res = "--details--"+"\n"
nlp = spacy.load("en_core_web_sm")
docs = nlp(text)
for token in docs:
res = res + token.text+" : " + token.pos_ + " "+ token.tag_ +"\n"
return res