<commit_before>pub mod ngram_generator;
pub mod lucene_asciifold;
pub mod registry;
pub mod tokenizers;
pub mod filters;

use term::Term;
use token::Token;

use analysis::ngram_generator::Edge;
use analysis::tokenizers::standard::StandardTokenizer;
use analysis::filters::lowercase::LowercaseFilter;
use analysis::filters::asciifolding::ASCIIFoldingFilter;
use analysis::filters::ngram::NGramFilter;<commit_msg>Implemented AnalyzerSpec<commit_after>pub mod ngram_generator;
pub mod lucene_asciifold;
pub mod registry;
pub mod tokenizers;
pub mod filters;

use term::Term;
use token::Token;

use analysis::tokenizers::TokenizerSpec;
use analysis::filters::FilterSpec;
use analysis::ngram_generator::Edge;
use analysis::tokenizers::standard::StandardTokenizer;
use analysis::filters::lowercase::LowercaseFilter;
use analysis::filters::asciifolding::ASCIIFoldingFilter;
use analysis::filters::ngram::NGramFilter;


#[derive(Debug)]
pub struct AnalyzerSpec {
    pub tokenizer: TokenizerSpec,
    pub filters: Vec<FilterSpec>,
}


impl AnalyzerSpec {
    pub fn initialise<'a>(&self, input: &'a str) -> Box<Iterator<Item=Token> + 'a> {
        let mut analyzer = self.tokenizer.initialise(input);

        for filter in self.filters.iter() {
            analyzer = filter.initialise(analyzer);
        }

        analyzer
    }
}
{'fraction_non_alphanumeric': 0.11849056603773585, 'fraction_numerical': 0.0, 'mean_word_length': 6.3259668508287294, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5182391', 'n_tokens_mistral': 404, 'n_tokens_neox': 399, 'n_words': 93}