public static HyperComponents.WebUI.CustomSpellChecker.SpellChecker GetSpellChecker() { HyperComponents.WebUI.CustomSpellChecker.SpellChecker c = new HyperComponents.WebUI.CustomSpellChecker.SpellChecker(); c.SetUserDictionary(SessionState.CacheParams["DictionarySpecificPath"].Value.ToString()); c.AllowWordsWithDigits = true; c.SetIncludeUserDictionaryInSuggestions(true); c.AllowXML = true; c.SetAllowCapitalizedWords(true); c.SetConsiderationRange(80); return(c); }
public static int TextHasErrors(ref HyperComponents.WebUI.CustomSpellChecker.SpellChecker c, string v) { System.Collections.Specialized.StringCollection badWords = new System.Collections.Specialized.StringCollection(); BadWord badWord = null; badWords.Clear(); //check some text. c.Check(v); int nbErrors = 0; //iterate through all bad words in the text. while ((badWord = c.NextBadWord()) != null) { if (badWords.IndexOf(badWord.Word) < 0) { //Trace.Warn(" -> " + badWord.Word + " - " + badWord.Reason.ToString()); nbErrors++; badWords.Add(badWord.Word); } } return(nbErrors); }
private void Analyze() { dg.Visible = false; lbResult.Visible = false; lbError.Visible = false; if (item != null) { try { DataSet ds = item.GetContent(culture.Code, inputformId, cbWithChildren.Checked); if (ds != null) { if (ds.Tables != null && ds.Tables[0].Rows.Count > 0) { // Add column containing the count of error ds.Tables[0].Columns.Add("Error", Type.GetType("System.String")); try { HyperComponents.WebUI.CustomSpellChecker.SpellChecker c = UITools.GetSpellChecker(); #region debugging /* Trace.Warn("c.AllowCaseInsensitiveSuggestions =" + c.AllowCaseInsensitiveSuggestions.ToString()); * Trace.Warn("c.AllowMixedCase =" + c.AllowMixedCase.ToString()); * Trace.Warn("c.AllowWordsWithDigits =" + c.AllowWordsWithDigits.ToString()); * Trace.Warn("c.AllowXML =" + c.AllowXML.ToString()); * Trace.Warn("c.CheckHyphenatedText =" + c.CheckHyphenatedText.ToString()); * Trace.Warn("c.SetIncludeUserDictionaryInSuggestions= " + c.GetIncludeUserDictionaryInSuggestions().ToString()); * Trace.Warn("c.LanguageParser" + c.LanguageParser.ToString()); * Trace.Warn("c.SetAllowCapitalizedWords = " + c.GetAllowCapitalizedWords().ToString()); * Trace.Warn("c.CheckCompoundWords =" + c.CheckCompoundWords.ToString()); * Trace.Warn("c.SetConsiderationRange=" + c.GetConsiderationRange().ToString()); * Trace.Warn("c.SplitWordThreshold = " + c.SplitWordThreshold.ToString()); * Trace.Warn("c.SuggestSplitWords = " + c.SuggestSplitWords.ToString()); * Trace.Warn("c.SetSeparateHyphenWords=" + c.GetSeparateHyphenWords().ToString()); * Trace.Warn("c.SetSuggestionsMethod=" + c.GetSuggestionsMethod().ToString()); * Trace.Warn("c.userDictionary.dictFile=" + c.userDictionary.dictFile); */ /* * c.AllowCaseInsensitiveSuggestions = true; * c.AllowMixedCase = false; * c.AllowWordsWithDigits = true; * c.AllowXML = true; * c.CheckHyphenatedText = true; * c.SetIncludeUserDictionaryInSuggestions(true); * c.LanguageParser = LanguageType.English; * c.SetAllowCapitalizedWords(true); * c.CheckCompoundWords = false; * c.SetConsiderationRange(-1); * c.SplitWordThreshold = 3; * c.SuggestSplitWords = true; * c.SetSeparateHyphenWords(false);*/ #endregion foreach (DataRow dr in ds.Tables[0].Rows) { //spellTest.HasErrors(dr["ChunkValue"].ToString(), true); Trace.Warn(dr["ChunkValue"].ToString()); dr["Error"] = UITools.TextHasErrors(ref c, dr["ChunkValue"].ToString()); } dg.DataSource = ds.Tables[0].DefaultView; Utils.InitGridSort(ref dg, true); dg.DataBind(); dg.DisplayLayout.AllowSortingDefault = Infragistics.WebUI.UltraWebGrid.AllowSorting.No; InitializeGridGrouping(); //dg.DisplayLayout.Pager.AllowPaging = true; if (dg.Rows.Count > 0) { dg.Visible = true; lbResult.Visible = false; } else { dg.Visible = false; lbResult.Text = "No errors found."; lbResult.Visible = true; } } catch (Exception e) { lbError.CssClass = "hc_error"; lbError.Text = e.ToString(); lbError.Visible = true; } finally { if (ds != null) { ds.Dispose(); } } } else // chunks count equals 0 { lbResult.Visible = true; if (ds != null) { ds.Dispose(); } } } else // ds is null { lbError.CssClass = "hc_error"; lbError.Text = "DataSet is null"; lbError.Visible = true; } } catch (DataException de) { lbError.CssClass = "hc_error"; lbError.Text = de.ToString(); lbError.Visible = true; } } }