public CognacyDecision Add(WordPair wordPair, bool cognacy) { var decision = new CognacyDecision(wordPair.VarietyPair.Variety1, wordPair.VarietyPair.Variety2, wordPair.Meaning, cognacy); Add(decision); return(decision); }
public WordPairViewModel(IWordAligner aligner, WordPair wordPair, bool areVarietiesInOrder) { _wordPair = wordPair; _areVarietiesInOrder = areVarietiesInOrder; _meaning = new MeaningViewModel(_wordPair.Word1.Meaning); _variety1 = new VarietyViewModel(_wordPair.VarietyPair.Variety1); _variety2 = new VarietyViewModel(_wordPair.VarietyPair.Variety2); IWordAlignerResult results = aligner.Compute(_wordPair); _alignment = results.GetAlignments().First(); _prefixNode = new AlignedNodeViewModel(_alignment.Prefixes[0], _alignment.Prefixes[1]); var nodes = new List<AlignedNodeViewModel>(); int i = 0; for (int column = 0; column < _alignment.ColumnCount; column++) { string note = null; if (i < _wordPair.AlignmentNotes.Count) note = _wordPair.AlignmentNotes[i]; nodes.Add(new AlignedNodeViewModel(column, _alignment[0, column], _alignment[1, column], note)); i++; } _suffixNode = new AlignedNodeViewModel(_alignment.Suffixes[0], _alignment.Suffixes[1]); _alignedNodes = new ReadOnlyCollection<AlignedNodeViewModel>(nodes); _showInMultipleWordAlignmentCommand = new RelayCommand(ShowInMultipleWordAlignment); }
public WordPairSurrogate(WordPair wp) { Meaning = wp.Meaning.Gloss; Word1 = wp.Word1.StrRep; Word2 = wp.Word2.StrRep; _alignmentNotes = wp.AlignmentNotes.ToList(); AreCognatePredicted = wp.AreCognatePredicted; PhoneticSimilarityScore = wp.PhoneticSimilarityScore; CognacyScore = wp.CognacyScore; }
public bool Remove(WordPair wordPair) { Dictionary <Meaning, CognacyDecision> decisions; UnorderedTuple <Variety, Variety> key = UnorderedTuple.Create(wordPair.VarietyPair.Variety1, wordPair.VarietyPair.Variety2); if (_lookupDictionary.TryGetValue(key, out decisions)) { CognacyDecision decision; if (decisions.TryGetValue(wordPair.Meaning, out decision)) { return(Remove(decision)); } } return(false); }
public bool Remove(WordPair wordPair) { Dictionary <Meaning, int> decisions; UnorderedTuple <Variety, Variety> key = UnorderedTuple.Create(wordPair.VarietyPair.Variety1, wordPair.VarietyPair.Variety2); if (_lookupDictionary.TryGetValue(key, out decisions)) { int index; if (decisions.TryGetValue(wordPair.Meaning, out index)) { decisions.Remove(wordPair.Meaning); if (decisions.Count == 0) { _lookupDictionary.Remove(key); } base.RemoveItem(index); return(true); } } return(false); }
public void UpdateActualCognacy(WordPair wordPair) { wordPair.ActualCognacy = GetCognacy(wordPair.VarietyPair, wordPair.Meaning); }
public WordPair ToWordPair(CogProject project, VarietyPair vp) { Meaning meaning = project.Meanings[Meaning]; Word word1 = vp.Variety1.Words[meaning].First(w => w.StrRep == Word1); Word word2 = vp.Variety2.Words[meaning].First(w => w.StrRep == Word2); var wp = new WordPair(word1, word2) { AreCognatePredicted = AreCognatePredicted, PhoneticSimilarityScore = PhoneticSimilarityScore, CognacyScore = CognacyScore }; wp.AlignmentNotes.AddRange(_alignmentNotes); return wp; }
public TestEnvironment(bool? actualCognacy, bool predictedCognacy) { DispatcherHelper.Initialize(); var segmentPool = new SegmentPool(); var spanFactory = new ShapeSpanFactory(); var projectService = Substitute.For<IProjectService>(); var analysisService = Substitute.For<IAnalysisService>(); _project = TestHelpers.GetTestProject(spanFactory, segmentPool); _project.Varieties.AddRange(new[] {new Variety("variety1"), new Variety("variety2")}); _project.Meanings.Add(new Meaning("meaning1", null)); var word1 = new Word("wɜrd", _project.Meanings[0]); _project.Varieties[0].Words.Add(word1); _project.Segmenter.Segment(word1); var word2 = new Word("kɑr", _project.Meanings[0]); _project.Varieties[1].Words.Add(word2); _project.Segmenter.Segment(word2); var vp = new VarietyPair(_project.Varieties[0], _project.Varieties[1]); if (actualCognacy != null) _project.CognacyDecisions.Add(new CognacyDecision(vp.Variety1, vp.Variety2, _project.Meanings[0], (bool) actualCognacy)); _project.VarietyPairs.Add(vp); var wp = new WordPair(word1, word2) {PredictedCognacy = predictedCognacy, ActualCognacy = actualCognacy}; _project.VarietyPairs[0].WordPairs.Add(wp); projectService.Project.Returns(_project); _wordPairViewModel = new WordPairViewModel(projectService, analysisService, wp, true); }