상속: SIL.Cog.Domain.Components.WordAlignerBase
예제 #1
0
        public void AlineFeatures()
        {
            var manner = _featSys.GetFeature<SymbolicFeature>("manner");
            var aline = new Aline(_segmentPool, Enumerable.Empty<SymbolicFeature>(), manner.ToEnumerable(),
                new Dictionary<SymbolicFeature, int> {{manner, 50}},
                new Dictionary<FeatureSymbol, int>
                    {
                        {manner.PossibleSymbols["stop"], 100},
                        {manner.PossibleSymbols["affricate"], 95},
                        {manner.PossibleSymbols["fricative"], 90},
                        {manner.PossibleSymbols["approximant"], 80}
                    });

            _project.WordAligners["primary"] = aline;
            var pm = new ProjectMigration2();
            pm.Migrate(_segmentPool, _project);

            aline = (Aline) _project.WordAligners["primary"];
            Assert.That(aline.RelevantConsonantFeatures.Select(f => f.ID), Is.EquivalentTo(new[] {"manner", "airstream"}));
            Assert.That(aline.FeatureWeights.Select(kvp => Tuple.Create(kvp.Key.ID, kvp.Value)), Is.EquivalentTo(new[] {Tuple.Create("manner", 50), Tuple.Create("airstream", 5)}));
            Assert.That(aline.ValueMetrics.Select(kvp => Tuple.Create(kvp.Key.ID, kvp.Value)), Is.EquivalentTo(new[]
                {
                    Tuple.Create("stop", 100),
                    Tuple.Create("affricate", 95),
                    Tuple.Create("fricative", 90),
                    Tuple.Create("approximant", 80),
                    Tuple.Create("pulmonic", 100),
                    Tuple.Create("ejective", 66),
                    Tuple.Create("implosive", 33),
                    Tuple.Create("click", 0)
                }));
        }
예제 #2
0
파일: AlineViewModel.cs 프로젝트: rmunn/cog
        public override object UpdateComponent()
        {
            var mode = AlignmentMode.Local;
            switch (_mode)
            {
                case AlineMode.Local:
                    mode = AlignmentMode.Local;
                    break;
                case AlineMode.Global:
                    mode = AlignmentMode.Global;
                    break;
                case AlineMode.SemiGlobal:
                    mode = AlignmentMode.SemiGlobal;
                    break;
                case AlineMode.HalfLocal:
                    mode = AlignmentMode.HalfLocal;
                    break;
            }

            var relevantVowelFeatures = new List<SymbolicFeature>();
            var relevantConsFeatures = new List<SymbolicFeature>();
            var featureWeights = new Dictionary<SymbolicFeature, int>();
            var valueMetrics = new Dictionary<FeatureSymbol, int>();
            foreach (RelevantFeatureViewModel feature in _features)
            {
                if (feature.Vowel)
                    relevantVowelFeatures.Add(feature.DomainFeature);
                if (feature.Consonant)
                    relevantConsFeatures.Add(feature.DomainFeature);
                featureWeights[feature.DomainFeature] = feature.Weight;
                foreach (RelevantValueViewModel value in feature.Values)
                    valueMetrics[value.DomainSymbol] = value.Metric;
            }

            var aligner = new Aline(_segmentPool, relevantVowelFeatures, relevantConsFeatures, featureWeights, valueMetrics,
                new AlineSettings
                {
                    ExpansionCompressionEnabled = _expansionCompressionEnabled,
                    Mode = mode,
                    ContextualSoundClasses = _soundClasses.SoundClasses.Select(nc => nc.DomainSoundClass),
                    SoundChangeScoringEnabled = _soundChangeScoringEnabled,
                    SyllablePositionCostEnabled = _syllablePositionCostEnabled
                });
            _projectService.Project.WordAligners[ComponentIdentifiers.PrimaryWordAligner] = aligner;
            return aligner;
        }