当前位置: 首页>>代码示例>>C#>>正文


C# TestEnvironment.SetupWordPairsViews方法代码示例

本文整理汇总了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"}));
            }
        }
开发者ID:rmunn,项目名称:cog,代码行数:49,代码来源:VarietyPairsViewModelTests.cs

示例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()));
            }
        }
开发者ID:rmunn,项目名称:cog,代码行数:32,代码来源:VarietyPairsViewModelTests.cs


注:本文中的TestEnvironment.SetupWordPairsViews方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。