Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Function for extracting keyphrases
def extract_keyphrase(text):
# Creating Spacy's Doc object
doc=textacy.make_spacy_doc(text,lang=en)
# Getting top 5 keyphrases from the text
keyphrases=textacy.ke.textrank(doc,normalize='lower',topn=0.33)
return [phrase for phrase,score in keyphrases]
# Extracting keyphrases for abstracts in validation set
df_val['pred_keys']=df_val['abstract'].apply(extract_keyphrase)
df_val.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment