/// <summary> /// Torna una llista d'ItemDic aplanada. /// Els ítems de la llista nova només contenen flags per a regles amb EsSufix = false. /// </summary> /// <param name="items">La llista d'ítems que volem aplanar.</param> /// <param name="regles">La llista de regles que emprarem.</param> /// <param name="filtre">Només es generen mots que tenen marques contingudes en aquest filtre.</param> /// <returns>La llista aplanada.</returns> public static List<ItemDic> Aplana(List<ItemDic> items, Regles regles, Marques filtre) { // PERFER: No desplegar els futurs i els condicionals, ja que són sempre regulars (?) List<ItemDic> llista = new List<ItemDic>(); foreach (ItemDic item in items) { string arrel = item.Arrel; List<Regla> aff = null; List<string> noAff = new List<string>(); foreach (string idRegla in item.LlistaFlags) { Regla regla = regles.Llista[idRegla]; if (regla.EsAfix) { if (aff == null) aff = new List<Regla>(); aff.Add(regla); } else { noAff.Add(idRegla); } } if (aff == null) { // PER_FER: mirar si no hem de posar totes les regles de noaff llista.Add(item); } else // (aff != null) { ItemDic nou = null; // Afegim l'arrel nua nou = new ItemDic(arrel, noAff.ToArray()); nou.MesMorfoGram(item.mgComuna, item.mgArrel); llista.Add(nou); // Afegim els mots generats per les regles d'aff foreach (Regla regla in aff) { List<Mot> mots = new List<Mot>(); foreach (CasRegla cas in regla.Casos) { mots.Clear(); int generats = cas.Genera(arrel, ref mots, item.mgComuna, regles, filtre, true); if (generats == 0) continue; if (generats > 1) throw new Exception("S'esperava un sol mot per al cas"); Mot mot = mots[0]; nou = new ItemDic(mot.Forma); if (regla.EsCombinable) foreach (string id in noAff) { Regla reglaNoAff = regles.Llista[id]; if (reglaNoAff.EsCombinable && reglaNoAff.EsAplicable(nou.Arrel)) nou.MesFlags(id); } if (cas.MesRegles != null) { foreach (string id in cas.MesRegles) { Regla reglaExtra = regles.Llista[id]; if (reglaExtra.EsAplicable(nou.Arrel)) nou.MesFlags(id); } } nou.MesMorfoGram(item.mgComuna, mot.Info); llista.Add(nou); } } } } return llista; }
public override void Genera(Dictionary<string, string> dades, Dictionary<string, string> excepcions, Marques filtre, List<ItemDic> items) { string arrel0, arrel1; arrel0 = Arrel0(dades["arrel"], out arrel1); int numArrel = (mgComuna.Gen == MorfoGram.eGen.F) ? 1 : 0; ItemDic item = new ItemDic((numArrel == 1) ? arrel1 : arrel0, regla); item.MesMorfoGram(mgComuna, mgArrel); if (admetD) item.MesFlags("Y"); if (admetL) { if (numArrel == 0) item.MesFlags("V"); else { Paraula paraula = new Paraula(arrel1); if (paraula.PotApostrofar(true)) item.MesFlags("V"); } } items.Add(item); }
public override void Genera(Dictionary<string, string> dades, Dictionary<string, string> excepcions, Marques filtre, List<ItemDic> items) { ItemDic item = new ItemDic(forma, flags); if (mg != null) item.MesMorfoGram(mg, mg); items.Add(item); }
public override void Genera(Dictionary<string, string> dades, Dictionary<string, string> excepcions, Marques filtre, List<ItemDic> items) { ItemDic item = new ItemDic(dades["arrel"]); item.MesMorfoGram(mgComuna, null); if (admetD) item.MesFlags("Y"); if (admetL) item.MesFlags("V"); if (admetN) item.MesFlags("W"); items.Add(item); }