Exemple #1
0
        public void dictForText(Dictionary <string, List <string> > wordForms, CourseMeta.CacheDict res)
        {
            var entries = new Dictionary <string, DictFoundRes>();

            foreach (var wordForm in wordForms)                //kv.key - hledane slovo, kv.Value - hledane slovo + lowercase hledane slovo + seznam zakladnich tvaru slova
            {
                DictEntryObj dictEntry = find(wordForm.Value); //vrat ze vsech kandidatu jedno nalezne entry (dle zvolene strategie)
                if (dictEntry == null)
                {
                    res.notFound.Add(wordForm.Key); continue;
                }                                                                          //nenalezeno => dej mezi nenalezene
                string       key = DictFoundRes.getKey(dictEntry.type, dictEntry.entryId); //nalezeno - klic
                DictFoundRes entry;
                if (!entries.TryGetValue(key, out entry))
                {
                    entries.Add(key, entry = new DictFoundRes {
                        entry = dictEntry
                    });                                                     // najdi dle klice
                    lock (dictEntry) {
                        var snd    = dictEntry.entry.Descendants("sound").FirstOrDefault();
                        var sndVal = snd == null ? null : snd.Value;
                        if (sndVal != null)
                        {
                            if (sndVal.StartsWith("@"))
                            {
                                snd.Remove();
                            }
                            else
                            {
                                res.externals.Add(sndVal);
                            }
                        }
                    }
                }
                entry.words.Add(wordForm.Key);             //pridej ohyb tvar
            }
            res.dict         = createDict(entries.Values); //k nalezenym heslum vytvori slovnik
            res.dict.crsLang = crsData.crsLang; res.dict.natLang = natLang;
        }
Exemple #2
0
        List <ILookup <string, DictEntryObj> > sourcesLower = new List <ILookup <string, DictEntryObj> >(); //tabulka case unsenzitive headword => hesla

        public XElement findEntry(string word, Action <XElement> modifySoundTag = null)
        {
            foreach (var w in crsData.getWordsForms(XExtension.Create(word)))
            {
                DictEntryObj dictEntry = find(w.Value);
                if (dictEntry == null)
                {
                    continue;
                }
                string key = DictFoundRes.getKey(dictEntry.type, dictEntry.entryId);
                var    snd = dictEntry.entry.Descendants("sound").FirstOrDefault();
                if (modifySoundTag != null && snd != null)
                {
                    modifySoundTag(snd);
                }
                else if (snd != null && snd.Value.StartsWith("@"))
                {
                    snd.Remove();
                }
                return(dictEntry.entry);
            }
            return(null);
        }