Note
Click here to download the full example code
Keyphrase Extraction (English)ΒΆ
The following example uses a python implementation of the Rapid Automatic Keyword Extraction algorithm to extract keyphrases from a text.
import pandas as pd
from enlp.processing.stdtools import get_stopwords
from enlp.understanding.keywords import keyphrase_list
Load example text and get stopwords
with open("example_data/en_historynlp.txt", "r") as file:
text=file.read()
all_stopwords, stopwords_nb, stopwords_en = get_stopwords()
Extract keyphrases
keyphrases = keyphrase_list(text,
stopwords=stopwords_en,
)
print (pd.DataFrame(keyphrases, columns=['score', 'keyphrase']).head(10))
Out:
score keyphrase
0 4.0 word embeddings
1 4.0 word alignment
2 4.0 valued weights
3 4.0 typically produces
4 4.0 turing test
5 4.0 tasks implemented
6 4.0 supervised learning
7 4.0 startlingly human
8 4.0 speech tagging
9 4.0 solved problem
Total running time of the script: ( 0 minutes 0.021 seconds)