/flashtext4s

A Scala Port of the Python package FlashText @ https://github.com/vi3k6i5/flashtext

Primary LanguageScalaMIT LicenseMIT

FlashText4s

Build Status codecov Codacy Badge

A idiomatic port of flashtext.py into Scala

Usage

Extract keywords

    val keywordProcessor = KeywordProcessor()
    keywordProcessor.addKeyWord("Scala")
    keywordProcessor.addKeyWord("Java")
    val actualResult = keywordProcessor.findKeywords("I like Scala and Java")
    actualResult shouldBe Set("Scala", "Java")

Replace keywords

    val keywordProcessor = KeywordProcessor()
    keywordProcessor.addKeyWord("Scala", "Python")
    keywordProcessor.addKeyWord("Java", "C++")
    val actualResult = keywordProcessor.replaceKeywords("I like Scala and Java")
    actualResult shouldBe "I like Python and C++"