//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))); } } }
public string printNPXml(NP np) { string nl = Environment.NewLine; string ret = ""; 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(np.getLemma()) + "' uid='" + clean4xml(np.getNickname()) + "'>" + nl; ret += "<nounPhrase"; if (np.hasGender()) { ret += " gender='" + (np.getGender() == Gender.Masc ? "masc" : "fem") + "'"; } ret += " forceNominative='" + (np.forceNominative ? "1" : "0") + "'"; ret += ">" + nl; //Singular nominative: for (int i = 0; i < Math.Max(np.sgNom.Count, np.sgNomArt.Count); i++) { ret += "\t<sgNom>" + nl; if (np.sgNom.Count > i) { ret += "\t\t<articleNo>" + clean4xml(np.sgNom[i].value) + "</articleNo>" + nl; } if (np.sgNomArt.Count > i) { ret += "\t\t<articleYes>" + clean4xml(np.sgNomArt[i].value) + "</articleYes>" + nl; } ret += "\t</sgNom>" + nl; } //Singular genitive: for (int i = 0; i < Math.Max(np.sgGen.Count, np.sgGenArt.Count); i++) { ret += "\t<sgGen>" + nl; if (np.sgGen.Count > i) { ret += "\t\t<articleNo>" + clean4xml(np.sgGen[i].value) + "</articleNo>" + nl; } if (np.sgGenArt.Count > i) { ret += "\t\t<articleYes>" + clean4xml(np.sgGenArt[i].value) + "</articleYes>" + nl; } ret += "\t</sgGen>" + nl; } //Plural nominative: for (int i = 0; i < Math.Max(np.plNom.Count, np.plNomArt.Count); i++) { ret += "\t<plNom>" + nl; if (np.plNom.Count > i) { ret += "\t\t<articleNo>" + clean4xml(np.plNom[i].value) + "</articleNo>" + nl; } if (np.plNomArt.Count > i) { ret += "\t\t<articleYes>" + clean4xml(np.plNomArt[i].value) + "</articleYes>" + nl; } ret += "\t</plNom>" + nl; } //Plural genitive: for (int i = 0; i < Math.Max(np.plGen.Count, np.plGenArt.Count); i++) { ret += "\t<plGen>" + nl; if (np.plGen.Count > i) { ret += "\t\t<articleNo>" + clean4xml(np.plGen[i].value) + "</articleNo>" + nl; } if (np.plGenArt.Count > i) { ret += "\t\t<articleYes>" + clean4xml(np.plGenArt[i].value) + "</articleYes>" + nl; } ret += "\t</plGen>" + nl; } ret += "</nounPhrase>" + nl; ret += "</Lemma>"; return(ret); }
//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 } }