/// <summary> /// Ctor: annotated Hanzi /// </summary> public OneResultCtrl(string query, CedictAnnotation ann, ICedictEntryProvider prov, UiTones tones, bool isMobile) { this.query = query; this.ann = ann; this.prov = prov; this.tones = tones; this.isMobile = isMobile; }
/// <summary> /// Ctor: annotated Hanzi /// </summary> public EntryRenderer(string lang, string query, CedictAnnotation ann, UiTones tones) { this.lang = lang; this.query = query; this.ann = ann; this.tones = tones; this.hanim = true; this.extraEntryClass = ""; }
/// <summary> /// Ctor: annotated Hanzi /// </summary> public EntryRenderer(string query, CedictAnnotation ann, ICedictEntryProvider prov, UiTones tones) { this.query = query; this.ann = ann; this.prov = prov; this.tones = tones; this.hanim = true; }
private int annotateFrom(MySqlCommand cmdSelBinary10, Dictionary <int, CedictEntry> loadedEntries, byte[] buf, string query, bool simp, int start, int farthestEnd, List <CedictAnnotation> anns) { // Get candidates List <Index.AnnCandidate> cands = index.GetAnnotationCandidates(query, simp, start, farthestEnd); if (cands.Count == 0) { return(-1); } // Try to verify longest candidates, then increasingly shorter ones int cix = 0; for (int length = cands[0].Length; length > 0; --length) { List <int> idList = new List <int>(); while (cix < cands.Count && cands[cix].Length == length) { idList.Add(cands[cix].EntryId); ++cix; } loadMissingEntries(cmdSelBinary10, loadedEntries, buf, idList); SearchScript scr = simp ? SearchScript.Simplified : SearchScript.Traditional; string expected = query.Substring(start, length); bool foundAny = false; foreach (int id in idList) { CedictEntry entry = loadedEntries[id]; string hw = simp ? entry.ChSimpl : entry.ChTrad; if (hw == expected) { CedictAnnotation ann = new CedictAnnotation(id, entry, scr, start, length); anns.Add(ann); foundAny = true; } } if (foundAny) { return(start + length); } } return(-1); }
/// <summary> /// Verifies which candidates really fit query's indicated substring. /// </summary> private List <CedictAnnotation> doVerifyAnns(BinReader br, string query, bool simp, int start, int length, HashSet <int> cands) { List <CedictAnnotation> vers = new List <CedictAnnotation>(); SearchScript scr = simp ? SearchScript.Simplified : SearchScript.Traditional; string expected = query.Substring(start, length); foreach (var ix in cands) { br.Position = ix; CedictEntry entry = new CedictEntry(br); string hw = simp ? entry.ChSimpl : entry.ChTrad; if (hw == expected) { CedictAnnotation ann = new CedictAnnotation(ix, scr, start, length); vers.Add(ann); } } return(vers); }