コード例 #1
0
ファイル: AlineConfig.cs プロジェクト: rmunn/cog
        public override IWordAligner Load(SpanFactory<ShapeNode> spanFactory, SegmentPool segmentPool, CogProject project, XElement elem)
        {
            var settings = new AlineSettings();
            LoadSettings(project.Segmenter, project.FeatureSystem, elem, settings);
            XElement relevantFeaturesElem = elem.Element(ConfigManager.Cog + "RelevantFeatures");
            Debug.Assert(relevantFeaturesElem != null);

            var relevantVowelFeatures = new List<SymbolicFeature>();
            var relevantConsFeatures = new List<SymbolicFeature>();
            var featureWeights = new Dictionary<SymbolicFeature, int>();
            var valueMetrics = new Dictionary<FeatureSymbol, int>();

            foreach (XElement featureElem in relevantFeaturesElem.Elements(ConfigManager.Cog + "RelevantFeature"))
            {
                var feature = project.FeatureSystem.GetFeature<SymbolicFeature>((string) featureElem.Attribute("ref"));
                if ((bool?) featureElem.Attribute("vowel") ?? false)
                    relevantVowelFeatures.Add(feature);
                if ((bool?) featureElem.Attribute("consonant") ?? false)
                    relevantConsFeatures.Add(feature);
                featureWeights[feature] = (int) featureElem.Attribute("weight");
                foreach (XElement valueElem in featureElem.Elements(ConfigManager.Cog + "RelevantValue"))
                {
                    FeatureSymbol symbol = feature.PossibleSymbols[(string) valueElem.Attribute("ref")];
                    valueMetrics[symbol] = (int) valueElem.Attribute("metric");
                }
            }

            settings.SoundChangeScoringEnabled = (bool?) elem.Element(ConfigManager.Cog + "SoundChangeScoringEnabled") ?? true;
            settings.SyllablePositionCostEnabled = (bool?) elem.Element(ConfigManager.Cog + "SyllablePositionCostEnabled") ?? true;

            return new Aline(segmentPool, relevantVowelFeatures, relevantConsFeatures, featureWeights, valueMetrics, settings);
        }
コード例 #2
0
ファイル: Aline.cs プロジェクト: megahirt/cog
 public Aline(SegmentPool segmentPool, IEnumerable <SymbolicFeature> relevantVowelFeatures, IEnumerable <SymbolicFeature> relevantConsFeatures,
              IDictionary <SymbolicFeature, int> featureWeights, IDictionary <FeatureSymbol, int> valueMetrics, AlineSettings settings)
     : base(settings)
 {
     _settings = settings;
     _scorer   = new AlineScorer(segmentPool, relevantVowelFeatures, relevantConsFeatures, featureWeights, valueMetrics,
                                 settings.ContextualSoundClasses, settings.SoundChangeScoringEnabled, settings.SyllablePositionCostEnabled);
 }
コード例 #3
0
ファイル: Aline.cs プロジェクト: rmunn/cog
        public Aline(SegmentPool segmentPool, IEnumerable<SymbolicFeature> relevantVowelFeatures, IEnumerable<SymbolicFeature> relevantConsFeatures,
			IDictionary<SymbolicFeature, int> featureWeights, IDictionary<FeatureSymbol, int> valueMetrics, AlineSettings settings)
            : base(settings)
        {
            _settings = settings;
            _scorer = new AlineScorer(segmentPool, relevantVowelFeatures, relevantConsFeatures, featureWeights, valueMetrics,
                settings.ContextualSoundClasses, settings.SoundChangeScoringEnabled, settings.SyllablePositionCostEnabled);
        }