Beispiel #1
0
 /// <summary>
 /// Adds pattern ending in this node
 /// </summary>
 /// <param name="ngram">Pattern</param>
 public void AddNgram(NGram <TValue> ngram)
 {
     if (_nGrams == null)
     {
         _nGrams = new HashSet <NGram <TValue> >(NGramEqualityComparer.Instance);
     }
     _nGrams.Add(ngram);
 }
Beispiel #2
0
        public static NGram <BeforeNoProper> ToBeforeNoProper_ngrams(this XElement xe)
        {
            var words = xe.GetWordsArray();
            var unstick_from_digits = xe.AttrValueIsTrue("unstick-from-digits");

            var ngram = new NGram <BeforeNoProper>(words, new BeforeNoProper(unstick_from_digits));

            return(ngram);
        }
Beispiel #3
0
        public static NGram <BeforeProperOrNumber> ToBeforeProperOrNumber_ngrams(this XElement xe)
        {
            var words               = xe.GetWordsArray();
            var digits_before       = xe.AttrValueIsTrue("digits-before");
            var slash_before        = xe.AttrValueIsTrue("slash-before");
            var unstick_from_digits = xe.AttrValueIsTrue("unstick-from-digits");

            var ngram = new NGram <BeforeProperOrNumber>(words, new BeforeProperOrNumber(digits_before, slash_before, unstick_from_digits));

            return(ngram);
        }
Beispiel #4
0
                public bool Equals(NGram <TValue> x, NGram <TValue> y)
                {
                    var len = x.Words.Length;

                    if (len != y.Words.Length)
                    {
                        return(false);
                    }

                    for (int i = 0; i < len; i++)
                    {
                        if (!string.Equals(x.Words[i], y.Words[i]))
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
Beispiel #5
0
 public int GetHashCode(NGram <TValue> obj)
 {
     return(obj.Words.Length.GetHashCode());
 }