public TestEnvironment()
            {
                var sourceAnalyzer = Substitute.For <IMorphologicalAnalyzer>();

                sourceAnalyzer.AddAnalyses("caminé", new WordAnalysis(new[]
                {
                    new TestMorpheme("s1", "v", "walk", MorphemeType.Stem),
                    new TestMorpheme("s2", "v", "pst", MorphemeType.Affix)
                }, 0, "v"));
                var targetGenerator = Substitute.For <IMorphologicalGenerator>();
                var targetMorphemes = new ReadOnlyObservableList <IMorpheme>(new ObservableList <IMorpheme>
                {
                    new TestMorpheme("e1", "v", "walk", MorphemeType.Stem),
                    new TestMorpheme("e2", "v", "pst", MorphemeType.Affix)
                });

                targetGenerator.Morphemes.Returns(targetMorphemes);
                targetGenerator.AddGeneratedWords(
                    new WordAnalysis(new[] { targetMorphemes[0], targetMorphemes[1] }, 0, "v"), "walked");
                var transferer = new SimpleTransferer(new GlossMorphemeMapper(targetGenerator));
                ITranslationEngine transferEngine = new TransferEngine(sourceAnalyzer, transferer, targetGenerator);
                var smtEngine = Substitute.For <IInteractiveSmtEngine>();

                var alignment = new WordAlignmentMatrix(5, 5)
                {
Esempio n. 2
0
        public void Translate_CannotMapMorphemes_ReturnsEmptyTranslation()
        {
            var sourceAnalyzer = Substitute.For <IMorphologicalAnalyzer>();

            sourceAnalyzer.AddAnalyses("habló", new WordAnalysis(new[]
            {
                new TestMorpheme("s1", "v", "talk", MorphemeType.Stem),
                new TestMorpheme("s2", "v", "pst", MorphemeType.Affix)
            }, 0, "v"));
            var targetGenerator = Substitute.For <IMorphologicalGenerator>();
            var targetMorphemes = new ReadOnlyObservableList <IMorpheme>(new ObservableList <IMorpheme>());

            targetGenerator.Morphemes.Returns(targetMorphemes);
            var transferer = new SimpleTransferer(new GlossMorphemeMapper(targetGenerator));
            var engine     = new TransferEngine(sourceAnalyzer, transferer, targetGenerator);

            Assert.That(engine.TranslateWord("habló"), Is.Empty);
        }
Esempio n. 3
0
        public void Translate_CanTranslate_ReturnsCorrectTranslation()
        {
            var sourceAnalyzer = Substitute.For <IMorphologicalAnalyzer>();

            sourceAnalyzer.AddAnalyses("habló", new WordAnalysis(new[]
            {
                new TestMorpheme("s1", "v", "talk", MorphemeType.Stem),
                new TestMorpheme("s2", "v", "pst", MorphemeType.Affix)
            }, 0, "v"));
            var targetGenerator = Substitute.For <IMorphologicalGenerator>();
            var targetMorphemes = new ReadOnlyObservableList <IMorpheme>(new ObservableList <IMorpheme>
            {
                new TestMorpheme("e1", "v", "talk", MorphemeType.Stem),
                new TestMorpheme("e2", "v", "pst", MorphemeType.Affix)
            });

            targetGenerator.Morphemes.Returns(targetMorphemes);
            targetGenerator.AddGeneratedWords(new WordAnalysis(new[] { targetMorphemes[0], targetMorphemes[1] }, 0, "v"), "talked");
            var transferer = new SimpleTransferer(new GlossMorphemeMapper(targetGenerator));
            var engine     = new TransferEngine(sourceAnalyzer, transferer, targetGenerator);

            Assert.That(engine.TranslateWord("habló"), Is.EqualTo("talked".Split(' ')));
        }