void ILoader.loadDico(LanguageDictionary dico, Factory factory) { // chargement du dico à partir d'une base SQLite // -- chargement des mots --------------------------------------- List<Dictionary<string, object>> words = this.db.select("words", new string[] { "word", "type", "attributs", "definition" }); for (int i = 0; i < words.Count; i++) { string w = (string)words[i]["word"]; string t = (string)words[i]["type"]; string a = (string)words[i]["attributs"]; string d = (string)words[i]["definition"]; if (a == null) a = ""; if (d == null) d = ""; Word word = factory.create(w, t, a.Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries), d); if (word.IsTypeOf(typeof(VerbType))) { //charger la table de conjugaison Word[] verbsConjugated = this.getConjugatedVerbsFor(word.word, factory); ConjugationTable table = new ConjugationTable(word); table.AddRange(verbsConjugated); // ajout des verbes à la table de conjugaison dico.conjugaisonTables.Add(table); // ajout de la table de conjugaison au dictionnaire dico.AddRange(verbsConjugated); // ajout des verbes au dictionnaire } dico.Add(word); } }
private Word[] getConjugatedVerbsFor(string v, Factory factory) { List<Dictionary<string, object>> verbsRaw = this.db.select("conjugated_verbs", new string[] { "mood", "tense", "person", "word" }, new string[] { "base='" + v + "'" }); List<Word> verbs = new List<Word>(); for (int i = 0; i < verbsRaw.Count; i++) { int m = (int)((decimal)verbsRaw[i]["mood"]); int t = (int)((decimal)verbsRaw[i]["tense"]); int p = (int)((decimal)verbsRaw[i]["person"]); string w = (string)verbsRaw[i]["word"]; verbs.Add(factory.create(w, "verb", new string[] { m.ToString(), t.ToString(), p.ToString() }, "")); } return verbs.ToArray(); }