4 releases

0.1.5 Mar 24, 2023
0.1.4 Mar 23, 2023

#2076 in Algorithms

Download history 20/week @ 2024-07-25 3/week @ 2024-08-01 6/week @ 2024-09-19 2/week @ 2024-09-26

62 downloads per month

WTFPL license

9KB
216 lines

mapwords.rs

https://github.com/jjoeldaniel/mapwords.rs/actions/workflows/ci.yml

mapwords.rs is a Rust library that provides functionality for collecting keywords from a given string or file and then sorts and prints them based on their frequency. It ignores stop words and only returns the most frequently occurring keywords.

Installation

To use mapwords.rs in your Rust project, add the following line to your Cargo.toml file:

[dependencies]
mapwords = "0.1.5"

Usage

First, import the MapWordsString or MapWordsFile struct from the mapwords crate:

use mapwords::MapWordsString;
use mapwords::MapWordsFile;

Then, create a new instance of either struct by calling the new function with either a string or file path and a number representing the number of top keywords to return:

let mut map_words = MapWordsString::new("This is a test string".to_string(), 2);

You can then get the keywords by calling the get_keywords() function. This returns a Vec<(&u16, &String)> if you would like to print it out yourself

let keywords = map_words.get_keywords();

Finally, you can print the top keywords by calling the print_keywords() function:

map_words.print_keywords();

License

mapwords.rs is licensed under the WTFPL License. See the LICENSE file for more details.

Dependencies

~2.2–3MB
~54K SLoC