Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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');
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
 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);
         }
     }
 }