Crates.io | mapwords |
lib.rs | mapwords |
version | 0.1.5 |
source | src |
created_at | 2023-03-23 10:29:12.865559 |
updated_at | 2023-03-24 00:11:14.425235 |
description | HashMap based keyword extraction |
homepage | https://github.com/jjoeldaniel/mapwords.rs |
repository | https://github.com/jjoeldaniel/mapwords.rs |
max_upload_size | |
id | 818194 |
size | 14,810 |
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.
To use mapwords.rs in your Rust project, add the following line to your Cargo.toml file:
[dependencies]
mapwords = "0.1.5"
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();
mapwords.rs is licensed under the WTFPL License. See the LICENSE file for more details.