/** * Get a text analyzer by specifying a list of text analyze processing methods. * * @param tokenization * @param letterCase * @param stopWords * @param stemming * @return */ public static TextAnalyzer get( Tokenization tokenization, LetterCase letterCase, StopWords stopWords, Stemming stemming) { TextAnalyzer analyzer = new TextAnalyzer(); analyzer.stemming = stemming; analyzer.stopWords = stopWords; analyzer.letterCase = letterCase; analyzer.tokenization = tokenization; return analyzer; }
/** * Get a text analyzer by specifying a list of text analyze processing methods. * * @param procs * @return */ public static TextAnalyzer get(TextAnalysisProcessing... procs) { TextAnalyzer analyzer = new TextAnalyzer(); for (TextAnalysisProcessing proc : procs) { // note that if any proc is null, a null exception will be thrown here // this is to make sure that get(String... procs) make uses valid alias. if (proc instanceof Stemming) { analyzer.stemming = (Stemming) proc; } else if (proc instanceof StopWords) { analyzer.stopWords = (StopWords) proc; } else if (proc instanceof LetterCase) { analyzer.letterCase = (LetterCase) proc; } else if (proc instanceof Tokenization) { analyzer.tokenization = (Tokenization) proc; } } return analyzer; }