Popularity
0.8
Stable
Activity
0.0
Stable
9
4
0

Description

This module can be used to replace keywords in sentences or extract keywords from sentences. It is based on the FlashText algorithm

Monthly Downloads: 297
Programming language: Ruby
License: MIT License
Latest version: v0.1.2

Flashtext Ruby Gem alternatives and similar gems

Based on the "Data Structures" category.
Alternatively, view Flashtext Ruby Gem alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Flashtext Ruby Gem or a related project?

Add another 'Data Structures' Gem

README

Flashtext Ruby Gem

Ruby (zero dependencies) gem for amazing Python package flashtext

This module can be used to replace keywords in sentences or extract keywords from sentences. It is based on the FlashText algorithm

More about Flashtext algorithm.

The original paper published on FlashText algorithm

The article published on Medium freeCodeCamp

Installation

$ gem install flashtext

API doc

Documentation can be found at FlashText Read the Docs

Usage

If you are using irb console

require 'flashtext'

Extract keywords

keyword_processor = Flashtext::KeywordProcessor.new
# keyword_processor.add_keyword(<unclean name>, <standardised name>)
keyword_processor.add_keyword('Big Apple', 'New York')
keyword_processor.add_keyword('Bay Area')
keywords_found = keyword_processor.extract_keywords('I love Big Apple and Bay Area.')
keywords_found
#=> ["New York", "Bay Area"]

Replace keywords

keyword_processor.add_keyword('New Delhi', 'NCR region')
new_sentence = keyword_processor.replace_keywords('I love Big Apple and new delhi.')
new_sentence
#=> "I love New York and NCR region."

Case Sensitive example

keyword_processor = Flashtext::KeywordProcessor.new(case_sensitive = true)
keyword_processor.add_keyword('Big Apple', 'New York')
keyword_processor.add_keyword('Bay Area')
keywords_found = keyword_processor.extract_keywords('I love big Apple and Bay Area.')
keywords_found
#=> ['Bay Area']

Test

rspec spec

Contribute

Implementation in other languages

License

This code is under MIT license.


*Note that all licence references and agreements mentioned in the Flashtext Ruby Gem README section above are relevant to that project's source code only.