public List <Form> getComparPast() //comparative past/conditional, eg. "ní ba mhó" { List <Form> ret = new List <Form>(); foreach (Form gradedForm in graded) { string form = ""; if (Regex.IsMatch(gradedForm.value, "^[aeiouáéíóúAEIOUÁÉÍÓÚ]")) { form = "ní b'" + gradedForm.value; } else if (Regex.IsMatch(gradedForm.value, "^f[aeiouáéíóúAEIOUÁÉÍÓÚ]")) { form = "ní b'" + Opers.Mutate(Mutation.Len1, gradedForm.value); } else { form = "ní ba " + Opers.Mutate(Mutation.Len1, gradedForm.value); } ret.Add(new Form(form)); } return(ret); }
public string printAdjectiveXml(Adjective a) { string ret = ""; string nl = Environment.NewLine; if (this.withXmlDeclarations) { ret += "<?xml version='1.0' encoding='utf-8'?>" + nl; } if (this.withXmlDeclarations) { ret += "<?xml-stylesheet type='text/xsl' href='!gram.xsl'?>" + nl; } ret += "<Lemma lemma='" + clean4xml(a.getLemma()) + "' uid='" + clean4xml(a.getNickname()) + "'>" + nl; ret += "<adjective declension='" + a.declension + "'>" + nl; foreach (Form f in a.sgNom) { ret += "\t<sgNomMasc>" + clean4xml(f.value) + "</sgNomMasc>" + nl; } foreach (Form f in a.sgNom) { ret += "\t<sgNomFem>" + clean4xml(Opers.Mutate(Mutation.Len1, f.value)) + "</sgNomFem>" + nl; } foreach (Form f in a.sgGenMasc) { ret += "\t<sgGenMasc>" + clean4xml(Opers.Mutate(Mutation.Len1, f.value)) + "</sgGenMasc>" + nl; } foreach (Form f in a.sgGenFem) { ret += "\t<sgGenFem>" + clean4xml(f.value) + "</sgGenFem>" + nl; } foreach (Form f in a.plNom) { ret += "\t<plNom>" + clean4xml(f.value) + "</plNom>" + nl; } foreach (Form f in a.plNom) { ret += "\t<plNomSlen>" + clean4xml(Opers.Mutate(Mutation.Len1, f.value)) + "</plNomSlen>" + nl; } foreach (Form f in a.plNom) { ret += "\t<plGenStrong>" + clean4xml(f.value) + "</plGenStrong>" + nl; } foreach (Form f in a.sgNom) { ret += "\t<plGenWeak>" + clean4xml(f.value) + "</plGenWeak>" + nl; } foreach (Form f in a.getComparPres()) { ret += "\t<comparPres>" + clean4xml(f.value) + "</comparPres>" + nl; } foreach (Form f in a.getComparPast()) { ret += "\t<comparPast>" + clean4xml(f.value) + "</comparPast>" + nl; } foreach (Form f in a.getSuperPres()) { ret += "\t<superPres>" + clean4xml(f.value) + "</superPres>" + nl; } foreach (Form f in a.getSuperPast()) { ret += "\t<superPast>" + clean4xml(f.value) + "</superPast>" + nl; } foreach (Form f in a.abstractNoun) { ret += "\t<abstractNoun>" + clean4xml(f.value) + "</abstractNoun>" + nl; } foreach (Form f in a.abstractNoun) { ret += "\t<abstractNounExamples>" + nl; ret += "\t\t<example>" + clean4xml("dá " + Opers.Mutate(Mutation.Len1, f.value)) + "</example>" + nl; if (Regex.IsMatch(f.value, "^[" + Opers.Vowels + "]")) { ret += "\t\t<example>" + clean4xml("ag dul in " + Opers.Mutate(Mutation.None, f.value)) + "</example>" + nl; } else { ret += "\t\t<example>" + clean4xml("ag dul i " + Opers.Mutate(Mutation.Ecl1, f.value)) + "</example>" + nl; } ret += "\t</abstractNounExamples>" + nl; } ret += "</adjective>" + nl; ret += "</Lemma>"; return(ret); }
//Constructs a verbal phrase from a verb: public VP(Verb v) { #region prepare-structure VPTense[] ts = new VPTense[] { VPTense.Past, VPTense.PastCont, VPTense.Pres, VPTense.PresCont, VPTense.Fut, VPTense.Cond }; VPMood[] ms = new VPMood[] { VPMood.Imper, VPMood.Subj }; VPShape[] ss = new VPShape[] { VPShape.Declar, VPShape.Interrog /*, VPShape.RelDep, VPShape.RelIndep, VPShape.Report*/ }; VPPerson[] pers = new VPPerson[] { VPPerson.Sg1, VPPerson.Sg2, VPPerson.Sg3Masc, VPPerson.Sg3Fem, VPPerson.Pl1, VPPerson.Pl2, VPPerson.Pl3, VPPerson.NoSubject, VPPerson.Auto }; VPPolarity[] pols = new VPPolarity[] { VPPolarity.Pos, VPPolarity.Neg }; foreach (VPTense t in ts) { this.tenses.Add(t, new Dictionary <VPShape, Dictionary <VPPerson, Dictionary <VPPolarity, List <Form> > > >()); foreach (VPShape s in ss) { this.tenses[t].Add(s, new Dictionary <VPPerson, Dictionary <VPPolarity, List <Form> > >()); foreach (VPPerson per in pers) { this.tenses[t][s].Add(per, new Dictionary <VPPolarity, List <Form> >()); foreach (VPPolarity pol in pols) { this.tenses[t][s][per].Add(pol, new List <Form>()); } } } } foreach (VPMood m in ms) { this.moods.Add(m, new Dictionary <VPPerson, Dictionary <VPPolarity, List <Form> > >()); foreach (VPPerson per in pers) { this.moods[m].Add(per, new Dictionary <VPPolarity, List <Form> >()); foreach (VPPolarity pol in pols) { this.moods[m][per].Add(pol, new List <Form>()); } } } #endregion //Apply rules to build tensed forms: foreach (VPTense t in v.tenseRules.Keys) { foreach (VPPerson p in v.tenseRules[t].Keys) { foreach (VPShape s in v.tenseRules[t][p].Keys) { foreach (VPPolarity l in v.tenseRules[t][p][s].Keys) { foreach (VerbTenseRule rule in v.tenseRules[t][p][s][l]) { //For each verb form, use the rule to build a verbal phrase form: foreach (Form vForm in v.tenses[rule.verbTense][rule.verbDependency][rule.verbPerson]) { Form vpForm = new Form(""); if (rule.particle != "") { vpForm.value += rule.particle + " "; } vpForm.value += Opers.Mutate(rule.mutation, vForm.value); if (rule.pronoun != "") { vpForm.value += " " + rule.pronoun; } if (v.getLemma() == "bí" && t == VPTense.Pres && s == VPShape.Declar && l == VPPolarity.Neg && vpForm.value.StartsWith("ní fhuil")) { vpForm.value = "níl" + vpForm.value.Substring(8); //ní fhuil --> níl } this.tenses[t][s][p][l].Add(vpForm); } } } } } } #region mappings Dictionary <VPPerson, VerbPerson> mapPerson = new Dictionary <VPPerson, VerbPerson>(); mapPerson.Add(VPPerson.Sg1, VerbPerson.Sg1); mapPerson.Add(VPPerson.Sg2, VerbPerson.Sg2); mapPerson.Add(VPPerson.Sg3Masc, VerbPerson.Sg3); mapPerson.Add(VPPerson.Sg3Fem, VerbPerson.Sg3); mapPerson.Add(VPPerson.Pl1, VerbPerson.Pl1); mapPerson.Add(VPPerson.Pl2, VerbPerson.Pl2); mapPerson.Add(VPPerson.Pl3, VerbPerson.Pl3); mapPerson.Add(VPPerson.NoSubject, VerbPerson.Base); mapPerson.Add(VPPerson.Auto, VerbPerson.Auto); Dictionary <VPPerson, string> mapPronoun = new Dictionary <VPPerson, string>(); mapPronoun.Add(VPPerson.Sg1, " mé"); mapPronoun.Add(VPPerson.Sg2, " tú"); mapPronoun.Add(VPPerson.Sg3Masc, " sé"); mapPronoun.Add(VPPerson.Sg3Fem, " sí"); mapPronoun.Add(VPPerson.Pl1, " muid"); mapPronoun.Add(VPPerson.Pl2, " sibh"); mapPronoun.Add(VPPerson.Pl3, " siad"); mapPronoun.Add(VPPerson.NoSubject, ""); mapPronoun.Add(VPPerson.Auto, ""); #endregion #region create-mood-imperative foreach (VPPerson vpPerson in pers) { bool hasSyntheticForms = false; //Synthetic forms: foreach (Form vForm in v.moods[VerbMood.Imper][mapPerson[vpPerson]]) { string pos = vForm.value; string neg = "ná " + Opers.Mutate(Mutation.PrefH, vForm.value); this.moods[VPMood.Imper][vpPerson][VPPolarity.Pos].Add(new Form(pos)); this.moods[VPMood.Imper][vpPerson][VPPolarity.Neg].Add(new Form(neg)); hasSyntheticForms = true; } //Analytic forms: if (!hasSyntheticForms || vpPerson == VPPerson.Pl1 || vpPerson == VPPerson.Pl3) { foreach (Form vForm in v.moods[VerbMood.Imper][VerbPerson.Base]) { string pos = vForm.value + mapPronoun[vpPerson]; string neg = "ná " + Opers.Mutate(Mutation.PrefH, vForm.value) + mapPronoun[vpPerson]; this.moods[VPMood.Imper][vpPerson][VPPolarity.Pos].Add(new Form(pos)); this.moods[VPMood.Imper][vpPerson][VPPolarity.Neg].Add(new Form(neg)); hasSyntheticForms = true; } } } #endregion #region create-mood-subjunctive foreach (VPPerson vpPerson in pers) { Mutation posMut = Mutation.Ecl1; Mutation negMut = Mutation.Len1; string negParticle = "nár "; //Exceptions for irregular verbs: if (v.getLemma() == "abair") { negMut = Mutation.None; } if (v.getLemma() == "bí") { negParticle = "ná "; } bool hasSyntheticForms = false; //Synthetic forms: foreach (Form vForm in v.moods[VerbMood.Subj][mapPerson[vpPerson]]) { string pos = "go " + Opers.Mutate(posMut, vForm.value); string neg = negParticle + Opers.Mutate(negMut, vForm.value); this.moods[VPMood.Subj][vpPerson][VPPolarity.Pos].Add(new Form(pos)); this.moods[VPMood.Subj][vpPerson][VPPolarity.Neg].Add(new Form(neg)); hasSyntheticForms = true; } //Analytic forms: if (!hasSyntheticForms || vpPerson == VPPerson.Pl1) { foreach (Form vForm in v.moods[VerbMood.Subj][VerbPerson.Base]) { string pos = "go " + Opers.Mutate(posMut, vForm.value) + mapPronoun[vpPerson]; string neg = negParticle + Opers.Mutate(negMut, vForm.value) + mapPronoun[vpPerson]; this.moods[VPMood.Subj][vpPerson][VPPolarity.Pos].Add(new Form(pos)); this.moods[VPMood.Subj][vpPerson][VPPolarity.Neg].Add(new Form(neg)); hasSyntheticForms = true; } } } #endregion }
//Creates a prepositional phrase from a preposition and a noun phrase: public PP(Preposition prep, NP np) { this.prepNick = prep.getNickname(); if (this.prepNick == "ag_prep") { foreach (FormSg f in np.sgDat) { this.sg.Add(new FormSg("ag " + f.value, f.gender)); } foreach (Form f in np.plDat) { this.pl.Add(new Form("ag " + f.value)); } foreach (FormSg f in np.sgDatArtN) { this.sgArtN.Add(new FormSg("ag an " + Opers.Mutate(Mutation.Len3, f.value), f.gender)); } foreach (FormSg f in np.sgDatArtS) { this.sgArtS.Add(new FormSg("ag an " + Opers.Mutate((f.gender == Gender.Fem?Mutation.Ecl3:Mutation.Ecl2), f.value), f.gender)); } foreach (Form f in np.plDatArt) { this.plArt.Add(new Form("ag na " + Opers.Mutate(Mutation.PrefH, f.value))); } } if (this.prepNick == "ar_prep") { foreach (FormSg f in np.sgDat) { this.sg.Add(new FormSg("ar " + Opers.Mutate(Mutation.Len1, f.value), f.gender)); } foreach (Form f in np.plDat) { this.pl.Add(new Form("ar " + Opers.Mutate(Mutation.Len1, f.value))); } foreach (FormSg f in np.sgDatArtN) { this.sgArtN.Add(new FormSg("ar an " + Opers.Mutate(Mutation.Len3, f.value), f.gender)); } foreach (FormSg f in np.sgDatArtS) { this.sgArtS.Add(new FormSg("ar an " + Opers.Mutate((f.gender == Gender.Fem?Mutation.Ecl3:Mutation.Ecl2), f.value), f.gender)); } foreach (Form f in np.plDatArt) { this.plArt.Add(new Form("ar na " + Opers.Mutate(Mutation.PrefH, f.value))); } } if (this.prepNick == "thar_prep") { foreach (FormSg f in np.sgDat) { this.sg.Add(new FormSg("thar " + Opers.Mutate(Mutation.Len1, f.value), f.gender)); } foreach (Form f in np.plDat) { this.pl.Add(new Form("thar " + Opers.Mutate(Mutation.Len1, f.value))); } foreach (FormSg f in np.sgDatArtN) { this.sgArtN.Add(new FormSg("thar an " + Opers.Mutate(Mutation.Len3, f.value), f.gender)); } foreach (FormSg f in np.sgDatArtS) { this.sgArtS.Add(new FormSg("thar an " + Opers.Mutate((f.gender == Gender.Fem?Mutation.Ecl3:Mutation.Ecl2), f.value), f.gender)); } foreach (Form f in np.plDatArt) { this.plArt.Add(new Form("thar na " + Opers.Mutate(Mutation.PrefH, f.value))); } } if (this.prepNick == "as_prep") { foreach (FormSg f in np.sgDat) { this.sg.Add(new FormSg("as " + f.value, f.gender)); } foreach (Form f in np.plDat) { this.pl.Add(new Form("as " + f.value)); } foreach (FormSg f in np.sgDatArtN) { this.sgArtN.Add(new FormSg("as an " + Opers.Mutate(Mutation.Len3, f.value), f.gender)); } foreach (FormSg f in np.sgDatArtS) { this.sgArtS.Add(new FormSg("as an " + Opers.Mutate((f.gender == Gender.Fem?Mutation.Ecl3:Mutation.Ecl2), f.value), f.gender)); } foreach (Form f in np.plDatArt) { this.plArt.Add(new Form("as na " + Opers.Mutate(Mutation.PrefH, f.value))); } } if (this.prepNick == "chuig_prep") { foreach (FormSg f in np.sgDat) { this.sg.Add(new FormSg("chuig " + f.value, f.gender)); } foreach (Form f in np.plDat) { this.pl.Add(new Form("chuig " + f.value)); } foreach (FormSg f in np.sgDatArtN) { this.sgArtN.Add(new FormSg("chuig an " + Opers.Mutate(Mutation.Len3, f.value), f.gender)); } foreach (FormSg f in np.sgDatArtS) { this.sgArtS.Add(new FormSg("chuig an " + Opers.Mutate((f.gender == Gender.Fem?Mutation.Ecl3:Mutation.Ecl2), f.value), f.gender)); } foreach (Form f in np.plDatArt) { this.plArt.Add(new Form("chuig na " + Opers.Mutate(Mutation.PrefH, f.value))); } } if (this.prepNick == "de_prep") { foreach (FormSg f in np.sgDat) { string txt = Opers.Mutate(Mutation.Len1, f.value); if (Opers.StartsVowelFhx(txt)) { txt = "d'" + txt; } else { txt = "de " + txt; } this.sg.Add(new FormSg(txt, f.gender)); } foreach (Form f in np.plDat) { string txt = Opers.Mutate(Mutation.Len1, f.value); if (Opers.StartsVowelFhx(txt)) { txt = "d'" + txt; } else { txt = "de " + txt; } this.pl.Add(new Form(txt)); } foreach (FormSg f in np.sgDatArtN) { this.sgArtN.Add(new FormSg("den " + Opers.Mutate(Mutation.Len3, f.value), f.gender)); } foreach (FormSg f in np.sgDatArtS) { this.sgArtS.Add(new FormSg("den " + Opers.Mutate((f.gender == Gender.Fem?Mutation.Len3:Mutation.Len2), f.value), f.gender)); } foreach (Form f in np.plDatArt) { this.plArt.Add(new Form("de na " + Opers.Mutate(Mutation.PrefH, f.value))); } } if (this.prepNick == "do_prep") { foreach (FormSg f in np.sgDat) { string txt = Opers.Mutate(Mutation.Len1, f.value); if (Opers.StartsVowelFhx(txt)) { txt = "d'" + txt; } else { txt = "do " + txt; } this.sg.Add(new FormSg(txt, f.gender)); } foreach (Form f in np.plDat) { string txt = Opers.Mutate(Mutation.Len1, f.value); if (Opers.StartsVowelFhx(txt)) { txt = "d'" + txt; } else { txt = "do " + txt; } this.pl.Add(new Form(txt)); } foreach (FormSg f in np.sgDatArtN) { this.sgArtN.Add(new FormSg("don " + Opers.Mutate(Mutation.Len3, f.value), f.gender)); } foreach (FormSg f in np.sgDatArtS) { this.sgArtS.Add(new FormSg("don " + Opers.Mutate((f.gender == Gender.Fem?Mutation.Len3:Mutation.Len2), f.value), f.gender)); } foreach (Form f in np.plDatArt) { this.plArt.Add(new Form("do na " + Opers.Mutate(Mutation.PrefH, f.value))); } } if (this.prepNick == "faoi_prep") { foreach (FormSg f in np.sgDat) { this.sg.Add(new FormSg("faoi " + Opers.Mutate(Mutation.Len1, f.value), f.gender)); } foreach (Form f in np.plDat) { this.pl.Add(new Form("faoi " + Opers.Mutate(Mutation.Len1, f.value))); } foreach (FormSg f in np.sgDatArtN) { this.sgArtN.Add(new FormSg("faoin " + Opers.Mutate(Mutation.Len3, f.value), f.gender)); } foreach (FormSg f in np.sgDatArtS) { this.sgArtS.Add(new FormSg("faoin " + Opers.Mutate((f.gender == Gender.Fem?Mutation.Ecl3:Mutation.Ecl2), f.value), f.gender)); } foreach (Form f in np.plDatArt) { this.plArt.Add(new Form("faoi na " + Opers.Mutate(Mutation.PrefH, f.value))); } } if (this.prepNick == "i_prep") { foreach (FormSg f in np.sgDat) { if (Opers.StartsVowel(f.value)) { this.sg.Add(new FormSg("in " + f.value, f.gender)); } else { this.sg.Add(new FormSg("i " + Opers.Mutate(Mutation.Ecl1x, f.value), f.gender)); } } foreach (Form f in np.plDat) { if (Opers.StartsVowel(f.value)) { this.pl.Add(new Form("in " + f.value)); } else { this.pl.Add(new Form("i " + Opers.Mutate(Mutation.Ecl1x, f.value))); } } foreach (FormSg f in np.sgDatArtN) { string txt = Opers.Mutate(Mutation.Len3, f.value); if (Opers.StartsVowelFhx(txt)) { txt = "san " + txt; } else { txt = "sa " + txt; } this.sgArtN.Add(new FormSg(txt, f.gender)); } foreach (FormSg f in np.sgDatArtS) { string txt = Opers.Mutate((f.gender == Gender.Fem?Mutation.Len3:Mutation.Len2), f.value); if (Opers.StartsVowelFhx(txt)) { txt = "san " + txt; } else { txt = "sa " + txt; } this.sgArtS.Add(new FormSg(txt, f.gender)); } foreach (Form f in np.plDatArt) { this.plArt.Add(new Form("sna " + Opers.Mutate(Mutation.PrefH, f.value))); } } if (this.prepNick == "le_prep") { foreach (FormSg f in np.sgDat) { this.sg.Add(new FormSg("le " + Opers.Mutate(Mutation.PrefH, f.value), f.gender)); } foreach (Form f in np.plDat) { this.pl.Add(new Form("le " + Opers.Mutate(Mutation.PrefH, f.value))); } foreach (FormSg f in np.sgDatArtN) { this.sgArtN.Add(new FormSg("leis an " + Opers.Mutate(Mutation.Len3, f.value), f.gender)); } foreach (FormSg f in np.sgDatArtS) { this.sgArtS.Add(new FormSg("leis an " + Opers.Mutate((f.gender == Gender.Fem?Mutation.Ecl3:Mutation.Ecl2), f.value), f.gender)); } foreach (Form f in np.plDatArt) { this.plArt.Add(new Form("leis na " + Opers.Mutate(Mutation.PrefH, f.value))); } } if (this.prepNick == "ó_prep") { foreach (FormSg f in np.sgDat) { this.sg.Add(new FormSg("ó " + Opers.Mutate(Mutation.Len1, f.value), f.gender)); } foreach (Form f in np.plDat) { this.pl.Add(new Form("ó " + Opers.Mutate(Mutation.Len1, f.value))); } foreach (FormSg f in np.sgDatArtN) { this.sgArtN.Add(new FormSg("ón " + Opers.Mutate(Mutation.Len3, f.value), f.gender)); } foreach (FormSg f in np.sgDatArtS) { this.sgArtS.Add(new FormSg("ón " + Opers.Mutate((f.gender == Gender.Fem?Mutation.Ecl3:Mutation.Ecl2), f.value), f.gender)); } foreach (Form f in np.plDatArt) { this.plArt.Add(new Form("ó na " + Opers.Mutate(Mutation.PrefH, f.value))); } } if (this.prepNick == "roimh_prep") { foreach (FormSg f in np.sgDat) { this.sg.Add(new FormSg("roimh " + Opers.Mutate(Mutation.Len1, f.value), f.gender)); } foreach (Form f in np.plDat) { this.pl.Add(new Form("roimh " + Opers.Mutate(Mutation.Len1, f.value))); } foreach (FormSg f in np.sgDatArtN) { this.sgArtN.Add(new FormSg("roimh an " + Opers.Mutate(Mutation.Len3, f.value), f.gender)); } foreach (FormSg f in np.sgDatArtS) { this.sgArtS.Add(new FormSg("roimh an " + Opers.Mutate((f.gender == Gender.Fem?Mutation.Ecl3:Mutation.Ecl2), f.value), f.gender)); } foreach (Form f in np.plDatArt) { this.plArt.Add(new Form("roimh na " + Opers.Mutate(Mutation.PrefH, f.value))); } } if (this.prepNick == "trí_prep") { foreach (FormSg f in np.sgDat) { this.sg.Add(new FormSg("trí " + Opers.Mutate(Mutation.Len1, f.value), f.gender)); } foreach (Form f in np.plDat) { this.pl.Add(new Form("trí " + Opers.Mutate(Mutation.Len1, f.value))); } foreach (FormSg f in np.sgDatArtN) { this.sgArtN.Add(new FormSg("tríd an " + Opers.Mutate(Mutation.Len3, f.value), f.gender)); } foreach (FormSg f in np.sgDatArtS) { this.sgArtS.Add(new FormSg("tríd an " + Opers.Mutate((f.gender == Gender.Fem?Mutation.Ecl3:Mutation.Ecl2), f.value), f.gender)); } foreach (Form f in np.plDatArt) { this.plArt.Add(new Form("trí na " + Opers.Mutate(Mutation.PrefH, f.value))); } } if (this.prepNick == "um_prep") { foreach (FormSg f in np.sgDat) { string txt = f.value; if (!Opers.StartsBilabial(txt)) { txt = Opers.Mutate(Mutation.Len1, txt); } this.sg.Add(new FormSg("um " + txt, f.gender)); } foreach (Form f in np.plDat) { string txt = f.value; if (!Opers.StartsBilabial(txt)) { txt = Opers.Mutate(Mutation.Len1, txt); } this.pl.Add(new Form("um " + txt)); } foreach (FormSg f in np.sgDatArtN) { this.sgArtN.Add(new FormSg("um an " + Opers.Mutate(Mutation.Len3, f.value), f.gender)); } foreach (FormSg f in np.sgDatArtS) { this.sgArtS.Add(new FormSg("um an " + Opers.Mutate((f.gender == Gender.Fem?Mutation.Ecl3:Mutation.Ecl2), f.value), f.gender)); } foreach (Form f in np.plDatArt) { this.plArt.Add(new Form("um na " + Opers.Mutate(Mutation.PrefH, f.value))); } } }
//Creates a noun phrase from a noun modified by an adjective: public NP(Noun head, Adjective mod) { if (mod.isPre) { Noun prefixedHead = new Noun(head.printXml()); //create a copy of the head noun string prefix = mod.getLemma(); foreach (Form f in prefixedHead.sgNom) { f.value = Opers.Prefix(prefix, f.value); } foreach (Form f in prefixedHead.sgGen) { f.value = Opers.Prefix(prefix, f.value); } foreach (Form f in prefixedHead.sgDat) { f.value = Opers.Prefix(prefix, f.value); } foreach (Form f in prefixedHead.sgVoc) { f.value = Opers.Prefix(prefix, f.value); } foreach (Form f in prefixedHead.plNom) { f.value = Opers.Prefix(prefix, f.value); } foreach (Form f in prefixedHead.plGen) { f.value = Opers.Prefix(prefix, f.value); } foreach (Form f in prefixedHead.plVoc) { f.value = Opers.Prefix(prefix, f.value); } foreach (Form f in prefixedHead.count) { f.value = Opers.Prefix(prefix, f.value); } NP np = new NP(prefixedHead); this.isDefinite = np.isDefinite; this.sgNom = np.sgNom; this.sgNomArt = np.sgNomArt; this.sgGen = np.sgGen; this.sgGenArt = np.sgGenArt; this.sgDat = np.sgDat; this.sgDatArtN = np.sgDatArtN; this.sgDatArtS = np.sgDatArtS; this.plNom = np.plNom; this.plNomArt = np.plNomArt; this.plGen = np.plGen; this.plGenArt = np.plGenArt; this.plDat = np.plDat; this.plDatArt = np.plDatArt; } else { this.isDefinite = head.isDefinite; this.isImmutable = head.isImmutable; this.forceNominative = true; #region singular-nominative foreach (FormSg headForm in head.sgNom) { { //without article: foreach (Form modForm in mod.sgNom) { Mutation mutA = (headForm.gender == Gender.Masc ? Mutation.None : Mutation.Len1); string value = headForm.value + " " + Opers.Mutate(mutA, modForm.value); this.sgNom.Add(new FormSg(value, headForm.gender)); } } if (!head.isDefinite) //with article: { foreach (Form modForm in mod.sgNom) { Mutation mutN = (headForm.gender == Gender.Masc ? Mutation.PrefT : Mutation.Len3); if (head.isImmutable) { mutN = Mutation.None; } Mutation mutA = (headForm.gender == Gender.Masc ? Mutation.None : Mutation.Len1); string value = "an " + Opers.Mutate(mutN, headForm.value) + " " + Opers.Mutate(mutA, modForm.value); this.sgNomArt.Add(new FormSg(value, headForm.gender)); } } } #endregion #region singular-genitive foreach (FormSg headForm in head.sgGen) { { //without article: List <Form> modForms = (headForm.gender == Gender.Masc ? mod.sgGenMasc : mod.sgGenFem); foreach (Form modForm in modForms) { Mutation mutN = (head.isProper ? Mutation.Len1 : Mutation.None); //proper nouns are always lenited in the genitive if (head.isImmutable) { mutN = Mutation.None; } Mutation mutA = (headForm.gender == Gender.Masc ? Mutation.Len1 : Mutation.None); string value = Opers.Mutate(mutN, headForm.value) + " " + Opers.Mutate(mutA, modForm.value); this.sgGen.Add(new FormSg(value, headForm.gender)); } } } foreach (FormSg headForm in head.sgGen) { //with article: if (!head.isDefinite || head.allowArticledGenitive) { List <Form> modForms = (headForm.gender == Gender.Masc ? mod.sgGenMasc : mod.sgGenFem); foreach (Form modForm in modForms) { Mutation mutN = (headForm.gender == Gender.Masc ? Mutation.Len3 : Mutation.PrefH); if (head.isImmutable) { mutN = Mutation.None; } Mutation mutA = (headForm.gender == Gender.Masc ? Mutation.Len1 : Mutation.None); string article = (headForm.gender == Gender.Masc ? "an" : "na"); string value = article + " " + Opers.Mutate(mutN, headForm.value) + " " + Opers.Mutate(mutA, modForm.value); this.sgGenArt.Add(new FormSg(value, headForm.gender)); } } } #endregion #region plural-nominative foreach (Form headForm in head.plNom) { { //without article: foreach (Form modForm in mod.plNom) { Mutation mutA = (Opers.IsSlender(headForm.value) ? Mutation.Len1 : Mutation.None); string value = headForm.value + " " + Opers.Mutate(mutA, modForm.value); this.plNom.Add(new Form(value)); } } if (!head.isDefinite) //with article: { foreach (Form modForm in mod.plNom) { Mutation mutN = Mutation.PrefH; if (head.isImmutable) { mutN = Mutation.None; } Mutation mutA = (Opers.IsSlender(headForm.value) ? Mutation.Len1 : Mutation.None); string value = "na " + Opers.Mutate(mutN, headForm.value) + " " + Opers.Mutate(mutA, modForm.value); this.plNomArt.Add(new Form(value)); } } } #endregion #region plural-genitive foreach (FormPlGen headForm in head.plGen) { { //without article: List <Form> modForms = (headForm.strength == Strength.Strong ? mod.plNom : mod.sgNom); foreach (Form modForm in modForms) { Mutation mutA = (Opers.IsSlender(headForm.value) ? Mutation.Len1 : Mutation.None); if (headForm.strength == Strength.Weak) { mutA = (Opers.IsSlenderI(headForm.value) ? Mutation.Len1 : Mutation.None); //"Gael", "captaen" are not slender } string value = headForm.value + " " + Opers.Mutate(mutA, modForm.value); this.plGen.Add(new Form(value)); } } } foreach (FormPlGen headForm in head.plGen) { //with article: if (!head.isDefinite || head.allowArticledGenitive) { List <Form> modForms = (headForm.strength == Strength.Strong ? mod.plNom : mod.sgNom); foreach (Form modForm in modForms) { Mutation mutN = Mutation.Ecl1; if (head.isImmutable) { mutN = Mutation.None; } Mutation mutA = (Opers.IsSlender(headForm.value) ? Mutation.Len1 : Mutation.None); if (headForm.strength == Strength.Weak) { mutA = (Opers.IsSlenderI(headForm.value) ? Mutation.Len1 : Mutation.None); //"Gael", "captaen" are not slender } string value = "na " + Opers.Mutate(mutN, headForm.value) + " " + Opers.Mutate(mutA, modForm.value); this.plGenArt.Add(new Form(value)); } } } #endregion #region singular-dative foreach (FormSg headForm in head.sgDat) { { //without article: foreach (Form modForm in mod.sgNom) { Mutation mutA = (headForm.gender == Gender.Masc ? Mutation.None : Mutation.Len1); string value = headForm.value + " " + Opers.Mutate(mutA, modForm.value); this.sgDat.Add(new FormSg(value, headForm.gender)); } } if (!head.isDefinite) //with article: { foreach (Form modForm in mod.sgNom) { Mutation mutA = (headForm.gender == Gender.Masc ? Mutation.None : Mutation.Len1); string value = headForm.value + " " + Opers.Mutate(mutA, modForm.value); this.sgDatArtS.Add(new FormSg(value, headForm.gender)); } foreach (Form modForm in mod.sgNom) { string value = headForm.value + " " + Opers.Mutate(Mutation.Len1, modForm.value); this.sgDatArtN.Add(new FormSg(value, headForm.gender)); } } } #endregion #region plural-dative foreach (Form headForm in head.plNom) { { //without article: foreach (Form modForm in mod.plNom) { Mutation mutA = (Opers.IsSlender(headForm.value) ? Mutation.Len1 : Mutation.None); string value = headForm.value + " " + Opers.Mutate(mutA, modForm.value); this.plDat.Add(new Form(value)); } } if (!head.isDefinite) //with article: { foreach (Form modForm in mod.plNom) { Mutation mutA = (Opers.IsSlender(headForm.value) ? Mutation.Len1 : Mutation.None); string value = headForm.value + " " + Opers.Mutate(mutA, modForm.value); this.plDatArt.Add(new Form(value)); } } } #endregion } }
//Creates a noun phrase from a noun: public NP(Noun head) { this.isDefinite = head.isDefinite; this.isImmutable = head.isImmutable; #region singular-nominative foreach (FormSg headForm in head.sgNom) { { //without article: this.sgNom.Add(new FormSg(headForm.value, headForm.gender)); } if (!head.isDefinite) //with article: { Mutation mut = (headForm.gender == Gender.Masc ? Mutation.PrefT : Mutation.Len3); if (head.isImmutable) { mut = Mutation.None; } string value = "an " + Opers.Mutate(mut, headForm.value); this.sgNomArt.Add(new FormSg(value, headForm.gender)); } } #endregion #region singular-genitive foreach (FormSg headForm in head.sgGen) { { //without article: Mutation mut = (head.isProper ? Mutation.Len1 : Mutation.None); //proper nouns are always lenited in the genitive if (head.isImmutable) { mut = Mutation.None; } string value = Opers.Mutate(mut, headForm.value); this.sgGen.Add(new FormSg(value, headForm.gender)); } //with article: if (!head.isDefinite || head.allowArticledGenitive) { Mutation mut = (headForm.gender == Gender.Masc ? Mutation.Len3 : Mutation.PrefH); if (head.isImmutable) { mut = Mutation.None; } string article = (headForm.gender == Gender.Masc ? "an" : "na"); string value = article + " " + Opers.Mutate(mut, headForm.value); this.sgGenArt.Add(new FormSg(value, headForm.gender)); } } #endregion #region plural-nominative foreach (Form headForm in head.plNom) { { //without article: this.plNom.Add(new Form(headForm.value)); } if (!head.isDefinite) //with article: { Mutation mut = Mutation.PrefH; if (head.isImmutable) { mut = Mutation.None; } string value = "na " + Opers.Mutate(mut, headForm.value); this.plNomArt.Add(new Form(value)); } } #endregion #region plural-genitive foreach (Form headForm in head.plGen) { { //without article: Mutation mut = (head.isProper ? Mutation.Len1 : Mutation.None); //proper nouns are always lenited in the articleless genitive if (head.isImmutable) { mut = Mutation.None; } string value = Opers.Mutate(mut, headForm.value); this.plGen.Add(new Form(value)); } if (!head.isDefinite || head.allowArticledGenitive) //with article: { Mutation mut = Mutation.Ecl1; if (head.isImmutable) { mut = Mutation.None; } string value = "na " + Opers.Mutate(mut, headForm.value); this.plGenArt.Add(new Form(value)); } } #endregion #region singular-dative foreach (FormSg headForm in head.sgDat) { { //without article: this.sgDat.Add(new FormSg(headForm.value, headForm.gender)); } if (!head.isDefinite) //with article: { this.sgDatArtN.Add(new FormSg(headForm.value, headForm.gender)); this.sgDatArtS.Add(new FormSg(headForm.value, headForm.gender)); } } #endregion #region plural-dative foreach (Form headForm in head.plNom) { { //without article: this.plDat.Add(new Form(headForm.value)); } if (!head.isDefinite) //with article: { this.plDatArt.Add(new Form(headForm.value)); } } #endregion }
//Creates a noun phrase from an explicit listing of all the basic forms: public NP(Gender gender, string sgNom, string sgGen, string plNom, string plGen, string sgDatArtN) { #region singular-nominative { //without article: this.sgNom.Add(new FormSg(sgNom, gender)); } { //with article: Mutation mut = (gender == Gender.Masc ? Mutation.PrefT : Mutation.Len3); string value = "an " + Opers.Mutate(mut, sgNom); this.sgNomArt.Add(new FormSg(value, gender)); } #endregion #region singular-genitive { //without article: string value = sgNom; this.sgGen.Add(new FormSg(value, gender)); } { //with article: Mutation mut = (gender == Gender.Masc ? Mutation.Len3 : Mutation.PrefH); string article = (gender == Gender.Masc ? "an" : "na"); string value = article + " " + Opers.Mutate(mut, sgGen); this.sgGenArt.Add(new FormSg(value, gender)); } #endregion #region plural-nominative { //without article: this.plNom.Add(new Form(plNom)); } { //with article: string value = "na " + Opers.Mutate(Mutation.PrefH, plNom); this.plNomArt.Add(new Form(value)); } #endregion #region plural-genitive { //without article: this.plGen.Add(new Form(plNom)); } { //with article: string value = "na " + Opers.Mutate(Mutation.Ecl1, plGen); this.plGenArt.Add(new Form(value)); } #endregion #region singular-dative { //without article: this.sgDat.Add(new FormSg(sgNom, gender)); } { //with article: this.sgDatArtN.Add(new FormSg(sgDatArtN, gender)); this.sgDatArtS.Add(new FormSg(sgNom, gender)); Mutation mut = (gender == Gender.Masc ? Mutation.PrefT : Mutation.Len3); string value = "an " + Opers.Mutate(mut, sgNom); this.sgNomArt.Add(new FormSg(value, gender)); } #endregion #region plural-dative { //without article: this.plDat.Add(new Form(plNom)); } { //with article: this.plDatArt.Add(new Form(plNom)); } #endregion }