public void DisjunctiveAllomorphs() { var any = FeatureStruct.New().Symbol(HCFeatureSystem.Segment).Value; var edSuffix = new AffixProcessRule { Name = "ed_suffix", Gloss = "PAST", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value }; edSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") } }); Morphophonemic.MorphologicalRules.Add(edSuffix); var morpher = new Morpher(TraceManager, Language); AssertMorphsEqual(morpher.ParseWord("bazɯd"), "disj PAST"); Assert.That(morpher.ParseWord("batɯd"), Is.Empty); Assert.That(morpher.ParseWord("badɯd"), Is.Empty); Assert.That(morpher.ParseWord("basɯd"), Is.Empty); AssertMorphsEqual(morpher.ParseWord("bas"), "disj"); }
public void PartialEntry() { var any = FeatureStruct.New().Symbol(HCFeatureSystem.Segment).Value; var nominalizer = new AffixProcessRule { Name = "nominalizer", Gloss = "NOM", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value }; nominalizer.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") } }); Morphophonemic.MorphologicalRules.Add(nominalizer); var morpher = new Morpher(TraceManager, Language); AssertMorphsEqual(morpher.ParseWord("pi"), "54"); AssertMorphsEqual(morpher.ParseWord("piv"), "54 NOM"); Morphophonemic.MorphologicalRules.Clear(); var sSuffix = new AffixProcessRule { Name = "s_suffix", Gloss = "PAST", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, }; sSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") } }); var verbTemplate = new AffixTemplate { Name = "verb", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value }; verbTemplate.Slots.Add(new AffixTemplateSlot(sSuffix) { Optional = true }); Morphophonemic.AffixTemplates.Add(verbTemplate); morpher = new Morpher(TraceManager, Language); AssertMorphsEqual(morpher.ParseWord("pi"), "54"); AssertMorphsEqual(morpher.ParseWord("pis")); }
public void SameRuleUsedInMultipleTemplates() { var any = FeatureStruct.New().Symbol(HCFeatureSystem.Segment).Value; var edSuffix = new AffixProcessRule { Name = "ed_suffix", Gloss = "PAST", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem) .Symbol("V", "IV", "TV").Value, }; edSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "d") } }); var transitiveVerbTemplate = new AffixTemplate { Name = "Transitive Verb", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("TV").Value }; transitiveVerbTemplate.Slots.Add(new AffixTemplateSlot(edSuffix)); Morphophonemic.AffixTemplates.Add(transitiveVerbTemplate); var intransitiveVerbTemplate = new AffixTemplate { Name = "Intransitive Verb", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("IV").Value }; intransitiveVerbTemplate.Slots.Add(new AffixTemplateSlot(edSuffix)); Morphophonemic.AffixTemplates.Add(intransitiveVerbTemplate); var nominalizer = new AffixProcessRule { Name = "intransitive verbalizer", Gloss = "IVERB", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value, OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("IV").Value }; nominalizer.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") } }); Morphophonemic.MorphologicalRules.Add(nominalizer); var morpher = new Morpher(TraceManager, Language); AssertMorphsEqual(morpher.ParseWord("mivd"), "53 IVERB PAST"); }
public void FreeFluctuation() { var any = FeatureStruct.New().Symbol(HCFeatureSystem.Segment).Value; var d = FeatureStruct.New(Language.PhonologicalFeatureSystem) .Symbol(HCFeatureSystem.Segment) .Symbol("cons+") .Symbol("strident-") .Symbol("del_rel-") .Symbol("alveolar") .Symbol("nasal-") .Symbol("vd+").Value; var edSuffix = new AffixProcessRule { Name = "ed_suffix", Gloss = "PAST", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value }; edSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+t") } }); edSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+"), new InsertSimpleContext(d) } }); Morphophonemic.MorphologicalRules.Add(edSuffix); var morpher = new Morpher(TraceManager, Language); AssertMorphsEqual(morpher.ParseWord("tazd"), "free PAST"); AssertMorphsEqual(morpher.ParseWord("tast"), "free PAST"); AssertMorphsEqual(morpher.ParseWord("tazt"), "free PAST"); AssertMorphsEqual(morpher.ParseWord("tasd"), "free PAST"); }
public void StemNames() { var any = FeatureStruct.New().Symbol(HCFeatureSystem.Segment).Value; var edSuffix = new AffixProcessRule { Name = "ed_suffix", Gloss = "1", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem) .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("1")).Value }; edSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") } }); Morphophonemic.MorphologicalRules.Add(edSuffix); var tSuffix = new AffixProcessRule { Name = "t_suffix", Gloss = "2", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem) .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("2")).Value }; tSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+t") } }); Morphophonemic.MorphologicalRules.Add(tSuffix); var sSuffix = new AffixProcessRule { Name = "s_suffix", Gloss = "3", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem) .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("3")).Value }; sSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+s") } }); Morphophonemic.MorphologicalRules.Add(sSuffix); var morpher = new Morpher(TraceManager, Language); AssertMorphsEqual(morpher.ParseWord("sanɯd")); AssertMorphsEqual(morpher.ParseWord("sant")); AssertMorphsEqual(morpher.ParseWord("sans")); AssertMorphsEqual(morpher.ParseWord("san"), "stemname"); AssertMorphsEqual(morpher.ParseWord("sadɯd"), "stemname 1"); AssertMorphsEqual(morpher.ParseWord("sadt"), "stemname 2"); AssertMorphsEqual(morpher.ParseWord("sads")); AssertMorphsEqual(morpher.ParseWord("sad")); AssertMorphsEqual(morpher.ParseWord("sapɯd"), "stemname 1"); AssertMorphsEqual(morpher.ParseWord("sapt")); AssertMorphsEqual(morpher.ParseWord("saps"), "stemname 3"); AssertMorphsEqual(morpher.ParseWord("sap")); }
public void NonFinalTemplate() { var any = FeatureStruct.New().Symbol(HCFeatureSystem.Segment).Value; var alvStop = FeatureStruct.New(Language.PhonologicalFeatureSystem) .Symbol(HCFeatureSystem.Segment) .Symbol("cons+") .Symbol("strident-") .Symbol("del_rel-") .Symbol("alveolar").Value; var voicelessCons = FeatureStruct.New(Language.PhonologicalFeatureSystem) .Symbol(HCFeatureSystem.Segment) .Symbol("cons+") .Symbol("vd-").Value; var edSuffix = new AffixProcessRule { Name = "ed_suffix", Gloss = "PAST", }; edSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value, Pattern <Word, ShapeNode> .New("2").Annotation(alvStop).Value }, Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new InsertSegments(Table3, "ɯd") } }); edSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Annotation(voicelessCons).Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "t") } }); edSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "d") } }); var verbTemplate = new AffixTemplate { Name = "verb", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value }; verbTemplate.Slots.Add(new AffixTemplateSlot(edSuffix)); Morphophonemic.AffixTemplates.Add(verbTemplate); var nominalizer = new AffixProcessRule { Name = "nominalizer", Gloss = "NOM", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value }; nominalizer.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") } }); Morphophonemic.MorphologicalRules.Add(nominalizer); var crule = new CompoundingRule { Name = "rule1", HeadRequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem) .Symbol("V").Value, NonHeadRequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem) .Symbol("N").Value, OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value }; crule.Subrules.Add(new CompoundingSubrule { HeadLhs = { Pattern <Word, ShapeNode> .New("head").Annotation(any).OneOrMore.Value }, NonHeadLhs = { Pattern <Word, ShapeNode> .New("nonHead").Annotation(any).OneOrMore.Value }, Rhs = { new CopyFromInput("head"), new InsertSegments(Table3, "+"), new CopyFromInput("nonHead") } }); Morphophonemic.MorphologicalRules.Add(crule); var sSuffix = new AffixProcessRule { Name = "s_suffix", Gloss = "PL", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value, }; sSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") } }); var nounTemplate = new AffixTemplate { Name = "noun", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value }; nounTemplate.Slots.Add(new AffixTemplateSlot(sSuffix) { Optional = true }); Morphophonemic.AffixTemplates.Add(nounTemplate); var morpher = new Morpher(TraceManager, Language); AssertMorphsEqual(morpher.ParseWord("sagd"), "32 PAST"); AssertMorphsEqual(morpher.ParseWord("sagdv")); AssertMorphsEqual(morpher.ParseWord("sagdvs")); AssertMorphsEqual(morpher.ParseWord("sagdmi")); AssertMorphsEqual(morpher.ParseWord("sagdmis")); verbTemplate.IsFinal = false; morpher = new Morpher(TraceManager, Language); AssertMorphsEqual(morpher.ParseWord("sagd")); AssertMorphsEqual(morpher.ParseWord("sagdv"), "32 PAST NOM"); AssertMorphsEqual(morpher.ParseWord("sagdvs"), "32 PAST NOM PL"); AssertMorphsEqual(morpher.ParseWord("sagdmi"), "32 PAST 53"); AssertMorphsEqual(morpher.ParseWord("sagdmis"), "32 PAST 53 PL"); }
public void RealizationalRule() { var any = FeatureStruct.New().Symbol(HCFeatureSystem.Segment).Value; var alvStop = FeatureStruct.New(Language.PhonologicalFeatureSystem) .Symbol(HCFeatureSystem.Segment) .Symbol("cons+") .Symbol("strident-") .Symbol("del_rel-") .Symbol("alveolar").Value; var voicelessCons = FeatureStruct.New(Language.PhonologicalFeatureSystem) .Symbol(HCFeatureSystem.Segment) .Symbol("cons+") .Symbol("vd-").Value; var labiodental = FeatureStruct.New(Language.PhonologicalFeatureSystem) .Symbol(HCFeatureSystem.Segment) .Symbol("cons+") .Symbol("labiodental").Value; var voiced = FeatureStruct.New(Language.PhonologicalFeatureSystem) .Symbol(HCFeatureSystem.Segment) .Symbol("vd+").Value; var strident = FeatureStruct.New(Language.PhonologicalFeatureSystem) .Symbol(HCFeatureSystem.Segment) .Symbol("cons+") .Symbol("strident+").Value; var edSuffix = new RealizationalAffixProcessRule { Name = "ed_suffix", RealizationalFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem) .Feature(Head).EqualTo(head => head .Feature("tense").EqualTo("past")).Value, Gloss = "PAST" }; edSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value, Pattern <Word, ShapeNode> .New("2").Annotation(alvStop).Value }, Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new InsertSegments(Table3, "ɯd") } }); edSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Annotation(voicelessCons).Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "t") } }); edSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "d") } }); var sSuffix = new RealizationalAffixProcessRule { Name = "s_suffix", RealizationalFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem) .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("3") .Feature("tense").EqualTo("pres")).Value, Gloss = "3SG" }; sSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value, Pattern <Word, ShapeNode> .New("2").Annotation(labiodental).Value }, Rhs = { new CopyFromInput("1"), new ModifyFromInput("2", voiced), new InsertSegments(Table3, "z") } }); sSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Annotation(strident).Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "ɯz") } }); sSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value, Pattern <Word, ShapeNode> .New("2").Annotation(voicelessCons).Value }, Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new InsertSegments(Table3, "s") } }); sSuffix.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "z") } }); var evidential = new RealizationalAffixProcessRule { Name = "evidential", RealizationalFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem) .Feature(Head).EqualTo(head => head .Feature("evidential").EqualTo("witnessed")).Value, Gloss = "WIT" }; evidential.Allomorphs.Add(new AffixProcessAllomorph { Lhs = { Pattern <Word, ShapeNode> .New("1").Annotation(any).OneOrMore.Value }, Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") } }); var verbTemplate = new AffixTemplate { Name = "verb", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value }; verbTemplate.Slots.Add(new AffixTemplateSlot(sSuffix, edSuffix) { Optional = true }); verbTemplate.Slots.Add(new AffixTemplateSlot(evidential) { Optional = true }); Morphophonemic.AffixTemplates.Add(verbTemplate); var morpher = new Morpher(TraceManager, Language); Word[] output = morpher.ParseWord("sagd").ToArray(); AssertMorphsEqual(output, "32 PAST"); AssertSyntacticFeatureStructsEqual(output, FeatureStruct.New(Language.SyntacticFeatureSystem) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("tense").EqualTo("past")).Value); output = morpher.ParseWord("sagdv").ToArray(); AssertMorphsEqual(output, "32 PAST WIT"); AssertSyntacticFeatureStructsEqual(output, FeatureStruct.New(Language.SyntacticFeatureSystem) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("tense").EqualTo("past") .Feature("evidential").EqualTo("witnessed")).Value); Assert.That(morpher.ParseWord("sid"), Is.Empty); output = morpher.ParseWord("sau").ToArray(); AssertMorphsEqual(output, "bl2"); AssertSyntacticFeatureStructsEqual(output, FeatureStruct.New(Language.SyntacticFeatureSystem) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("tense").EqualTo("past")).Value); evidential.RealizationalFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem) .Feature(Head).EqualTo(head => head .Feature("evidential").EqualTo("witnessed") .Feature("tense").EqualTo("pres")).Value; morpher = new Morpher(TraceManager, Language); output = morpher.ParseWord("sagzv").ToArray(); AssertMorphsEqual(output, "32 3SG WIT"); AssertSyntacticFeatureStructsEqual(output, FeatureStruct.New(Language.SyntacticFeatureSystem) .Symbol("V") .Feature(Head).EqualTo(head => head .Feature("pers").EqualTo("3") .Feature("tense").EqualTo("pres") .Feature("evidential").EqualTo("witnessed")).Value); }