Skip to content

Instantly share code, notes, and snippets.

@dajor
Created May 1, 2021 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dajor/b8873dc029dc46e11e0a1b4b2509ff68 to your computer and use it in GitHub Desktop.
Save dajor/b8873dc029dc46e11e0a1b4b2509ff68 to your computer and use it in GitHub Desktop.
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