#replace #string #algorithm #string-search #search

flashtext

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

1 unstable release

0.1.0 Apr 6, 2020

#2299 in Data structures

Download history 142/week @ 2024-04-08 142/week @ 2024-04-15 167/week @ 2024-04-22 137/week @ 2024-04-29 116/week @ 2024-05-06 89/week @ 2024-05-13 127/week @ 2024-05-20 104/week @ 2024-05-27 72/week @ 2024-06-03 57/week @ 2024-06-10 63/week @ 2024-06-17 129/week @ 2024-06-24 84/week @ 2024-07-01 176/week @ 2024-07-08 106/week @ 2024-07-15 139/week @ 2024-07-22

512 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