public Result <IEnumerable <string> > ProcessWords(IEnumerable <string> words) { if (!File.Exists(_stemmer.PathToMyStem)) { return(Result.Fail <IEnumerable <string> >("Can't find path to 'mystem.exe'")); } var processedWords = new List <string>(); var lastError = ""; words = words.Select(w => w.ToLower()); foreach (var word in words) { var wordData = _stemmer.Analysis(word); Result.Ok(wordData) .Then(wd => GetPartOfSpeech(wd, word)) .Then(ps => { var infinitive = GetInfinitiveForm(wordData, word); if (!boringPartsOfSpeech.Contains(ps)) { processedWords.Add(_infinitive && infinitive.IsSuccess ? infinitive.Value : word); } }).OnFail(e => lastError = e); } return(lastError != "" ? Result.Fail <IEnumerable <string> >(lastError) : processedWords); }
private static bool IsNoun(string word) { var index = word.Length * 2 + 2; var analyse = Stemmer.Analysis(word); Console.Write(word[0]); return(analyse[index] == 'S'); }
public bool IsWordNotBoring(string word) { var wordGrammeme = new string(myStem.Analysis(word) .SkipWhile(x => x != '=') .Skip(1) .TakeWhile(char.IsLetter) .ToArray()); return(!boringGrammemes.Contains(wordGrammeme)); }
public IEnumerable <string> ProcessWords(IEnumerable <string> words) { words = words.Select(w => w.ToLower()); foreach (var word in words) { var wordData = _stemmer.Analysis(word); var partOfSpeech = GetPartOfSpeech(wordData); if (!boringPartsOfSpeech.Contains(partOfSpeech)) { yield return(_infinitive ? GetInfinitiveForm(wordData) : word); } } }