sastrawi 0.1.1

A library for stemming and stopword removal for Bahasa Indonesia based on PHP sastrawi project by Andy Librian
Documentation
use crate::dictionary::Dictionary;
use crate::tokenizer::Tokenizer;

pub struct StopWord<'a> {
    dictionary: &'a Dictionary,
    tokenizer: Tokenizer,
}

impl<'a> StopWord<'a> {
    pub fn new(dictionary: &Dictionary) -> StopWord {
        let tokenizer = Tokenizer::new();
        StopWord{
            dictionary: dictionary,
            tokenizer: tokenizer,
        }
    }

    pub fn stop_word(&self, sentence: &mut String) {
        let words = self.tokenizer.tokenize(sentence);
        let mut results: Vec<String> = Vec::new();

        for word in words.iter() {
            if !self.dictionary.find(word) {
                results.push(word.clone());
            }
        }

        *sentence = results.join(" ");
    }
}