Skip to content

Instantly share code, notes, and snippets.

@robgon-art
Created June 5, 2022 20:16
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 robgon-art/e559ef395deda86b6b7186f1111e4543 to your computer and use it in GitHub Desktop.
Save robgon-art/e559ef395deda86b6b7186f1111e4543 to your computer and use it in GitHub Desktop.
extract keyphrases using pke
import pke
extractor = pke.unsupervised.TopicRank()
num_keywords = 10
phrase = "penguins skiing down a snowy mountain"
extractor.load_document(input=phrase)
extractor.candidate_selection(pos={'NOUN', 'PROPN', 'ADJ', 'VERB'})
extractor.candidate_weighting()
keyphrases = extractor.get_n_best(n=num_keywords, stemming=False)
print(keyphrases)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment