public async Task Load(string fileName) { Lines.AddRange(await DictionaryFile_Helper.Load(fileName)); var lines = Lines.ToLookup(x => x.SimplifiedChinese).Select(coll => coll.First()).ToList(); FR = new FastReplace(lines.Where(x => x.Enable).OrderByDescending(x => x.SimplifiedChinese_Priority).ThenByDescending(x => x.SimplifiedChinese.Length).ToDictionary(x => x.SimplifiedChinese, x => x.TraditionalChinese)); lines = Lines.ToLookup(x => x.TraditionalChinese).Select(coll => coll.First()).ToList(); FRRevert = new FastReplace(lines.Where(x => x.Enable).OrderByDescending(x => x.TraditionalChinese_Priority).ThenByDescending(x => x.TraditionalChinese.Length).ToDictionary(x => x.TraditionalChinese, x => x.SimplifiedChinese)); }
public void Reload() { var lines = Lines.ToLookup(x => x.SimplifiedChinese).Select(coll => coll.First()).ToList(); FR = new FastReplace(lines.Where(x => x.Enable).OrderByDescending(x => x.SimplifiedChinese_Priority).ThenByDescending(x => x.SimplifiedChinese.Length).ToDictionary(x => x.SimplifiedChinese, x => x.TraditionalChinese)); lines = Lines.ToLookup(x => x.TraditionalChinese).Select(coll => coll.First()).ToList(); FRRevert = new FastReplace(lines.Where(x => x.Enable).OrderByDescending(x => x.TraditionalChinese_Priority).ThenByDescending(x => x.TraditionalChinese.Length).ToDictionary(x => x.TraditionalChinese, x => x.SimplifiedChinese)); ReservedWordTable.Clear(); ReservedWordTable_Revert.Clear(); lines.Where(x => x.Enable).Where(x => x.SimplifiedChinese_Priority == 9999 && x.TraditionalChinese_Priority == 9999 && x.SimplifiedChinese == x.TraditionalChinese).ToList().ForEach(x => InsertTo_ReservedWordTable(x.SimplifiedChinese)); FR_Reserved = new FastReplace(ReservedWordTable); FRRevert_Reserved = new FastReplace(ReservedWordTable_Revert); }
public void ReloadFastReplaceDic() { FR = new FastReplace(_dictionary); FRRevert = new FastReplace(_dictionaryRevert); }