コード例 #1
0
ファイル: PrinterNeid.cs プロジェクト: colincwilson/Gramadan
        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);
        }
コード例 #2
0
ファイル: NP.cs プロジェクト: colincwilson/Gramadan
 //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
     }
 }