/// <summary> /// Recursive search for right ss - sharp s permutations /// </summary> private WordEntry SpellSharps(ref string @base, int nPos, int n, int repNum, ref SpellCheckResultType info, out string root) { var pos = @base.IndexOfOrdinal("ss", nPos); if (pos >= 0 && n < MaxSharps) { var baseBuilder = StringBuilderPool.Get(@base, @base.Length); baseBuilder[pos] = 'ß'; baseBuilder.Remove(pos + 1, 1); @base = baseBuilder.ToString(); var h = SpellSharps(ref @base, pos + 1, n + 1, repNum + 1, ref info, out root); if (h != null) { return(h); } baseBuilder.Clear(); baseBuilder.Append(@base); baseBuilder[pos] = 's'; baseBuilder.Insert(pos + 1, 's'); @base = StringBuilderPool.GetStringAndReturn(baseBuilder); h = SpellSharps(ref @base, pos + 2, n + 1, repNum, ref info, out root); if (h != null) { return(h); } } else if (repNum > 0) { return(CheckWord(@base, ref info, out root)); } root = null; return(null); }
/// <summary> /// Recursive search for right ss - sharp s permutations /// </summary> private WordEntry SpellSharps(ref string @base, ref SpellCheckResultType info, out string root) => SpellSharps(ref @base, 0, 0, 0, ref info, out root);
private WordEntry CheckDetailsInitCap(int abbv, CapitalizationType capType, ref string scw, ref SpellCheckResultType resultType, out string root) { var u8buffer = HunspellTextFunctions.MakeAllSmall(scw, TextInfo); scw = HunspellTextFunctions.MakeInitCap(u8buffer, TextInfo); resultType |= SpellCheckResultType.OrigCap; if (capType == CapitalizationType.Init) { resultType |= SpellCheckResultType.InitCap; } var rv = CheckWord(scw, ref resultType, out root); if (capType == CapitalizationType.Init) { resultType &= ~SpellCheckResultType.InitCap; } // forbid bad capitalization // (for example, ijs -> Ijs instead of IJs in Dutch) // use explicit forms in dic: Ijs/F (F = FORBIDDENWORD flag) if (EnumEx.HasFlag(resultType, SpellCheckResultType.Forbidden)) { rv = null; return(rv); } if (capType == CapitalizationType.All && rv != null && IsKeepCase(rv)) { rv = null; } if (rv != null || (!Affix.CultureUsesDottedI && scw.StartsWith('İ'))) { return(rv); } rv = CheckWord(u8buffer, ref resultType, out root); if (abbv != 0 && rv == null) { u8buffer += "."; rv = CheckWord(u8buffer, ref resultType, out root); if (rv == null) { u8buffer = scw + "."; if (capType == CapitalizationType.Init) { resultType |= SpellCheckResultType.InitCap; } rv = CheckWord(u8buffer, ref resultType, out root); if (capType == CapitalizationType.Init) { resultType &= ~SpellCheckResultType.InitCap; } if (capType == CapitalizationType.All && rv != null && IsKeepCase(rv)) { rv = null; } return(rv); } } if ( rv != null && IsKeepCase(rv) && ( capType == CapitalizationType.All || // if CHECKSHARPS: KEEPCASE words with \xDF are allowed in INITCAP form, too. !(Affix.CheckSharps && u8buffer.Contains('ß')) ) ) { rv = null; } return(rv); }
private WordEntry CheckDetailsAllCap(int abbv, ref string scw, ref SpellCheckResultType resultType, out string root) { resultType |= SpellCheckResultType.OrigCap; var rv = CheckWord(scw, ref resultType, out root); if (rv != null) { return(rv); } if (abbv != 0) { rv = CheckWord(scw + ".", ref resultType, out root); if (rv != null) { return(rv); } } // Spec. prefix handling for Catalan, French, Italian: // prefixes separated by apostrophe (SANT'ELIA -> Sant'+Elia). var textInfo = TextInfo; var apos = scw.IndexOf('\''); if (apos >= 0) { scw = HunspellTextFunctions.MakeAllSmall(scw, textInfo); // conversion may result in string with different len than before MakeAllSmall2 so re-scan if (apos < scw.Length - 1) { scw = StringEx.ConcatString(scw, 0, apos + 1, HunspellTextFunctions.MakeInitCap(scw.Subslice(apos + 1), textInfo)); rv = CheckWord(scw, ref resultType, out root); if (rv != null) { return(rv); } scw = HunspellTextFunctions.MakeInitCap(scw, textInfo); rv = CheckWord(scw, ref resultType, out root); if (rv != null) { return(rv); } } } if (Affix.CheckSharps && scw.Contains("SS")) { scw = HunspellTextFunctions.MakeAllSmall(scw, textInfo); var u8buffer = scw; rv = SpellSharps(ref u8buffer, ref resultType, out root); if (rv == null) { scw = HunspellTextFunctions.MakeInitCap(scw, textInfo); rv = SpellSharps(ref scw, ref resultType, out root); } if (abbv != 0 && rv == null) { u8buffer += "."; rv = SpellSharps(ref u8buffer, ref resultType, out root); if (rv == null) { u8buffer = scw + "."; rv = SpellSharps(ref u8buffer, ref resultType, out root); } } } return(rv); }
public static bool HasFlag(this SpellCheckResultType value, SpellCheckResultType flag) => (value & flag) == flag;
public SpellCheckResult(string root, SpellCheckResultType info, bool correct) { Root = root; Info = info; Correct = correct; }