Created
May 1, 2021 12:26
-
-
Save dajor/b8873dc029dc46e11e0a1b4b2509ff68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_hotwords(text): | |
result = [] | |
pos_tag = ['PROPN', 'ADJ', 'NOUN'] # 1 | |
doc = nlp(text.lower()) # 2 | |
for token in doc: | |
# 3 | |
if(token.text in nlp.Defaults.stop_words or token.text in punctuation): | |
continue | |
# 4 | |
if(token.pos_ in pos_tag): | |
result.append(token.text) | |
return result # 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment