/// <summary> /// Stems the words. /// </summary> /// <param name="words">The words.</param> /// <param name="language"></param> /// <returns>The resulting stemmed words.</returns> public string[] Stem(string[] words, StemmerLanguage language) { if (!Languages.TryGetValue(language, out var Stemmer)) { return(words); } return(Stemmer.StemWords(words)); }
/// <summary> /// Stems the words. /// </summary> /// <param name="words">The words.</param> /// <param name="language"></param> /// <returns>The resulting stemmed words.</returns> public string[] Stem(string[] words, StemmerLanguage language) { if (!Languages.ContainsKey(language)) { return(words); } return(Languages[language].StemWords(words)); }
/// <summary> /// Stems the specified tokens. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="language">The language.</param> /// <returns>The resulting stemmed tokens.</returns> public Token[] Stem(Token[] tokens, StemmerLanguage language) { Token[] FinalTokens = tokens.Where(x => x.TokenType == TokenType.Word).ToArray(); var Results = Stem(FinalTokens.Select(x => x.Value).ToArray(), language); for (int x = 0; x < Results.Length; ++x) { FinalTokens[x].Value = Results[x]; } return(tokens); }
/// <summary> /// Withes the specified stemmer. /// </summary> /// <param name="stemmer">The stemmer.</param> /// <returns>This.</returns> /// <exception cref="ArgumentNullException">stemmer</exception> public Pipeline With(StemmerLanguage stemmer) { StemmerLanguage = stemmer ?? throw new ArgumentNullException(nameof(stemmer)); return(this); }