private void Search(AttributeStructure data, string pathInTree) { // exclude the tuning-file if (pathInTree == "simulation\\attrib\\tuning\\tuning_info.rbf") return; foreach (var attribValue in data.Root) { if (attribValue.DataType != AttributeDataType.String) continue; string attribData = attribValue.Data as string; if (string.IsNullOrWhiteSpace(attribData)) continue; // exclude file references if (!attribData.ContainsAny('\\', '/')) { DictEntry entry; if (!m_results.TryGetValue(attribValue.Key, out entry)) { entry = new DictEntry(attribValue.Key); m_results.Add(entry.Key, entry); } if (!entry.Options.Contains(attribData)) entry.Options.Add(attribData); } } }
/// <summary> /// 使用状况帮助后事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ResSyzkHelped(object sender, DictEntryPickedEventArgs e) { DictEntry dic = e.DictEntry; //获取多值帮助选择的数据 if (dic == null) //没有选中任何值 "确定" { return; } else if (dic.Row == null) //"取消" { return; } var id = dic.ID; //id赋值 GetCurRow()[ResSyzkId] = id; }
//Write's a complete new File public static void write(DictEntry dicEntry) { createPathIfNotExists(); StreamWriter writer = new StreamWriter(path, false); if (dicEntry is DictEntrySingleWord) { DictEntrySingleWord entry = ((DictEntrySingleWord)dicEntry); writer.WriteLine(entry.getWord() + "," + entry.getRate()); } else { List <DictEntrySingleWord> list = ((DictEntryMultyWord)dicEntry).getAllSubWords(); foreach (DictEntrySingleWord entry in list) { writer.WriteLine(entry.getWord() + "," + entry.getRate()); } } writer.Close(); }
private void BtnSearchClick(object sender, EventArgs e) { if (FileManager.AttribTree == null) { UIHelper.ShowError("The attrib-tree could not be found! Ensure that there is a mod loaded"); return; } m_selectedItem = null; m_chklbxEntries.Items.Clear(); m_progBarSearch.Value = 1; m_progBarSearch.Step = 1; m_progBarSearch.Minimum = 1; m_progBarSearch.Maximum = FileManager.AttribTree.RootNode.GetTotalFileCount(); m_btnSearch.Enabled = false; m_results = new Dictionary <string, DictEntry>(); m_crawler = new RBFCrawler(Search, FileManager.AttribTree.RootNode, AdvanceProgress); m_crawler.OnFinished += CrawlerOnFinished; m_crawler.Start(); }
public ObservableCollection <DictEntry> GetDictionary() { // поскольку в объекте dataAccess объект FbDataAdapter уже мониторит одну таблицу // на предмет изменений, получение данных происходит без помощи адаптера DataTableReader reader = dataAccess.GetReader(dictionarySqlSelect); ObservableCollection <DictEntry> dictionary = new ObservableCollection <DictEntry>(); if (reader != null) { while (reader.Read()) { DictEntry dictModel = new DictEntry() { Id = reader.GetValue(0), Name = reader.GetValue(1) }; dictionary.Add(dictModel); } } return(dictionary); }
/// <summary> /// Updates the dict content. If the dict content was not initialized, nothing will happen /// </summary> public void UpdateContent() { if (Content == null) { return; } string text = textBox.Text; DictEntry entry = Content.Contents.FirstOrDefault(e => e.LanguageID == CurrentLanguage.ID); //if there is a dict entry for the current language, update it if (entry != null) { entry.Content = System.Web.HttpUtility.HtmlEncode(text); } //if not, make a new one else { Content.AddEntry(CurrentLanguage.ID, System.Web.HttpUtility.HtmlEncode(text)); } }
static void Main(string[] args) { DictEntry[] dict = new DictEntry[30]; dict[0] = new DictEntry("head", "huvud"); dict[1] = new DictEntry("see", "se"); dict[2] = new DictEntry("father", "far, pappa"); dict[3] = new DictEntry("tree", "träd"); dict[4] = new DictEntry("moon", "måne"); dict[5] = new DictEntry("move", "flytta"); dict[6] = new DictEntry("city", "stad"); Console.WriteLine("{0,-10}{1,-20}", "English", "Swedish"); Console.WriteLine("--------------------"); for (int i = 0; i < dict.Length; i++) { if (dict[i] != null) { Console.WriteLine("{0,-10}{1,-20}", dict[i].english, dict[i].swedish); } } Console.WriteLine("--------------------"); }
public void AddPropertie(string name, ScalerVar propertie) { _properties.Remove(name); _properties.Add(DictEntry.Root(name, new DictItem(propertie))); }
private static IDictionary<string, DictEntry> initializeDictHash() { DictEntry defaultEntry; DictEntry entry; IDictionary<string, DictEntry> d = new Dictionary<string, DictEntry>(1000); for (int i = 0; i < exceptionWords.Length; i++) { if (!d.ContainsKey(exceptionWords[i])) { entry = new DictEntry(exceptionWords[i], true); d.Add(exceptionWords[i], entry); } else { Debug.Write("Warning: Entry [" + exceptionWords[i] + "] already in dictionary 1"); } } for (int i = 0; i < directConflations.Length; i++) { if (!d.ContainsKey(directConflations[i][0])) { entry = new DictEntry(directConflations[i][1], false); d.Add(directConflations[i][0], entry); } else { Debug.Write("Warning: Entry [" + directConflations[i][0] + "] already in dictionary 2"); } } for (int i = 0; i < countryNationality.Length; i++) { if (!d.ContainsKey(countryNationality[i][0])) { entry = new DictEntry(countryNationality[i][1], false); d.Add(countryNationality[i][0], entry); } else { Debug.Write("Warning: Entry [" + countryNationality[i][0] + "] already in dictionary 3"); } } defaultEntry = new DictEntry(null, false); string[] array = KStemData1.data; for (int i = 0; i < array.Length; i++) { if (!d.ContainsKey(array[i])) { d.Add(array[i], defaultEntry); } else { Debug.Write("Warning: Entry [" + array[i] + "] already in dictionary 4"); } } array = KStemData2.data; for (int i = 0; i < array.Length; i++) { if (!d.ContainsKey(array[i])) { d.Add(array[i], defaultEntry); } else { Debug.Write("Warning: Entry [" + array[i] + "] already in dictionary 4"); } } array = KStemData3.data; for (int i = 0; i < array.Length; i++) { if (!d.ContainsKey(array[i])) { d.Add(array[i], defaultEntry); } else { Debug.Write("Warning: Entry [" + array[i] + "] already in dictionary 4"); } } array = KStemData4.data; for (int i = 0; i < array.Length; i++) { if (!d.ContainsKey(array[i])) { d.Add(array[i], defaultEntry); } else { Debug.Write("Warning: Entry [" + array[i] + "] already in dictionary 4"); } } array = KStemData5.data; for (int i = 0; i < array.Length; i++) { if (!d.ContainsKey(array[i])) { d.Add(array[i], defaultEntry); } else { Debug.Write("Warning: Entry [" + array[i] + "] already in dictionary 4"); } } array = KStemData6.data; for (int i = 0; i < array.Length; i++) { if (!d.ContainsKey(array[i])) { d.Add(array[i], defaultEntry); } else { Debug.Write("Warning: Entry [" + array[i] + "] already in dictionary 4"); } } array = KStemData7.data; for (int i = 0; i < array.Length; i++) { if (!d.ContainsKey(array[i])) { d.Add(array[i], defaultEntry); } else { Debug.Write("Warning: Entry [" + array[i] + "] already in dictionary 4"); } } for (int i = 0; i < KStemData8.data.Length; i++) { if (!d.ContainsKey(KStemData8.data[i])) { d.Add(KStemData8.data[i], defaultEntry); } else { Debug.Write("Warning: Entry [" + KStemData8.data[i] + "] already in dictionary 4"); } } for (int i = 0; i < supplementDict.Length; i++) { if (!d.ContainsKey(supplementDict[i])) { d.Add(supplementDict[i], defaultEntry); } else { Debug.Write("Warning: Entry [" + supplementDict[i] + "] already in dictionary 5"); } } for (int i = 0; i < properNouns.Length; i++) { if (!d.ContainsKey(properNouns[i])) { d.Add(properNouns[i], defaultEntry); } else { Debug.Write("Warning: Entry [" + properNouns[i] + "] already in dictionary 6"); } } return d; }
/** * Stems the text in the token. Returns true if changed. */ public bool stem(String term, int len) { len = term.Length; // HACK for API compatibility result = null; k = len - 1; if ((k <= 1) || (k >= MaxWordLen - 1)) { return false; // don't stem } // first check the stemmer dictionaries, and avoid using the // cache if it's in there. DictEntry entry = dict_ht.ContainsKey(term) ? dict_ht[term] : null; if (entry != null) { if (entry.root != null) { result = entry.root; return true; } return false; } /*** * caching off is normally faster if (cache == null) initializeStemHash(); * * // now check the cache, before we copy chars to "word" if (cache != null) * { String val = cache.get(term, 0, len); if (val != null) { if (val != * SAME) { result = val; return true; } return false; } } ***/ word.reset(); // allocate enough space so that an expansion is never needed word.reserve(len + 10); for (int i = 0; i < len; i++) { char ch = term[i]; if (!isAlpha(ch)) return false; // don't stem // don't lowercase... it's a requirement that lowercase filter be // used before this stemmer. word.unsafeWrite(ch); } matchedEntry = null; /*** * lookups.clear(); lookups.add(word.toString()); ***/ /* * This while loop will never be executed more than one time; it is here * only to allow the break statement to be used to escape as soon as a word * is recognized */ while (true) { // YCS: extra lookup()s were inserted so we don't need to // do an extra wordInDict() here. plural(); if (matched()) break; pastTense(); if (matched()) break; aspect(); if (matched()) break; ityEndings(); if (matched()) break; nessEndings(); if (matched()) break; ionEndings(); if (matched()) break; erAndOrEndings(); if (matched()) break; lyEndings(); if (matched()) break; alEndings(); if (matched()) break; entry = wordInDict(); iveEndings(); if (matched()) break; izeEndings(); if (matched()) break; mentEndings(); if (matched()) break; bleEndings(); if (matched()) break; ismEndings(); if (matched()) break; icEndings(); if (matched()) break; ncyEndings(); if (matched()) break; nceEndings(); matched(); break; } /* * try for a direct mapping (allows for cases like `Italian'->`Italy' and * `Italians'->`Italy') */ entry = matchedEntry; if (entry != null) { result = entry.root; // may be null, which means that "word" is the stem } /*** * caching off is normally faster if (cache != null && cache.size() < * maxCacheSize) { char[] key = new char[len]; System.arraycopy(term, 0, * key, 0, len); if (result != null) { cache.put(key, result); } else { * cache.put(key, word.toString()); } } ***/ /*** * if (entry == null) { if (!word.toString().equals(new String(term,0,len))) * { System.out.println("CASE:" + word.toString() + "," + new * String(term,0,len)); * * } } ***/ // no entry matched means result is "word" return true; }
private DictEntry wordInDict() { /*** * if (matchedEntry != null) { if (dict_ht.get(word.getArray(), 0, * word.size()) != matchedEntry) { * System.out.println("Uh oh... cached entry doesn't match"); } return * matchedEntry; } ***/ if (matchedEntry != null) return matchedEntry; String w = word.toString(); DictEntry e = dict_ht.ContainsKey(w) ? dict_ht[w] : null; if (e != null && !e.exception) { matchedEntry = e; // only cache if it's not an exception. } // lookups.add(word.toString()); return e; }
private bool lookup() { /****** * debugging code String thisLookup = word.toString(); bool added = * lookups.add(thisLookup); if (!added) { * System.out.println("######extra lookup:" + thisLookup); // occaasional * extra lookups aren't necessarily errors... could happen by diff * manipulations // throw new RuntimeException("######extra lookup:" + * thisLookup); } else { // System.out.println("new lookup:" + thisLookup); * } ******/ String w = word.toString(); matchedEntry = dict_ht.ContainsKey(w) ? dict_ht[w] : null; return matchedEntry != null; }
public Dictionary() { entry = new DictEntry(); names = new List <DictName>(); RegenerateTree(); }
//public class modExs { // public static modExs formMod(CourseMeta.modInfo mod) { return new modExs() { jsonId = mod.jsonId, exs = mod.exs.Select(e => e.compId).ToArray() }; } // public bool isGramm; // public string jsonId; // public string[] exs; //} public static void getDictEntries(string srcDir) { if (dictEntries != null) return; errors.Clear(); Func<Langs, Langs, string> dictCode = (l1, l2) => LMComLib.DictInfo.GetDict(l1, l2).Code; Func<Langs, string> dictHalfCode = l => CommonLib.langToLingeaLang(l); //sound files namapovane na master sound file a seznam slovicek, ktere jsou ozvuceny var soundFileToMastersAndUsages = DictLib.crsLangs.SelectMany(l => LingeaSndFiles.addSoundsStart(l).files.SelectMany(f => f.clones.Select(c => new { lang = l, c.fileName, soundMaster = f.fileName, //words = f.clones.SelectMany(cl => cl.word.Split('#')).Distinct() }))). GroupBy(f => f.fileName).ToDictionary( g => g.Key, g => new DictEntry { soundMaster = g.First().lang.ToString() + "/" + g.Select(t => t.soundMaster).Distinct().Single()/*, soundWords = g.SelectMany(t => t.words).Distinct().ToArray()*/ } ); //slova z entry Regex tagEx = new Regex(@"<.*?>", RegexOptions.Singleline); Func<XElement, IEnumerable<string>> removeTags = el => split(tagEx.Replace(el.ToString(), " ")); Func<XElement, XElement> srcFromTrans = el => { foreach (var src in el.Descendants().Where(e => new string[] { "in_c", "in_v", "in_g", "in_w", "in_pp", "in_d" }.Contains(e.AttributeValue("class"))).ToArray()) src.Remove(); return el; }; Func<DictEntry, string[][]> extractWords = de => { //if (de.wordId() == "dvd" && de.natLang==Langs.ru_ru) { // de.entry = srcFromTrans(de.entry); //} var trans = de.entry.DescendantsAttr("class", "trans").Concat(de.entry.DescendantsAttr("class", "trg")).Select(el => srcFromTrans(el)).SelectMany(el => removeTags(el)).Distinct(); var src = de.entry.DescendantsAttr("class", "src").SelectMany(el => removeTags(el)).Concat(de.headWords).Distinct(); return new string[][] { src.ToArray(), trans.ToArray() }; }; //Dictionary<string, string[]> entryWords = null; //*********** vytvoreni hesla Regex entrTagToSoundTitleEx = new Regex(@"(\d|\*|\(.*?\))"); Func<string, string> entrTagToSoundTitle = s => entrTagToSoundTitleEx.Replace(s, "").ToLower().Trim().Replace("\x301", null); Func<Langs, Langs, KeyValuePair<string, XElement>, DictEntry> createEntry = (crsLang, natLang, id_entry) => { var res = new DictEntry { //dictId = dictCode(crsLang, natLang), entryId = id_entry.Key, //soundTitle = title = entrTagToSoundTitle(id_entry.Value.DescendantsAttr("class", "entr").First().Value), //headWords = splitHeadwords(id_entry.Value.DescendantsAttr("class", "entr").First().Value).ToArray(), crsLang = crsLang, natLang = natLang, entry = id_entry.Value, }; res.soundFile = id_entry.Value.AttributeValue("oldLngSound"); var pron = id_entry.Value.DescendantsAttr("class", "pron").FirstOrDefault(); res.pronText = pron == null ? null : pron.Value; DictEntry sndFileInfo = null; if (res.soundFile != null) { //res2.soundDictId = res2.soundFile.Substring(1, 4); soundFileToMastersAndUsages.TryGetValue(res.soundFile, out sndFileInfo); if (sndFileInfo != null) res.soundMaster = sndFileInfo.soundMaster; //res2.soundWords = sndFileInfo.soundWords; } var wordsFromEntry = extractWords(res); res.wordStats = new LangCounts { crsWords = wordsFromEntry[0], natWords = wordsFromEntry[1] }; return res; }; dictEntries = getOldLingeaEntries(srcDir). //k entry dej seznam used Words (puvodni "vals" atribut "w" tagu slovniku) SelectMany(crs => crs.Value. //SideEfect(nat => entryWords = nat.Value.wordToEntryId.GroupBy(d => d.Value).ToDictionary(d => d.Key, d => d.Select(t => t.Value).Distinct().ToArray())). SelectMany(nat => nat.Value.entryIdToEntry.Select(kv => createEntry(crs.Key, nat.Key, kv))) ).ToArray(); //zjisti jazyk pres SoundMaster file var soundMasterLangs = dictEntries.Where(de => de.soundMaster != null).GroupBy(de => de.soundMaster).Select(g => new { g.Key, //soundMaser langs = new { langs = DictLib.crsLangs.Where(l => g.All(de => de.bothLangs().Contains(l))).Distinct().ToArray(), //spolecne Crs jazyk pro stejny zvuk dicts = g.Select(t => encodeLangs(t.crsLang, t.natLang)).Distinct().ToArray() //ruzne slovniky } }). Where(kv => kv.langs.dicts.Length > 2 && kv.langs.langs.Length == 1). //musi byt alespon 2 slovniky a prave jeden jazyk ToDictionary(kv => kv.Key, kv => kv.langs.langs[0]); //tabulka soundMaster => jazyk int ru = 0; int morf1 = 0; int morf1Err = 0; int morf2 = 0; int cwin1252 = 0; //foreach (var de in dictEntries.Where(de => de.wordId() == "affittare")) { foreach (var de in dictEntries) { //Pres spolecny soundMaster if (de.soundMaster != null) { Langs l; if (soundMasterLangs.TryGetValue(de.soundMaster, out l)) { if (de.okCrs == Langs.no) { de.okCrs = l; de.okCrsReason = OKCrsReason.soundMaster; } else if (de.okCrs != l) //errors.Add(de); throw new Exception(); } } //nemcina a francouzstina - vyslovnost if (de.pronText != null && (de.crsLang == Langs.en_gb && de.natLang != Langs.fr_fr || de.natLang == Langs.en_gb && de.crsLang != Langs.fr_fr)) { if (de.okCrs == Langs.no) { de.okCrs = Langs.en_gb; de.okCrsReason = OKCrsReason.pronunc; } else if (de.okCrs != Langs.en_gb) //errors.Add(de); throw new Exception(); } if (de.pronText != null && (de.crsLang == Langs.fr_fr && de.natLang != Langs.en_gb || de.natLang == Langs.fr_fr && de.crsLang != Langs.en_gb)) { if (de.okCrs == Langs.no) { de.okCrs = Langs.fr_fr; de.okCrsReason = OKCrsReason.pronunc; } else if (de.okCrs != Langs.fr_fr) //errors.Add(de); throw new Exception(); } //rustina if (de.crsLang == Langs.ru_ru || de.natLang == Langs.ru_ru) { Func<string[], bool> isRussian = words => words.SelectMany(w => w.ToCharArray()).Intersect(russianAlphabet).Any(); var natIsRussian = isRussian(de.wordStats.natWords); var crsIsRussian = isRussian(de.wordStats.crsWords); Langs crsLng; Langs notRuLang = de.crsLang == Langs.ru_ru ? de.natLang : de.crsLang; if (natIsRussian && !crsIsRussian) { crsLng = notRuLang; } else if (crsIsRussian && !natIsRussian) { crsLng = Langs.ru_ru; } else crsLng = Langs.no; ; if (crsLng != Langs.no) if (de.okCrs == Langs.no) { ru++; de.okCrs = crsLng; de.okCrsReason = OKCrsReason.russian; } else if (de.okCrs != crsLng) //errors.Add(de); throw new Exception(); } //v en_gb, fr_fr x sp_sp : okCrs neni en_gb iff existuje <span class="morf"> nf nebo nm bool isFr = !de.bothLangs().Except(XExtension.Create(Langs.en_gb, Langs.fr_fr)).Any(); bool isSp = !de.bothLangs().Except(XExtension.Create(Langs.en_gb, Langs.sp_sp)).Any(); if (isFr || isSp) { if (de.entry.DescendantsAttr("class", "morf").Any(el => new string[] { "nm", "nf" }.Contains(el.Value.Trim()))) { Langs lng = isFr ? Langs.fr_fr : Langs.sp_sp; if (de.okCrs == Langs.no) { morf1++; de.okCrs = lng; de.okCrsReason = OKCrsReason.morf_nm_nf; } else if (de.okCrs != lng) { morf1Err++; //1 chyba, soufflé //errors.Add(de); //throw new Exception(); } } } //v en_gb, de_de x it_it : okCrs neni en_gb iff existuje <span class="morf"> m pl | m | f pl | f bool isDe = !de.bothLangs().Except(XExtension.Create(Langs.en_gb, Langs.de_de)).Any(); bool isIt = !de.bothLangs().Except(XExtension.Create(Langs.en_gb, Langs.it_it)).Any(); if (isDe || isDe) { if (de.entry.DescendantsAttr("class", "morf").Any(el => new string[] { "m pl", "m", "f pl", "f" }.Contains(el.Value.Trim()))) { Langs lng = isDe ? Langs.de_de : Langs.it_it; if (de.okCrs == Langs.no) { morf2++; de.okCrs = lng; de.okCrsReason = OKCrsReason.morf_m_pl_f; } else if (de.okCrs != lng) throw new Exception(); } } if (de.crsLang != Langs.ru_ru && de.natLang != Langs.ru_ru && DictLib.crsLangs.Contains(de.crsLang) && !DictLib.crsLangs.Contains(de.natLang)) { Func<string[], bool> notWin1252 = words => words.SelectMany(w => w.ToCharArray()).Where(ch => char.IsLetter(ch)).Except(win1252).Any(); var natNotWin1252 = notWin1252(de.wordStats.natWords); var crsNotWin1252 = notWin1252(de.wordStats.crsWords); if (natNotWin1252 != crsNotWin1252) { Langs crsLng; if (natNotWin1252 && !crsNotWin1252) crsLng = de.crsLang; else if (crsNotWin1252 && !natNotWin1252) { //šř v crsLng = de.natLang; } else throw new Exception(); if (de.okCrs == Langs.no) { cwin1252++; de.okCrs = crsLng; de.okCrsReason = OKCrsReason.charsOK; } else if (de.okCrs != crsLng) throw new Exception(); } //cwin1252Err++; } } if (morf1Err > 1) throw new Exception(); //***************** grupy dle vyslovnosti Langs[] enfr = new Langs[] { Langs.en_gb, Langs.fr_fr }; Dictionary<string, Langs> pronToLang = new Dictionary<string, Langs>(); foreach (var entr in dictEntries.Where(de => de.pronText != null).GroupBy(de => de.wordId())) { pronToLang.Clear(); foreach (var pronGrp in entr.GroupBy(de => de.pronText).Where(g => g.Count() > 1)) { foreach (var de in pronGrp) { var otherLang = de.bothLangs().Except(enfr).FirstOrDefault(); if (otherLang == Langs.no) continue; pronToLang[de.pronText] = de.crsLang == otherLang ? de.natLang : de.crsLang; }; } if (pronToLang.Count() < 2) continue; foreach (var de in entr) { Langs pronl; if (!pronToLang.TryGetValue(de.pronText, out pronl)) { if (de.bothLangs().Intersect(enfr).Count() == 2) pronl = pronToLang.First().Value == Langs.en_gb ? Langs.fr_fr : Langs.en_gb; else continue; } if (de.okCrs == Langs.no) { de.okCrs = pronl; de.okCrsReason = OKCrsReason.viaPronunciation; } else if (de.okCrs != pronl) throw new Exception(); } } //******************* rucne upravena slovicka Dictionary<string, Admin.ByHand> hands = new Dictionary<string, Admin.ByHand>(); var files = Directory.EnumerateFiles(@"d:\LMCom\rew\Web4\RwDicts\Sources\LingeaOld\design", "byHand_*.xml"); foreach (var fn in files) foreach (var h in XmlUtils.FileToObject<List<Admin.ByHand>>(fn)) hands.Add(h.id(), h); //var hands = Directory.EnumerateFiles(@"d:\LMCom\rew\Web4\RwDicts\Sources\LingeaOld\design", "byHand_*.xml").SelectMany(fn => XmlUtils.FileToObject<List<Admin.ByHand>>(fn)).ToDictionary(cr => cr.email(), cr => cr); foreach (var de in dictEntries.Where(de => de.okCrs == Langs.no && hands.ContainsKey(de.id()))) { de.okCrs = hands[de.id()].okCrs; de.okCrsReason = OKCrsReason.byHand; } //******************* zdroj spravnych slov jsou doposud oznacena slova v Lingea slovniku. Pro dany slovnik se udela rozdil spravnych slov. var allLangs = dictEntries.Where(de => de.okCrs != Langs.no).SelectMany(de => de.bothLangs()).Distinct().ToArray(); Func<DictEntry, Langs, IEnumerable<string>> getWords = (de, l) => de.okCrs == l ? de.wordStats.crsWords : de.wordStats.natWords; var sources = allLangs.ToDictionary( l => l, l => dictEntries.Where(de => de.okCrs != Langs.no && de.bothLangs().Contains(l)).SelectMany(de => getWords(de, l)).Distinct().ToArray() ); Dictionary<Langs, Dictionary<Langs, Dictionary<string, bool>>> diffWordsTab = allLangs.ToDictionary(myLang => myLang, myLang => allLangs.Where(nl => nl != myLang).ToDictionary(otherLang => otherLang, otherLang => { try { var ml = sources[myLang]; var ol = sources[otherLang]; return ml.Except(ol).ToDictionary(w => w, w => true); } catch { return new Dictionary<string, bool>(); } })); Func<Langs, Langs, Dictionary<string, bool>> diffWords = (myLang, otherLang) => { return diffWordsTab.ContainsKey(myLang) && diffWordsTab[myLang].ContainsKey(otherLang) ? diffWordsTab[myLang][otherLang] : null; }; //foreach (var de in dictEntries.Where(de => de.wordId() == "cofounder").Where(de => de.okCrs == Langs.no && de.crsLang != Langs.ru_ru && !CourseDictionary.crsLangs.Contains(de.natLang))) { foreach (var de in dictEntries.Where(de => de.okCrs == Langs.no && de.crsLang != Langs.ru_ru && !DictLib.crsLangs.Contains(de.natLang))) { var crsOkW = diffWords(de.crsLang, de.natLang); var natOkW = diffWords(de.natLang, de.crsLang); if (crsOkW == null || natOkW == null) continue; var isCrs = de.wordStats.crsWords.Where(w => crsOkW.ContainsKey(w)).Any() || de.wordStats.natWords.Where(w => natOkW.ContainsKey(w)).Any(); var isNat = de.wordStats.natWords.Where(w => crsOkW.ContainsKey(w)).Any() || de.wordStats.crsWords.Where(w => natOkW.ContainsKey(w)).Any(); if (isCrs == isNat) continue; var lng = isCrs ? de.crsLang : de.natLang; if (de.okCrs == Langs.no) { de.okCrs = lng; de.okCrsReason = OKCrsReason.wordsOK; } else if (de.okCrs != lng) throw new Exception(); } //*********************** SOUND by hand var soundHands = XmlUtils.FileToObject<DictEntry[]>(@"d:\LMCom\rew\Web4\RwDicts\Sources\LingeaOld\design\entriesSoundByHand.xml").ToDictionary(de => de.entryId, de => de); foreach (var de in dictEntries) { DictEntry sh; if (!soundHands.TryGetValue(de.entryId, out sh)) continue; de.soundMaster = sh.soundMaster; } //oprava nekolika hesel v kodu, kvuli soundMaster: foreach (var en in dictEntries) { //.SelectMany(d => d.entries)) { switch (en.soundMaster) { case "en_gb/aenge3225654": en.headWords = new string[] { "crackdown" }; en.entry.DescendantsAttr("class", "entr").First().Value = "crackdown"; break; case "de_de/aenge68bb654": en.soundMaster = null; break; case "en_gb/aenbg23cb736": en.headWords = new string[] { "checkout" }; en.entry.DescendantsAttr("class", "entr").First().Value = "checkout"; break; case "de_de/aenge800026b4654": if (en.headWords[0] != "einig") en.soundMaster = null; break; case "de_de/aenge80006d5a654": if (en.headWords[0] != "niedrig") en.soundMaster = null; break; case "it_it/ageit7675661": if (en.entryId == "fr_fr|de_de|porto") en.soundMaster = null; break; //case "it_it/aspit7b9e663": if (en.entryId == "en_gb|sp_sp|sereno") en.soundMaster = null; break; case "it_it/aspit7b9e663": en.soundMaster = null; break; case "it_it/aspite03663": if (en.entryId == "de_de|sp_sp|atar") en.soundMaster = null; break; case "en_gb/afren193c659": en.soundMaster = "en_gb/aenbg190c736"; break; case "fr_fr/afrvn9d1c688": en.soundMaster = "it_it/afrit9d1d662"; break; case "fr_fr/afrvna71c688": en.soundMaster = "fr_fr/afrcza71d669"; break; case "fr_fr/afrvnc0ea688": en.soundMaster = "fr_fr/afrczc0eb669"; break; //case "it_it/aspit7b9e663": en.soundMaster = "it_it/aenit8000f16c660"; break; case "sp_sp/asplt7692724": en.soundMaster = "sp_sp/aensp80007692656"; break; } } //k jednomu Headword jeden zvuk Dictionary<Langs, Dictionary<string, string>> headwordToSoundMaster = dictEntries.Where(de => de.soundMaster != null).GroupBy(de => de.okCrs).ToDictionary( g => g.Key, g => g.GroupBy(de => de.headWords[0].ToLower()).ToDictionary( sg => sg.Key, sg => sg.Select(d => d.soundMaster).Distinct().Single())); //dopln soundMaster do entries var cnt = dictEntries.Where(en => en.soundMaster == null).Count(); foreach (var de in dictEntries.Where(en => en.soundMaster == null && DictLib.crsLangs.Contains(en.okCrs))) { string sm; if (!headwordToSoundMaster[de.okCrs].TryGetValue(de.headWords[0].ToLower(), out sm)) continue; de.soundMaster = sm; } cnt = dictEntries.Where(en => en.soundMaster == null).Count(); //vypis word lists //var sourcesAfter = allLangs.ToDictionary( // l => l, // l => dictEntries.Where(de => de.okCrs != Langs.no).Where(de => de.bothLangs().Contains(l)).SelectMany(de => getWords(de, l)).Distinct().ToArray() //); //foreach (var src in sourcesAfter) File.WriteAllLines(string.Format(@"d:\LMCom\rew\Web4\RwDicts\Sources\LingeaOld\design\wordList_{0}.txt", src.Key), src.Value.OrderBy(w => w)); }
public OrderPreservingDictionary() { //Synthetic tail and head of the linked ease to reduce the number of boundary conditions checks _head = new DictEntry <TM, T>(default, default, null, null);
private void BtnSearchClick(object sender, EventArgs e) { if (FileManager.AttribTree == null) { UIHelper.ShowError("The attrib-tree could not be found! Ensure that there is a mod loaded"); return; } m_selectedItem = null; m_chklbxEntries.Items.Clear(); m_progBarSearch.Value = 1; m_progBarSearch.Step = 1; m_progBarSearch.Minimum = 1; m_progBarSearch.Maximum = FileManager.AttribTree.RootNode.GetTotalFileCount(); m_btnSearch.Enabled = false; m_results = new Dictionary<string, DictEntry>(); m_crawler = new RBFCrawler(Search, FileManager.AttribTree.RootNode, AdvanceProgress); m_crawler.OnFinished += CrawlerOnFinished; m_crawler.Start(); }
protected static FR_L6LG_GDfDLR_1634 Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6LG_GDfDLR_1634(); returnValue.Result = new L6LG_GDfDLR_1634(); var languages = cls_Get_All_Languages_ForTenantID.Invoke(Connection, Transaction, new P_L2LN_GALFTID_1530() { Tenant_RefID = securityTicket.TenantID }, securityTicket).Result; var account = cls_Get_DisplayName_of_Account.Invoke(Connection, Transaction, securityTicket).Result; List <L6LG_GDfDLR_1634a> returnList = new List <L6LG_GDfDLR_1634a>(); var produtDemandAndSupplyQuantityList = cls_Get_Product_Demand_and_Supply_Quantity.Invoke(Connection, Transaction, securityTicket).Result; List <Guid> productIdList = produtDemandAndSupplyQuantityList.Select(p => p.ProductID).Distinct().ToList(); L3AR_GAfAL_0942[] articlesForArticleList = new L3AR_GAfAL_0942[0]; if (productIdList != null && productIdList.Count > 0) { P_L3AR_GAfAL_0942 articlesForArticleListParameter = new P_L3AR_GAfAL_0942(); articlesForArticleListParameter.ProductID_List = productIdList.ToArray(); FR_L3AR_GAfAL_0942_Array articlesForArticleListResult = cls_Get_Articles_for_ArticleList.Invoke(Connection, Transaction, articlesForArticleListParameter, securityTicket); articlesForArticleList = articlesForArticleListResult.Result; } foreach (L6LG_GPDaSQ_1636 productDemandAndSupplyQuantity in produtDemandAndSupplyQuantityList) { L3AR_GAfAL_0942 article = articlesForArticleList.FirstOrDefault(a => a.CMN_PRO_ProductID == productDemandAndSupplyQuantity.ProductID); if (article == null) { continue; } L6LG_GDfDLR_1634a product = new L6LG_GDfDLR_1634a(); product.ProductID = article.CMN_PRO_ProductID; product.DossageFormName = article.DossageFormName; product.ProducerName = article.ProducerName; product.Product_Name = new Dictionary <string, string>(); foreach (L2LN_GALFTID_1530 lang in languages) { string iso = lang.ISO_639_1; string content = ""; if (article.Product_Name != null && article.Product_Name.Contents != null) { DictEntry dicEntry = article.Product_Name.Contents.FirstOrDefault(c => c.LanguageID == lang.CMN_LanguageID); if (dicEntry != null) { content = dicEntry.Content; } } product.Product_Name.Add(iso, content); } product.Product_Number = article.Product_Number; product.UnitAmount = article.UnitAmount; product.UnitIsoCode = article.UnitIsoCode; product.DemandQuantity = productDemandAndSupplyQuantity.DemandQuantity; product.SupplyQuantity = productDemandAndSupplyQuantity.SupplyQuantity; product.ToBeOrderedQuantity = productDemandAndSupplyQuantity.DemandQuantity - productDemandAndSupplyQuantity.SupplyQuantity; returnList.Add(product); } returnValue.Result.Products = returnList.ToArray(); returnValue.Result.Account = account; return(returnValue); #endregion UserCode }
public virtual void AddContent(string key, object obj) { RemoveContent(key); content.Add(DictEntry.Root(key, new DictItem(obj))); }
private static CharArrayMap<DictEntry> initializeDictHash() { DictEntry defaultEntry; DictEntry entry; CharArrayMap<DictEntry> d = new CharArrayMap<DictEntry>(Version.LUCENE_CURRENT, 1000, false); for (int i = 0; i < exceptionWords.Length; i++) { if (!d.containsKey(exceptionWords[i])) { entry = new DictEntry(exceptionWords[i], true); d.put(exceptionWords[i], entry); } else { throw new Exception("Warning: Entry [" + exceptionWords[i] + "] already in dictionary 1"); } } for (int i = 0; i < directConflations.Length; i++) { if (!d.containsKey(directConflations[i][0])) { entry = new DictEntry(directConflations[i][1], false); d.put(directConflations[i][0], entry); } else { throw new Exception("Warning: Entry [" + directConflations[i][0] + "] already in dictionary 2"); } } for (int i = 0; i < countryNationality.Length; i++) { if (!d.containsKey(countryNationality[i][0])) { entry = new DictEntry(countryNationality[i][1], false); d.put(countryNationality[i][0], entry); } else { throw new Exception("Warning: Entry [" + countryNationality[i][0] + "] already in dictionary 3"); } } defaultEntry = new DictEntry(null, false); string[] array; array = KStemData1.data; for (int i = 0; i < array.Length; i++) { if (!d.containsKey(array[i])) { d.put(array[i], defaultEntry); } else { throw new Exception("Warning: Entry [" + array[i] + "] already in dictionary 4"); } } array = KStemData2.data; for (int i = 0; i < array.Length; i++) { if (!d.containsKey(array[i])) { d.put(array[i], defaultEntry); } else { throw new Exception("Warning: Entry [" + array[i] + "] already in dictionary 4"); } } array = KStemData3.data; for (int i = 0; i < array.Length; i++) { if (!d.containsKey(array[i])) { d.put(array[i], defaultEntry); } else { throw new Exception("Warning: Entry [" + array[i] + "] already in dictionary 4"); } } array = KStemData4.data; for (int i = 0; i < array.Length; i++) { if (!d.containsKey(array[i])) { d.put(array[i], defaultEntry); } else { throw new Exception("Warning: Entry [" + array[i] + "] already in dictionary 4"); } } array = KStemData5.data; for (int i = 0; i < array.Length; i++) { if (!d.containsKey(array[i])) { d.put(array[i], defaultEntry); } else { throw new Exception("Warning: Entry [" + array[i] + "] already in dictionary 4"); } } array = KStemData6.data; for (int i = 0; i < array.Length; i++) { if (!d.containsKey(array[i])) { d.put(array[i], defaultEntry); } else { throw new Exception("Warning: Entry [" + array[i] + "] already in dictionary 4"); } } array = KStemData7.data; for (int i = 0; i < array.Length; i++) { if (!d.containsKey(array[i])) { d.put(array[i], defaultEntry); } else { throw new Exception("Warning: Entry [" + array[i] + "] already in dictionary 4"); } } for (int i = 0; i < KStemData8.data.Length; i++) { if (!d.containsKey(KStemData8.data[i])) { d.put(KStemData8.data[i], defaultEntry); } else { throw new Exception("Warning: Entry [" + KStemData8.data[i] + "] already in dictionary 4"); } } for (int i = 0; i < supplementDict.Length; i++) { if (!d.containsKey(supplementDict[i])) { d.put(supplementDict[i], defaultEntry); } else { throw new Exception("Warning: Entry [" + supplementDict[i] + "] already in dictionary 5"); } } for (int i = 0; i < properNouns.Length; i++) { if (!d.containsKey(properNouns[i])) { d.put(properNouns[i], defaultEntry); } else { throw new Exception("Warning: Entry [" + properNouns[i] + "] already in dictionary 6"); } } return d; }
private bool Lookup() { /// <summary> ///**** /// debugging code String thisLookup = word.toString(); boolean added = /// lookups.add(thisLookup); if (!added) { /// System.out.println("######extra lookup:" + thisLookup); // occaasional /// extra lookups aren't necessarily errors... could happen by diff /// manipulations // throw new RuntimeException("######extra lookup:" + /// thisLookup); } else { // System.out.println("new lookup:" + thisLookup); /// } /// ***** /// </summary> matchedEntry = dict_ht.Get(word.Array, 0, word.Size()); return matchedEntry != null; }
/// <summary> /// Stems the text in the token. Returns true if changed. /// </summary> internal virtual bool Stem(char[] term, int len) { result = null; k = len - 1; if ((k <= 1) || (k >= MaxWordLen - 1)) { return false; // don't stem } // first check the stemmer dictionaries, and avoid using the // cache if it's in there. DictEntry entry = dict_ht.Get(term, 0, len); if (entry != null) { if (entry.root != null) { result = entry.root; return true; } return false; } /// <summary> ///* /// caching off is normally faster if (cache == null) initializeStemHash(); /// /// // now check the cache, before we copy chars to "word" if (cache != null) /// { String val = cache.get(term, 0, len); if (val != null) { if (val != /// SAME) { result = val; return true; } return false; } } /// ** /// </summary> word.Reset(); // allocate enough space so that an expansion is never needed word.Reserve(len + 10); for (int i = 0; i < len; i++) { char ch = term[i]; if (!IsAlpha(ch)) // don't stem { return false; } // don't lowercase... it's a requirement that lowercase filter be // used before this stemmer. word.UnsafeWrite(ch); } matchedEntry = null; /// <summary> ///* /// lookups.clear(); lookups.add(word.toString()); /// ** /// </summary> /* * This while loop will never be executed more than one time; it is here * only to allow the break statement to be used to escape as soon as a word * is recognized */ while (true) { // YCS: extra lookup()s were inserted so we don't need to // do an extra wordInDict() here. Plural(); if (Matched) { break; } PastTense(); if (Matched) { break; } Aspect(); if (Matched) { break; } ItyEndings(); if (Matched) { break; } NessEndings(); if (Matched) { break; } IonEndings(); if (Matched) { break; } ErAndOrEndings(); if (Matched) { break; } lyEndings(); if (Matched) { break; } AlEndings(); if (Matched) { break; } entry = WordInDict(); IveEndings(); if (Matched) { break; } IzeEndings(); if (Matched) { break; } MentEndings(); if (Matched) { break; } BleEndings(); if (Matched) { break; } IsmEndings(); if (Matched) { break; } IcEndings(); if (Matched) { break; } NcyEndings(); if (Matched) { break; } NceEndings(); bool foo = Matched; break; } /* * try for a direct mapping (allows for cases like `Italian'->`Italy' and * `Italians'->`Italy') */ entry = matchedEntry; if (entry != null) { result = entry.root; // may be null, which means that "word" is the stem } /// <summary> ///* /// caching off is normally faster if (cache != null && cache.size() < /// maxCacheSize) { char[] key = new char[len]; System.arraycopy(term, 0, /// key, 0, len); if (result != null) { cache.put(key, result); } else { /// cache.put(key, word.toString()); } } /// ** /// </summary> /// <summary> ///* /// if (entry == null) { if (!word.toString().equals(new String(term,0,len))) /// { System.out.println("CASE:" + word.toString() + "," + new /// String(term,0,len)); /// /// } } /// ** /// </summary> // no entry matched means result is "word" return true; }
public virtual void AddContent(DictEntry entry) { RemoveContent(entry.Key); content.Add(entry); }
private void EntriesSelectedIndexChanged(object sender, EventArgs e) { if (m_selectedItem != null) { m_selectedItem.Options.Clear(); m_selectedItem.Options.AddRange(m_rtbResultDisplay.Lines); } if (m_chklbxEntries.SelectedIndex == -1) return; var entry = m_chklbxEntries.SelectedItem as DictEntry; m_rtbResultDisplay.Lines = entry.Options.ToArray(); m_selectedItem = entry; }
/// <summary> /// /// </summary> protected override void CreateChildControls() { Controls.Clear(); ClientScriptManager csm = Page.ClientScript; //--------------------current language---------------------------------- //--dl if (IsLarge) { Controls.Add(new LiteralControl("<dl class='language lang_primar lang_description'>")); } else { Controls.Add(new LiteralControl("<dl class='language lang_primar lang_name_class'>")); } //--dt string jsStr = CANCEL_BUBBLE + @csm.GetPostBackEventReference(this, "ToggleLanguages"); Controls.Add(new LiteralControl("<dt onclick=\"" + jsStr + ";\">")); //current flag string currentFlagSrc = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), String.Format(FLAG_RESOURCE_ROOT, "noimage")); if (CurrentLanguage != null) { currentFlagSrc = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), String.Format(FLAG_RESOURCE_ROOT, CurrentLanguage.Code.ToLower())); } Controls.Add(new LiteralControl("<img src=" + currentFlagSrc + ">")); Controls.Add(new LiteralControl("</img>")); //arrow string arrowSrc = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), "DictTextBox.Images.arrow_down.png"); if (LanguagesShown) { this.Page.ClientScript.GetWebResourceUrl(this.GetType(), "DictTextBox.Images.arrow_up.png"); } Controls.Add(new LiteralControl("<img src=" + arrowSrc + ">")); Controls.Add(new LiteralControl("</img>")); //--dd Controls.Add(new LiteralControl("<dd>")); //textbox textBox = new TextBox(); textBox.ID = "TextBox"; textBox.Text = this.Text; if (CurrentLanguage != null) { textBox.Attributes["CurrentLanguageID"] = CurrentLanguage.ID.ToString(); } textBox.Attributes["onfocus"] = "focusOnDictTextBox(this);"; //js events string keyEvent = ""; if (!this.IgnoreEnterForPostback) { keyEvent += @"if (event.keyCode==13 && !event.shiftKey) {" + csm.GetPostBackEventReference(this, "ConfirmChanges") + @"}"; } if (!this.IgnoreTabForPostback) { keyEvent += @"if (event.keyCode == 9 && !event.shiftKey){" + csm.GetPostBackEventReference(this, "ProcessTab") + @"}"; } if (!this.IgnoreCancelForPostback) { keyEvent += @"if (event.keyCode == 27){" + csm.GetPostBackEventReference(this, "CancelChanges") + @"}"; } if (keyEvent != "") { textBox.Attributes["onkeydown"] = CANCEL_BUBBLE + keyEvent; } //textBox.Attributes["onkeydown"] = CANCEL_BUBBLE + @"if (event.keyCode==13 && !event.shiftKey) {" + csm.GetPostBackEventReference(this, "ConfirmChanges") + @"} if (event.keyCode == 9 && !event.shiftKey){" + csm.GetPostBackEventReference(this, "ProcessTab") + @"} if (event.keyCode == 27){" + csm.GetPostBackEventReference(this, "CancelChanges") + "}"; if (IsLarge) { textBox.TextMode = TextBoxMode.MultiLine; } else { textBox.CssClass = "inline-edit-input"; textBox.TextMode = TextBoxMode.SingleLine; } textBox.CssClass += " " + this.TextBoxCssClass; Controls.Add(textBox); //--dd end Controls.Add(new LiteralControl("</dd>")); //--dt end Controls.Add(new LiteralControl("</dt>")); //--dl end Controls.Add(new LiteralControl("</dl>")); //---------------- current language end------------------------------------ //---------------- all languages ------------------------------------------ string languagesStyleAttr = "style='display:block;'"; if (!LanguagesShown) { languagesStyleAttr = "style='display:none;'"; } string languagesClassAttr = "class='language lagn_choices'"; if (IsLarge) { languagesClassAttr = "class='language lagn_desc_choices'"; } //-- ul Controls.Add(new LiteralControl("<ul " + languagesClassAttr + " " + languagesStyleAttr + ">")); foreach (var language in Languages) { //--li jsStr = CANCEL_BUBBLE + @csm.GetPostBackEventReference(this, "SwitchLanguage$" + language.ID); Controls.Add(new LiteralControl("<li onclick=\"" + jsStr + "\">")); //--dl Controls.Add(new LiteralControl("<dl>")); //--dt Controls.Add(new LiteralControl("<dt>")); DictEntry entry = null; if (Content != null && Content.Contents != null) { entry = Content.Contents.FirstOrDefault(e => e.LanguageID == language.ID); } Controls.Add(new LiteralControl("<img src=" + this.Page.ClientScript.GetWebResourceUrl(this.GetType(), String.Format(FLAG_RESOURCE_ROOT, language.Code.ToLower())) + ">")); Controls.Add(new LiteralControl("</img>")); Controls.Add(new LiteralControl("<span>" + language.Name + "</span>")); /*.Attributes["CurrentLanguageID"] = CurrentLanguage.ID.ToString();*/ Controls.Add(new LiteralControl("<dd languageID=\"" + language.ID + "\">")); if (entry != null) { Controls.Add(new LiteralControl(entry.Content)); } Controls.Add(new LiteralControl("</dd>")); //--dt end Controls.Add(new LiteralControl("</dt>")); //--dl end Controls.Add(new LiteralControl("</dl>")); //--li end Controls.Add(new LiteralControl("</li>")); } //--ul end Controls.Add(new LiteralControl("</ul>")); if (IsTextBoxFocused) { Page.SetFocus(textBox); } }
public FvSolution(Solution solution) { _solvers = DictEntry.Root("solvers"); _relaxation = new RelaxationFactors(); _solution = solution; }
public RelaxationFactors() { fields = this.NewChild("fields"); equations = this.NewChild("equations"); this.Key = "relaxationFactors"; }