public void UpdateCognicity(WordPair wordPair, IWordAlignerResult alignerResult) { wordPair.AlignmentNotes.Clear(); Alignment <Word, ShapeNode> alignment = alignerResult.GetAlignments().First(); int initialEquivalentClasses = 0; bool mismatchFound = false; for (int column = 0; column < alignment.ColumnCount; column++) { AlignmentCell <ShapeNode> cell1 = alignment[0, column]; AlignmentCell <ShapeNode> cell2 = alignment[1, column]; if ((cell1.Count > 0 && cell1[0].Type() == CogFeatureSystem.VowelType) || (cell2.Count > 0 && cell2[0].Type() == CogFeatureSystem.VowelType)) { wordPair.AlignmentNotes.Add("X"); } else { if (cell1.StrRep() == cell2.StrRep()) { wordPair.AlignmentNotes.Add("1"); if (!mismatchFound) { initialEquivalentClasses++; } } else { SoundClass sc1; if (!_soundClasses.TryGetMatchingSoundClass(_segmentPool, alignment, 0, column, out sc1)) { sc1 = null; } SoundClass sc2; if (!_soundClasses.TryGetMatchingSoundClass(_segmentPool, alignment, 1, column, out sc2)) { sc2 = null; } if (sc1 != null && sc2 != null && sc1 == sc2) { wordPair.AlignmentNotes.Add("1"); if (!mismatchFound) { initialEquivalentClasses++; } } else { wordPair.AlignmentNotes.Add("0"); mismatchFound = true; } } } } wordPair.AreCognatePredicted = !mismatchFound || initialEquivalentClasses >= _initialEquivalenceThreshold; wordPair.CognicityScore = (double)initialEquivalentClasses / alignment.ColumnCount; }
public MultipleWordAlignmentWordViewModel(Word word, AlignmentCell <ShapeNode> prefix, IEnumerable <AlignmentCell <ShapeNode> > columns, AlignmentCell <ShapeNode> suffix, int cognateSetIndex) { _word = word; _variety = new VarietyViewModel(word.Variety); _prefix = prefix.StrRep(); _columns = new ReadOnlyList <string>(columns.Select(cell => cell.IsNull ? "-" : cell.StrRep()).ToArray()); _suffix = suffix.StrRep(); _cognateSetIndex = cognateSetIndex; }
public MultipleWordAlignmentWordViewModel(MultipleWordAlignmentViewModel parent, Word word, AlignmentCell<ShapeNode> prefix, IEnumerable<AlignmentCell<ShapeNode>> columns, AlignmentCell<ShapeNode> suffix, int cognateSetIndex) { _word = word; ReadOnlyCollection<Word> words = word.Variety.Words[word.Meaning]; _variety = new MultipleWordAlignmentVarietyViewModel(word.Variety, words.Count == 1 ? 0 : IndexOf(words, word)); _prefix = prefix.StrRep(); _columns = new ReadOnlyList<string>(columns.Select(cell => cell.IsNull ? "-" : cell.StrRep()).ToArray()); _suffix = suffix.StrRep(); _cognateSetIndex = cognateSetIndex; _parent = parent; }
public MultipleWordAlignmentWordViewModel(MultipleWordAlignmentViewModel parent, Word word, AlignmentCell <ShapeNode> prefix, IEnumerable <AlignmentCell <ShapeNode> > columns, AlignmentCell <ShapeNode> suffix, int cognateSetIndex) { _word = word; ReadOnlyCollection <Word> words = word.Variety.Words[word.Meaning]; _variety = new MultipleWordAlignmentVarietyViewModel(word.Variety, words.Count == 1 ? 0 : IndexOf(words, word)); _prefix = prefix.StrRep(); _columns = new ReadOnlyList <string>(columns.Select(cell => cell.IsNull ? "-" : cell.StrRep()).ToArray()); _suffix = suffix.StrRep(); _cognateSetIndex = cognateSetIndex; _parent = parent; }