#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

#2082 in Data structures

Download history 460/week @ 2023-12-04 706/week @ 2023-12-11 656/week @ 2023-12-18 19/week @ 2023-12-25 602/week @ 2024-01-01 612/week @ 2024-01-08 437/week @ 2024-01-15 309/week @ 2024-01-22 309/week @ 2024-01-29 236/week @ 2024-02-05 545/week @ 2024-02-12 364/week @ 2024-02-19 330/week @ 2024-02-26 422/week @ 2024-03-04 374/week @ 2024-03-11 428/week @ 2024-03-18

1,566 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