本文整理汇总了C#中TestEnvironment.SetupWordPairsViews方法的典型用法代码示例。如果您正苦于以下问题:C# TestEnvironment.SetupWordPairsViews方法的具体用法?C# TestEnvironment.SetupWordPairsViews怎么用?C# TestEnvironment.SetupWordPairsViews使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestEnvironment
的用法示例。
在下文中一共展示了TestEnvironment.SetupWordPairsViews方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TaskAreas_ChangeSorting_WordPairOrderingUpdated
public void TaskAreas_ChangeSorting_WordPairOrderingUpdated()
{
using (var env = new TestEnvironment())
{
env.Project.Meanings.AddRange(new[] {new Meaning("gloss1", "cat1"), new Meaning("gloss2", "cat2"), new Meaning("gloss3", "cat3"), new Meaning("gloss4", "cat4")});
env.Project.Varieties.AddRange(new[] {new Variety("variety1"), new Variety("variety2"), new Variety("variety3")});
env.Project.Varieties[0].Words.AddRange(new[] {new Word("hɛ.loʊ", env.Project.Meanings[0]), new Word("gʊd", env.Project.Meanings[1]), new Word("bæd", env.Project.Meanings[2]), new Word("wɜrd", env.Project.Meanings[3])});
env.Project.Varieties[1].Words.AddRange(new[] {new Word("hɛlp", env.Project.Meanings[0]), new Word("gu.gəl", env.Project.Meanings[1]), new Word("gu.fi", env.Project.Meanings[2]), new Word("kɑr", env.Project.Meanings[3])});
env.AnalysisService.SegmentAll();
var varietyPairGenerator = new VarietyPairGenerator();
varietyPairGenerator.Process(env.Project);
var wordPairGenerator = new SimpleWordPairGenerator(env.SegmentPool, env.Project, 0.3, ComponentIdentifiers.PrimaryWordAligner);
foreach (VarietyPair vp in env.Project.VarietyPairs)
{
wordPairGenerator.Process(vp);
vp.SoundChangeFrequencyDistribution = new ConditionalFrequencyDistribution<SoundContext, Ngram<Segment>>();
vp.SoundChangeProbabilityDistribution = new ConditionalProbabilityDistribution<SoundContext, Ngram<Segment>>(vp.SoundChangeFrequencyDistribution, (sc, fd) => new MaxLikelihoodProbabilityDistribution<Ngram<Segment>>(fd));
}
int i = 0;
foreach (WordPair wp in env.Project.VarietyPairs[0].WordPairs)
{
wp.PhoneticSimilarityScore = (1.0 / env.Project.VarietyPairs[0].WordPairs.Count) * (i + 1);
wp.AreCognatePredicted = wp.Meaning.Gloss.IsOneOf("gloss1", "gloss3");
i++;
}
env.OpenProject();
env.SetupWordPairsViews();
WordPairViewModel[] cognatesArray = env.Cognates.WordPairsView.Cast<WordPairViewModel>().ToArray();
WordPairViewModel[] noncognatesArray = env.Noncognates.WordPairsView.Cast<WordPairViewModel>().ToArray();
Assert.That(cognatesArray.Select(wp => wp.Meaning.Gloss), Is.EqualTo(new[] {"gloss3", "gloss1"}));
Assert.That(noncognatesArray.Select(wp => wp.Meaning.Gloss), Is.EqualTo(new[] {"gloss4", "gloss2"}));
var commonTasks = (TaskAreaItemsViewModel) env.VarietyPairs.TaskAreas[0];
var sortWordsByItems = (TaskAreaItemsViewModel) commonTasks.Items[2];
var sortWordsByGroup = (TaskAreaCommandGroupViewModel) sortWordsByItems.Items[0];
// default sorting is by similarity, change to gloss
sortWordsByGroup.SelectedCommand = sortWordsByGroup.Commands[1];
sortWordsByGroup.SelectedCommand.Command.Execute(null);
cognatesArray = env.Cognates.WordPairsView.Cast<WordPairViewModel>().ToArray();
noncognatesArray = env.Noncognates.WordPairsView.Cast<WordPairViewModel>().ToArray();
Assert.That(cognatesArray.Select(wp => wp.Meaning.Gloss), Is.EqualTo(new[] {"gloss1", "gloss3"}));
Assert.That(noncognatesArray.Select(wp => wp.Meaning.Gloss), Is.EqualTo(new[] {"gloss2", "gloss4"}));
}
}
示例2: FindCommand_SwitchVarietyPairChangeSelectedWordMatches_CorrectWordPairsSelected
public void FindCommand_SwitchVarietyPairChangeSelectedWordMatches_CorrectWordPairsSelected()
{
using (var env = new TestEnvironment())
{
SetupFindCommandTests(env);
env.VarietyPairs.SelectedVariety2 = env.VarietyPairs.Varieties[2];
env.SetupWordPairsViews();
WordPairViewModel[] noncognatesArray = env.Noncognates.WordPairsView.Cast<WordPairViewModel>().ToArray();
env.FindViewModel.Field = FindField.Form;
env.FindViewModel.String = "l";
env.FindViewModel.FindNextCommand.Execute(null);
Assert.That(env.Cognates.SelectedWordPairs, Is.Empty);
Assert.That(env.Noncognates.SelectedWordPairs, Is.EquivalentTo(noncognatesArray[0].ToEnumerable()));
env.FindViewModel.FindNextCommand.Execute(null);
Assert.That(env.Cognates.SelectedWordPairs, Is.Empty);
Assert.That(env.Noncognates.SelectedWordPairs, Is.EquivalentTo(noncognatesArray[2].ToEnumerable()));
env.Noncognates.SelectedWordPairs.Clear();
env.Noncognates.SelectedWordPairs.Add(noncognatesArray[1]);
env.FindViewModel.FindNextCommand.Execute(null);
Assert.That(env.Cognates.SelectedWordPairs, Is.Empty);
Assert.That(env.Noncognates.SelectedWordPairs, Is.EquivalentTo(noncognatesArray[2].ToEnumerable()));
env.FindViewModel.FindNextCommand.Execute(null);
Assert.That(env.Cognates.SelectedWordPairs, Is.Empty);
Assert.That(env.Noncognates.SelectedWordPairs, Is.EquivalentTo(noncognatesArray[0].ToEnumerable()));
env.FindViewModel.FindNextCommand.Execute(null);
Assert.That(env.Cognates.SelectedWordPairs, Is.Empty);
Assert.That(env.Noncognates.SelectedWordPairs, Is.EquivalentTo(noncognatesArray[0].ToEnumerable()));
}
}