1 use lazy_static::lazy_static;
2 use std::collections::BTreeSet;
3 
4 #[cfg(feature = "textrank")]
5 pub mod textrank;
6 #[cfg(feature = "tfidf")]
7 pub mod tfidf;
8 
9 lazy_static! {
10     pub static ref STOP_WORDS: BTreeSet<String> = {
11         let mut set = BTreeSet::new();
12         let words = [
13             "the", "of", "is", "and", "to", "in", "that", "we", "for", "an", "are", "by", "be", "as", "on", "with",
14             "can", "if", "from", "which", "you", "it", "this", "then", "at", "have", "all", "not", "one", "has", "or",
15             "that",
16         ];
17 
18         for &s in words.iter() {
19             set.insert(String::from(s));
20         }
21 
22         set
23     };
24 }
25 
26 /// Keyword with weight
27 #[derive(Debug, Clone)]
28 pub struct Keyword {
29     pub keyword: String,
30     pub weight: f64,
31 }
32 
33 pub trait KeywordExtract {
extract_tags(&self, sentence: &str, top_k: usize, allowed_pos: Vec<String>) -> Vec<Keyword>34     fn extract_tags(&self, sentence: &str, top_k: usize, allowed_pos: Vec<String>) -> Vec<Keyword>;
35 }
36