Keyword Extraction using Rake algorithm in Python

Anindya Naskar
2 min readAug 23, 2023

--

keywork extraction or entity extraction using rake algorithm in Python
thinkinfi.com

Sometimes we want to find out the main words or phrases from a text. This can help us to search for information better. This is called keyword extraction or entity extraction. It is a part of natural language processing, which is a field of computer science.

There are many ways to do keyword extraction. Some of them are based on how often a word or a group of words appears in the text. Some of them are based on the grammar of the words. But all of these methods need a lot of human work to make rules.

In this topic, I will show you how to do keyword extraction automatically using a Python package called RAKE. It is based on a technique that does not need any rules.

Also Read:

Why to extract keywords:

  • You can judge a comment or sentence within a second just by looking at keyword of a sentence.
  • You can make decision whether the comment or sentence is worth reading or not.
  • Further you can categorize the sentence to any category. For example whether a certain comment is about mobile or hotel etc.
  • You can also use keywords or entity as a feature for your supervised model to train.

Extract keyword using RAKE in Python:

# Sample text to test RAKE
text = """Google quietly rolled out a new way for Android users to listen
to podcasts and subscribe to shows they like, and it already works on
your phone. Podcast production company Pacific Content got the exclusive
on it.This text is taken from Google news."""

# Extract keywords
keywords = rake_object.run(text)
print ("keywords: ", keywords)

Output:

(‘keywords: ‘, [(‘podcast production company pacific content’, 25.0), (‘google quietly rolled’, 8.5), (‘google news’, 4.5), (‘android users’, 4.0), (‘exclusive’, 1.0), (‘works’, 1.0), (‘phone’, 1.0), (‘text’, 1.0), (‘podcasts’, 1.0), (‘subscribe’, 1.0), (‘listen’, 1.0), (‘shows’, 1.0)])

How RAKE algorithm works?

Read this article to know how rake algorithm works with Python implementation.

--

--

No responses yet