public static void AddIfNotExists(this List <MorphoAmbiguityTuple> mats, MorphoAmbiguityTuple mat) { for (int i = 0, len = mats.Count; i < len; i++) { if (Equals(mats[i], mat)) { return; } } mats.Add(mat); }
private static bool Equals(MorphoAmbiguityTuple x, MorphoAmbiguityTuple y) { if (!WordFormMorphology.Equals(ref x.wordFormMorphology, ref y.wordFormMorphology)) { return(false); } if (string.CompareOrdinal(x.word.valueUpper, y.word.valueUpper) != 0) { return(false); } return(x.punctuationType == y.punctuationType); }
unsafe public WordMorphoAmbiguity Create(Word word, int wordIdex) { while (_MorphoAmbiguityTuples_Buffer.Count <= wordIdex) { _MorphoAmbiguityTuples_Buffer.Add(new List <MorphoAmbiguityTuple>(DEFAULT_WORDFORMMORPHOLOGY_COUNT)); } var punctuationType = MorphoAmbiguityTuple.GetPunctuationType(word); var buffer = _MorphoAmbiguityTuples_Buffer[wordIdex]; buffer.Clear(); buffer.Add(new MorphoAmbiguityTuple(word, new WordFormMorphology(), punctuationType)); return(new WordMorphoAmbiguity(word, punctuationType, buffer)); }
unsafe public WordMorphoAmbiguity Create(Word word, int wordIdex, WordFormMorphology[] wordFormMorphologies) { while (_MorphoAmbiguityTuples_Buffer.Count <= wordIdex) { _MorphoAmbiguityTuples_Buffer.Add(new List <MorphoAmbiguityTuple>(DEFAULT_WORDFORMMORPHOLOGY_COUNT)); } var punctuationType = MorphoAmbiguityTuple.GetPunctuationType(word); var buffer = _MorphoAmbiguityTuples_Buffer[wordIdex]; buffer.Clear(); for (int i = 0, len = wordFormMorphologies.Length; i < len; i++) { buffer.Add(new MorphoAmbiguityTuple(word, wordFormMorphologies[i], punctuationType)); } return(new WordMorphoAmbiguity(word, punctuationType, buffer)); }