Exemple #1
0
 protected PhonologicalPatternRule(SpanFactory <ShapeNode> spanFactory, IPhonologicalPatternRuleSpec ruleSpec, MatcherSettings <ShapeNode> matcherSettings)
 {
     _spanFactory = spanFactory;
     _ruleSpec    = ruleSpec;
     _matcher     = new Matcher <Word, ShapeNode>(spanFactory, _ruleSpec.Pattern, matcherSettings);
 }
        public AnalysisRewriteRule(Morpher morpher, RewriteRule rule)
        {
            _morpher = morpher;
            _rule    = rule;

            var settings = new MatcherSettings <ShapeNode>
            {
                Direction      = rule.Direction == Direction.LeftToRight ? Direction.RightToLeft : Direction.LeftToRight,
                Filter         = ann => ann.Type().IsOneOf(HCFeatureSystem.Segment, HCFeatureSystem.Anchor),
                MatchingMethod = MatchingMethod.Unification,
                UseDefaults    = true,
                // during analysis shape nodes can have features that are underspecified, so this must be non-deterministic
                Nondeterministic = true
            };

            _rules = new List <Tuple <ReapplyType, PhonologicalPatternRule> >();
            foreach (RewriteSubrule sr in _rule.Subrules)
            {
                IPhonologicalPatternRuleSpec ruleSpec = null;
                var mode        = RewriteApplicationMode.Iterative;
                var reapplyType = ReapplyType.Normal;
                if (_rule.Lhs.Children.Count == sr.Rhs.Children.Count)
                {
                    ruleSpec = new FeatureAnalysisRewriteRuleSpec(settings, rule.Lhs, sr);
                    if (_rule.ApplicationMode == RewriteApplicationMode.Simultaneous)
                    {
                        foreach (Constraint <Word, ShapeNode> constraint in sr.Rhs.Children
                                 .Cast <Constraint <Word, ShapeNode> >())
                        {
                            if (constraint.Type() == HCFeatureSystem.Segment)
                            {
                                if (!IsUnifiable(constraint, sr.LeftEnvironment) ||
                                    !IsUnifiable(constraint, sr.RightEnvironment))
                                {
                                    reapplyType = ReapplyType.SelfOpaquing;
                                    break;
                                }
                            }
                        }
                    }
                }
                else if (_rule.Lhs.Children.Count > sr.Rhs.Children.Count)
                {
                    ruleSpec    = new NarrowAnalysisRewriteRuleSpec(settings, _rule.Lhs, sr);
                    mode        = RewriteApplicationMode.Simultaneous;
                    reapplyType = ReapplyType.Deletion;
                }
                else if (_rule.Lhs.Children.Count == 0)
                {
                    ruleSpec = new EpenthesisAnalysisRewriteRuleSpec(settings, sr);
                    if (_rule.ApplicationMode == RewriteApplicationMode.Simultaneous)
                    {
                        reapplyType = ReapplyType.SelfOpaquing;
                    }
                }
                Debug.Assert(ruleSpec != null);

                PhonologicalPatternRule patternRule = null;
                switch (mode)
                {
                case RewriteApplicationMode.Iterative:
                    patternRule = new IterativePhonologicalPatternRule(ruleSpec, settings);
                    break;

                case RewriteApplicationMode.Simultaneous:
                    patternRule = new SimultaneousPhonologicalPatternRule(ruleSpec, settings);
                    break;
                }

                _rules.Add(Tuple.Create(reapplyType, patternRule));
            }
        }
 public IterativePhonologicalPatternRule(IPhonologicalPatternRuleSpec ruleSpec,
                                         MatcherSettings <ShapeNode> matcherSettings)
     : base(ruleSpec, matcherSettings)
 {
 }
 protected PhonologicalPatternRule(IPhonologicalPatternRuleSpec ruleSpec,
                                   MatcherSettings <ShapeNode> matcherSettings)
 {
     _ruleSpec = ruleSpec;
     _matcher  = new Matcher <Word, ShapeNode>(_ruleSpec.Pattern, matcherSettings);
 }
 public SimultaneousPhonologicalPatternRule(IPhonologicalPatternRuleSpec ruleSpec,
                                            MatcherSettings <ShapeNode> matcherSettings)
     : base(ruleSpec, matcherSettings)
 {
     _ruleSpec = ruleSpec;
 }
Exemple #6
0
 public SimultaneousPhonologicalPatternRule(SpanFactory <ShapeNode> spanFactory, IPhonologicalPatternRuleSpec ruleSpec, MatcherSettings <ShapeNode> matcherSettings)
     : base(spanFactory, ruleSpec, matcherSettings)
 {
     _ruleSpec = ruleSpec;
 }
 public IterativePhonologicalPatternRule(SpanFactory<ShapeNode> spanFactory, IPhonologicalPatternRuleSpec ruleSpec, MatcherSettings<ShapeNode> matcherSettings)
     : base(spanFactory, ruleSpec, matcherSettings)
 {
 }
 public SimultaneousPhonologicalPatternRule(SpanFactory<ShapeNode> spanFactory, IPhonologicalPatternRuleSpec ruleSpec, MatcherSettings<ShapeNode> matcherSettings)
     : base(spanFactory, ruleSpec, matcherSettings)
 {
     _ruleSpec = ruleSpec;
 }
Exemple #9
0
 public IterativePhonologicalPatternRule(SpanFactory <ShapeNode> spanFactory, IPhonologicalPatternRuleSpec ruleSpec, MatcherSettings <ShapeNode> matcherSettings)
     : base(spanFactory, ruleSpec, matcherSettings)
 {
 }