public void SimpleRuleNotUnapplied()
        {
            var any = FeatureStruct.New().Symbol(HCFeatureSystem.Segment).Value;

            var prule = new MetathesisRule
                            {
                                Name = "rule1",
                                Pattern = Pattern<Word, ShapeNode>.New()
                                    .Group("1", group => group.Annotation(Char(Table3, "i")))
                                    .Group("2", group => group.Annotation(Char(Table3, "u"))).Value,
                                LeftSwitchName = "2",
                                RightSwitchName = "1"
                            };
            Morphophonemic.PhonologicalRules.Add(prule);

            var iSuffix = new AffixProcessRule
                          	{
                                Name = "i_suffix",
                          		Gloss = "3SG"
                          	};
            Morphophonemic.MorphologicalRules.Add(iSuffix);
            iSuffix.Allomorphs.Add(new AffixProcessAllomorph
                                    {
                                        Lhs = {Pattern<Word, ShapeNode>.New("1").Annotation(any).OneOrMore.Value},
                                        Rhs = {new CopyFromInput("1"), new InsertSegments(Table3, "i")}
                                    });

            var morpher = new Morpher(SpanFactory, TraceManager, Language);
            AssertMorphsEqual(morpher.ParseWord("pui"), "52 3SG");
        }
        public void ComplexRule()
        {
            var any = FeatureStruct.New().Symbol(HCFeatureSystem.Segment).Value;

            var rule1 = new MetathesisRule
                            {
                                Name = "rule1",
                                Pattern = Pattern<Word, ShapeNode>.New()
                                    .Group("1", group => group.Annotation(Char(Table3, "i")))
                                    .Group("middle", group => group.Annotation(Char(Table3, "+")))
                                    .Group("2", group => group.Annotation(Char(Table3, "u")))
                                    .Group("rightEnv", group => group.Annotation(HCFeatureSystem.RightSideAnchor)).Value,
                                LeftSwitchName = "2",
                                RightSwitchName = "1"
                            };
            Morphophonemic.PhonologicalRules.Add(rule1);

            var uSuffix = new AffixProcessRule
                          	{
                                Name = "u_suffix",
                          		Gloss = "3SG"
                          	};
            Morphophonemic.MorphologicalRules.Add(uSuffix);
            uSuffix.Allomorphs.Add(new AffixProcessAllomorph
                                    {
                                        Lhs = {Pattern<Word, ShapeNode>.New("1").Annotation(any).OneOrMore.Value},
                                        Rhs = {new CopyFromInput("1"), new InsertSegments(Table3, "+u")}
                                    });

            var morpher = new Morpher(SpanFactory, TraceManager, Language);
            AssertMorphsEqual(morpher.ParseWord("mui"), "53 3SG");
        }
        public void SimpleRule()
        {
            var rule1 = new MetathesisRule
                            {
                                Name = "rule1",
                                Pattern = Pattern<Word, ShapeNode>.New()
                                    .Group("1", group => group.Annotation(Char(Table3, "i")))
                                    .Group("2", group => group.Annotation(Char(Table3, "u"))).Value,
                                LeftSwitchName = "2",
                                RightSwitchName = "1"
                            };
            Morphophonemic.PhonologicalRules.Add(rule1);

            var morpher = new Morpher(SpanFactory, TraceManager, Language);
            AssertMorphsEqual(morpher.ParseWord("mui"), "51");
        }
Exemple #4
0
        public SynthesisMetathesisRule(SpanFactory <ShapeNode> spanFactory, Morpher morpher, MetathesisRule rule)
        {
            _morpher = morpher;
            _rule    = rule;

            var ruleSpec = new SynthesisMetathesisRuleSpec(spanFactory, rule.Pattern, rule.LeftSwitchName, rule.RightSwitchName);

            var settings = new MatcherSettings <ShapeNode>
            {
                Direction   = rule.Direction,
                Filter      = ann => ann.Type().IsOneOf(HCFeatureSystem.Segment, HCFeatureSystem.Boundary, HCFeatureSystem.Anchor) && !ann.IsDeleted(),
                UseDefaults = true
            };

            _patternRule = new IterativePhonologicalPatternRule(spanFactory, ruleSpec, settings);
        }
        public AnalysisMetathesisRule(SpanFactory <ShapeNode> spanFactory, Morpher morpher, MetathesisRule rule)
        {
            _morpher = morpher;
            _rule    = rule;

            var ruleSpec = new AnalysisMetathesisRuleSpec(rule.Pattern, rule.LeftSwitchName, rule.RightSwitchName);

            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
            };

            _patternRule = new IterativePhonologicalPatternRule(spanFactory, ruleSpec, settings);
        }