// *** IStemmer interface implementation *** public string GetStem(string word) { Utils.ThrowException(word == null ? new ArgumentNullException("word") : null); mStemmer.SetCurrent(word); mStemmer.Stem(); return(mStemmer.GetCurrent()); }
// *** IStemmer interface implementation *** public string GetStem(string word) { Utils.ThrowException(word == null ? new ArgumentNullException("word") : null); try { ISnowballStemmer stemmer = CreateStemmer(); stemmer.SetCurrent(word); stemmer.Stem(); return(stemmer.GetCurrent()); } catch { return(word); } }
/// <summary> /// Processes a string of terms using the Snowball stemming algorithm. /// </summary> /// <param name="text">Input string</param> /// <param name="language">Stemmer language</param> /// <returns>Stemmed terms</returns> public static string ProcessText(string text, SnowballStemmerEnum language) { StringBuilder builder = new StringBuilder(); string result = string.Empty; string stemmedWord; char[] delimiterChars = { ' ' }; string[] tokens = text.Split(delimiterChars); ISnowballStemmer stemmer = SnowballStemmerUtils.GetStemmer(language); foreach (string token in tokens) { stemmedWord = stemmer.Stem(token); builder.AppendFormat("{0} ", stemmedWord); } result = builder.ToString().Trim(); return(result); }