#replace #string #algorithm #string-search #text-replacement #search

flashtext

Rust implementation of flashtext algorithm to search and replace keywords in given text

1 unstable release

0.1.0 Apr 6, 2020

#2512 in Data structures

Download history 155/week @ 2024-08-26 130/week @ 2024-09-02 183/week @ 2024-09-09 242/week @ 2024-09-16 274/week @ 2024-09-23 257/week @ 2024-09-30 182/week @ 2024-10-07 133/week @ 2024-10-14 169/week @ 2024-10-21 140/week @ 2024-10-28 132/week @ 2024-11-04 90/week @ 2024-11-11 99/week @ 2024-11-18 13/week @ 2024-11-25 113/week @ 2024-12-02 204/week @ 2024-12-09

430 downloads per month

MIT license

12KB
172 lines

flashtext

Build Status

Rust implementation of flashtext algorithm to search and replace keywords in given text

Usage

Add this to your Cargo.toml

[dependencies]
flashtext = "0.1.0"

Examples

Find keyword/sentence

use flashtext::KeywordProcessor;
let mut keywordprocessor = KeywordProcessor::new(false);
keywordprocessor.add_keyword("apple");
println!("{:?}", keywordprocessor.find_keywords("An apple fell from the tree");

Replace keyword/sentence

use flashtext::KeywordProcessor;
let mut keywordprocessor = KeywordProcessor::new(false);
keywordprocessor.add_keywords("dancing", "reading");
println!("{}", keywordprocessor.replace_keywords("She likes dancing"));

TODO

  • Add tests
  • Add Benchmarks
  • Setup CI

Note

This experimental implementation is for learning purposes. For better performance and more features you should use rust's regex engine.

No runtime deps