Exemple #1
0
        public short FindAndCount(List <string> sentences)
        {
            if (sentences == null && sentences.Count == 0)
            {
                return(-1);
            }

            try
            {
                foreach (var wordToSearch in this.Words)
                {
                    var foundWord = new FoundWord
                    {
                        Word = wordToSearch
                    };
                    var sentenceNumber = 0;

                    for (var i = 0; i < sentences.Count; i++)
                    {
                        sentenceNumber++;
                        var sourceSentence = sentences[i].Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
                        var count          = CountPerSentence(wordToSearch, sourceSentence);

                        foundWord.NumOfFoundByWord += count;
                        if (count > 0)
                        {
                            for (var x = 0; x < count; x++)
                            {
                                foundWord.AddInSentenceNumberFound(sentenceNumber);
                            }
                        }
                    }

                    FoundWords.Add(foundWord);
                }
            }
            catch (Exception)
            {
                return(-4);
            }

            return(0);
        }