/// <summary> /// Generate new document with .sfx extension after removing the suffixes using porter algorithm /// </summary> /// <returns></returns> public async Task GenerateStemmedFileAsync() { if (_documentStpWords == null) { return; } StemmedTerms = _documentStpWords.Select(term => Porter2Stemmer.EnglishPorter2Stemmer.Instance.Stem(term).Value).ToList(); // Add terms into DocumentTerms StemmedTerms.ForEach(x => _terms.Add(x)); await File.WriteAllLinesAsync($"{_sfxFile}", StemmedTerms.ToArray()); }
/// <summary> /// Get the count of term in document. /// </summary> /// <param name="term"></param> /// <returns></returns> public int Count(string term) { return(StemmedTerms.Count(x => x == term)); }
/// <summary> /// Check if term exist in the document. return <see langword="true"/> if <paramref name="term"/> exist in the list of stemmed document terms /// </summary> /// <param name="term">The term looking for</param> /// <returns></returns> public bool IsTermExist(string term) { return(StemmedTerms != null && StemmedTerms.Contains(term, StringComparer.OrdinalIgnoreCase)); }