private void MakeRegexes() { try { Typos.Clear(); TyposCount = 0; TypoGroup bounded = new TypoGroup(20, @"^\\b(.*)\\b$", @"[^\\]\\\d", @"\b", @"\b"); TypoGroup other = new TypoGroup(5, null, @"[^\\]\\\d", "", ""); TypoGroup withBackreferences = new TypoGroup(1, null, null, "", ""); Typos.Add(bounded); Typos.Add(other); Typos.Add(withBackreferences); Dictionary <string, string> typoStrings = LoadTypos(); if (TyposLoaded) { foreach (KeyValuePair <string, string> k in typoStrings) { if (bounded.SuitableTypo(k.Key)) { bounded.Add(k.Key, k.Value); } else if (other.SuitableTypo(k.Key)) { other.Add(k.Key, k.Value); } else { withBackreferences.Add(k.Key, k.Value); } TyposCount++; } foreach (TypoGroup grp in Typos) { grp.MakeGroups(); } } } catch (TypoException) { Typos.Clear(); TyposCount = 0; TyposLoaded = false; } catch (Exception ex) { TyposLoaded = false; ErrorHandler.Handle(ex); } }
private void MakeRegexes() { try { Groups.Clear(); TyposCount = 0; TypoGroup bounded = new TypoGroup(20, @"^\\b(.*)\\b$", @"[^\\]\\\d", @"\b", @"\b"); TypoGroup other = new TypoGroup(5, null, @"[^\\]\\\d", "", ""); TypoGroup withBackreferences = new TypoGroup(1, null, null, "", ""); Groups.Add(bounded); Groups.Add(other); Groups.Add(withBackreferences); Dictionary<string, string> typoStrings = LoadTypos(); if (TyposLoaded) { foreach (KeyValuePair<string, string> k in typoStrings) { if (bounded.SuitableTypo(k.Key)) bounded.Add(k.Key, k.Value); else if (other.SuitableTypo(k.Key)) other.Add(k.Key, k.Value); else withBackreferences.Add(k.Key, k.Value); TyposCount++; } foreach (TypoGroup grp in Groups) grp.MakeGroups(); } } catch (TypoException) { Groups.Clear(); TyposCount = 0; TyposLoaded = false; } catch (Exception ex) { TyposLoaded = false; ErrorHandler.Handle(ex); } finally { if (Complete != null) Complete(); } }