rake_new2
rake_new2 is a Python library that enables simple and fast keyword extraction from any text. As the name implies, this library works on the RAKE(Rapid Automatic Keyword Extraction) algorithm.
It tries to determine the key phrases in a text by calculating the co-occurrences of every word in a key phrase and also its frequency in the entire text.

New in this version
-
Handles repetitive keywords/key-phrases
-
Handles consecutive punctuations.
-
Handles HTML tags in text : The user is allowed an option to choose if they want to keep HTML tags as keywords too.

Installation
Use the package manager pip to install rake_new2.
pip install rake_new2
Quick Start
from rake_new2 import Rake
text = "Red apples are good in taste."
text2 = "<h1> Hello world !</h1>"
rk,rk_new1,rk_new2 = Rake(),Rake(keep_html_tags=True),Rake(keep_html_tags=False)
rk.get_keywords_from_raw_text(text)
kw_s = rk.get_keywords_with_scores()
kw = rk.get_ranked_keywords()
f = rk.get_word_freq()
deg = rk.get_kw_degree()
print("\nORIGINAL TEXT : {}".format(text))
rk_new1.get_keywords_from_raw_text(text2)
kw_s1 = rk_new1.get_keywords_with_scores()
kw1 = rk_new1.get_ranked_keywords()
print("Keeping the tags : ",kw1)
rk_new2.get_keywords_from_raw_text(text2)
kw_s2 = rk_new2.get_keywords_with_scores()
kw2 = rk_new2.get_ranked_keywords()
print("Eliminating the tags : ",kw2)
'''OUTPUT >>
ORIGINAL TEXT : <h1> Hello world !</h1>
Keeping the tags : {'h1', 'hello'}
Eliminating the tags : {'hello world'}
'''
Debugging
You might come across a stopwords error.
It implies that you do not have the stopwords corpus downloaded from NLTK.
To download it, use the command below.
python -c "import nltk; nltk.download('stopwords')"
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
MIT