예제 #1
0
            private bool IsEntryCorrect(IWordCoOccurrenceMatrix matrix, IMatrixEntry entry,
                                        char start, string[] words)
            {
                var otherWord = words.Contains(entry.Column) ? entry.Row : entry.Column;

                if (words.Contains(otherWord) || !otherWord.StartsWith(start.ToString()))
                {
                    return(false);
                }
                return(words.All(w => matrix.GetCoOccurrenceCount(w, otherWord) > 0));
            }
예제 #2
0
            public int ComputeCoOccurrenceCount(IWordCoOccurrenceMatrix matrix)
            {
                int sum = 0;

                for (int i = Words.Count - 1; i > 0; i--)
                {
                    var current  = Words.ElementAt(i);
                    var restList = Words.GetRange(0, i);
                    sum += restList.Sum(rest => matrix.GetCoOccurrenceCount(rest, current));
                }
                return(sum);
            }
        private Boolean IsEveryWordPairExisting(IReformedQuery query)
        {
            var words = query.ReformedWords.Select(q => q.NewTerm).ToList();

            for (int i = 0; i < words.Count - 1; i++)
            {
                for (int j = i + 1; j < words.Count; j++)
                {
                    if (coOccurrenceMatrix.GetCoOccurrenceCount(words.ElementAt(i),
                                                                words.ElementAt(j)) == 0)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
예제 #4
0
 private void AssertWordPairExist(string word1, string word2)
 {
     Assert.IsTrue(matrix.GetCoOccurrenceCount(word1, word2) > 0);
 }