Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import spacy
- nlp = spacy.load('en')
- text_list = []
- text_list.append("I have spent 5+ years developing bug-tracking systems and creating data managing systems.")
- text_list.append("I have spent 2+ years in analysis and implementation of complex, custom-built applications.")
- for content in text_list:
- document = nlp(content)
- sentences = [sent for sent in document.sents if('year') in sent.string.lower()]
- for s in sentences:
- for ent in nlp(s.text).ents:
- if ent.label_ == "DATE":
- if('year' in ent.text):
- s_text = nlp(ent.text)
- num_list = []
- print("nText with Number::", s_text)
- for word in s_text:
- print("Word :", word, " Pos :", word.pos_, " Tag :", word.tag_, " Like Num? :", word.like_num)
- Text with Number:: 5+ years
- Word : 5 Pos : NUM Tag : CD Like Num? : True
- Word : + Pos : SYM Tag : SYM Like Num? : False
- Word : years Pos : NOUN Tag : NNS Like Num? : False
- Text with Number:: 2+ years
- Word : 2 Pos : PUNCT Tag : LS Like Num? : True
- Word : + Pos : SYM Tag : SYM Like Num? : False
- Word : years Pos : NOUN Tag : NNS Like Num? : False
Add Comment
Please, Sign In to add comment