Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# rule 3 function
def rule3_mod(text):
doc = nlp(text)
sent = []
for token in doc:
if token.pos_=='ADP':
phrase = ''
if token.head.pos_=='NOUN':
# appended rule
append = rule0(text, token.head.i)
if len(append)!=0:
phrase += append
else:
phrase += token.head.text
phrase += ' '+token.text
for right_tok in token.rights:
if (right_tok.pos_ in ['NOUN','PROPN']):
right_phrase = ''
# appended rule
append = rule0(text, right_tok.i)
if len(append)!=0:
right_phrase += ' '+append
else:
right_phrase += ' '+right_tok.text
phrase += right_phrase
if len(phrase)>2:
sent.append(phrase)
return sent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.