Description
This module can be used to replace keywords in sentences or extract keywords from sentences. It is based on the FlashText algorithm
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.
Scout Monitoring - Performance metrics and, now, Logs Management Monitoring with Scout Monitoring
Do you think we are missing an alternative of Flashtext Ruby Gem or a related project?
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
- Issue Tracker: https://github.com/imran3180/flashtext/issues
- Source Code: https://github.com/imran3180/flashtext/issues
Implementation in other languages
- Python: https://github.com/vi3k6i5/flashtext (Core Project)
- JavaScript: https://github.com/drenther/flashtext.js
- Golang: https://github.com/sundy-li/flashtext
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.