Exemplo n.º 1
0
        public CustomPaintTextBox(TextBoxBase clientTextBox, SpellChecker checker)
        {
            //Set up the CustomPaintTextBox
            this.clientTextBox = clientTextBox;
            this.mySpellChecker = checker;

            //Create a bitmap with the same dimensions as the textbox
            myBitmap = new Bitmap(clientTextBox.Width, clientTextBox.Height);

            //Create the graphics object from this bitmpa...this is where we will draw the lines to start with
            bufferGraphics = Graphics.FromImage(this.myBitmap);
            bufferGraphics.Clip = new Region(clientTextBox.ClientRectangle);

            //Get the graphics object for the textbox.  We use this to draw the bufferGraphics
            textBoxGraphics = Graphics.FromHwnd(clientTextBox.Handle);

            //Assign a handle for this class and set it to the handle for the textbox
            this.AssignHandle(clientTextBox.Handle);

            //We also need to make sure we update the handle if the handle for the textbox changes
            //This occurs if wordWrap is turned off for a RichTextBox
            clientTextBox.HandleCreated += TextBoxBase_HandleCreated;

            //We need to add a handler to change the clip rectangle if the textBox is resized
            clientTextBox.ClientSizeChanged += TextBoxBase_ClientSizeChanged;

            //this.disposedValue = false;
        }
 public FileHeaderInspectionTests()
 {
     var exemptPatterns = new ExemptPatterns();
     exemptPatterns.Add(@"^\d\.\d\.\d{1,5}\.\d$");
     exemptPatterns.Add(@"Runtime");
     var spellChecker = new SpellChecker(exemptPatterns);
     _inspector = new NodeReviewer(new[] { new SingleLineCommentLanguageRule(spellChecker) }, Enumerable.Empty<ISymbolEvaluation>());
 }
Exemplo n.º 3
0
		public static void ApplySpellCheckerCulture(
			SpellChecker spellChecker )
		{
			if ( spellChecker != null )
			{
				spellChecker.Culture = CultureInfo.CurrentUICulture;
			}
		}
Exemplo n.º 4
0
        public void SuggestionsTest()
        {
            var spell = new SpellChecker();

            var examples = spell.Suggestions("manle");

            Assert.IsTrue(examples.Any());
        }
Exemplo n.º 5
0
		public static void ApplySpellCheckerCulture(
			SpellChecker spellChecker,
			string languageCode )
		{
			if ( spellChecker != null )
			{
				spellChecker.Culture = LanguageCodeDetection.MakeValidCulture(languageCode);
			}
		}
Exemplo n.º 6
0
 public void TestSuggests()
 {
     var checker = new SpellChecker();
     var word = "小不列颠";
     var suggests = checker.Suggests(word);
     foreach (var suggest in suggests)
     {
         Console.WriteLine(suggest);
     }
 }
Exemplo n.º 7
0
        public void TestGetEdits1()
        {
            var s = "不列";
            var checker = new SpellChecker();

            var edits1 = checker.GetEdits1(s);
            foreach (var edit in edits1)
            {
                Console.WriteLine(edit);
            }
        }
Exemplo n.º 8
0
        private NamingService(CultureInfo culture)
        {
            this.culture = culture;

            if (StyleCopCore.PlatformID == PlatformID.Win32NT)
            {
                this.spellChecker = SpellChecker.FromCulture(culture);
            }

            this.InitCustomDictionaries();
        }
        public void ApplyTest()
        {
            SpellChecker sc = new SpellChecker ();
            ReplaceWrongChars sa = new ReplaceWrongChars (sc);
            Dictionary<string, SpellSuggestion> suggestedWords = new Dictionary<string, SpellSuggestion> ();

            sa.Apply ("applicotion", suggestedWords, dic);
            Assert.IsTrue (suggestedWords.Count == 1
                && suggestedWords.ContainsKey ("application")
                && suggestedWords["application"].EditDistance == 1);
        }
Exemplo n.º 10
0
        public void MultiSessionTest()
        {
            var spell1 = new SpellChecker("en-us");
            var spell2 = new SpellChecker("fr-fr");

            var examples1 = spell1.Suggestions("doog").ToList();
            spell1.Dispose();
            var examples2 = spell2.Suggestions("doog").ToList();

            Assert.AreEqual(examples1.Count(), 4);
            Assert.AreEqual(examples2.Count(), 2);
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            var spellChecker = new SpellChecker(new EnglishDictionary(), new BloomFilter(), new HashCollectionFactory(new HashFactoryCollection()));

            Console.WriteLine("Enter a sentence to be spell checked: ");
            var inputSentence = Console.ReadLine();

            var words_not_in_dictionary = inputSentence.Split(' ').Where(word => !spellChecker.is_word_in_dictionary(word.ToLowerInvariant()));

            Console.WriteLine("Here are the words you may have misspelled: ");
            words_not_in_dictionary.each(Console.WriteLine);
            Console.ReadLine();
        }
Exemplo n.º 12
0
        public void IgnoreTest()
        {
            var spell = new SpellChecker();

            var examples = spell.Check("codez");

            Assert.IsTrue(examples.Any());

            spell.Ignore("codez");

            examples = spell.Check("codez");

            Assert.AreEqual(examples.Count(), 0);
        }
Exemplo n.º 13
0
        public void ApplyTest()
        {
            SpellChecker sc = new SpellChecker ();
            SwapChars sa = new SwapChars (sc);
            Dictionary<string, SpellSuggestion> suggestedWords = new Dictionary<string, SpellSuggestion> ();

            sa.Apply ("buildinsg", suggestedWords, dic);
            Assert.IsTrue (suggestedWords.Count == 1
                && suggestedWords.ContainsKey ("buildings")
                && suggestedWords["buildings"].EditDistance == 1);

            suggestedWords.Clear ();
            sa.Apply ("zo", suggestedWords, dic);
            Assert.IsTrue (suggestedWords.Count == 1
                && suggestedWords.ContainsKey ("oz")
                && suggestedWords["oz"].EditDistance == 1);
        }
Exemplo n.º 14
0
        public void ApplyTest()
        {
            SpellChecker sc = new SpellChecker ();
            SplitWords sa = new SplitWords (sc);
            Dictionary<string, SpellSuggestion> suggestedWords = new Dictionary<string, SpellSuggestion> ();

            sa.Apply ("gohome", suggestedWords, dic);
            Assert.IsTrue (suggestedWords.Count == 1
                && suggestedWords.ContainsKey ("go home")
                && suggestedWords["go home"].EditDistance == 1);

            suggestedWords.Clear ();
            sa.Apply ("aq", suggestedWords, dic);
            Assert.IsTrue (suggestedWords.Count == 1
                && suggestedWords.ContainsKey ("a q")
                && suggestedWords["a q"].EditDistance == 1);
        }
        public void ApplyTest()
        {
            SpellChecker sc = new SpellChecker ();
            InsertForgottenChar sa = new InsertForgottenChar (sc);
            Dictionary<string, SpellSuggestion> suggestedWords = new Dictionary<string, SpellSuggestion> ();

            sa.Apply ("pplication", suggestedWords, dic);
            Assert.IsTrue (suggestedWords.Count >= 1
                && suggestedWords.ContainsKey ("application")
                && suggestedWords["application"].EditDistance == 1);

            suggestedWords.Clear ();
            sa.Apply ("applicatio", suggestedWords, dic);
            Assert.IsTrue (suggestedWords.Count == 1
                && suggestedWords.ContainsKey ("application")
                && suggestedWords["application"].EditDistance == 1);
        }
Exemplo n.º 16
0
        public void ApplyTest()
        {
            SpellChecker sc = new SpellChecker ();
            ReplacePatterns sa = new ReplacePatterns (sc);
            Dictionary<string, SpellSuggestion> suggestedWords = new Dictionary<string, SpellSuggestion> ();

            sa.Apply ("thare", suggestedWords, dic);
            Assert.IsTrue (suggestedWords.Count == 1
                && suggestedWords.ContainsKey ("their")
                && suggestedWords["their"].EditDistance == 3);

            // check infinite cycles ("i" replaces to "igh")
            suggestedWords.Clear ();
            sa.Apply ("appliceition", suggestedWords, dic);
            Assert.IsTrue (suggestedWords.Count == 1
                && suggestedWords.ContainsKey ("application")
                && suggestedWords["application"].EditDistance == 2);
        }
Exemplo n.º 17
0
        public void CheckTest()
        {
            var spell = new SpellChecker("en-us");

            var examples = spell.Check("foxx or recieve").ToList();

            Assert.AreEqual(examples.Count(), 2);

            var firstError = examples[0];

            Assert.AreEqual(firstError.StartIndex, 0);
            Assert.AreEqual(firstError.Length, 4);
            Assert.AreEqual(firstError.RecommendedAction, RecommendedAction.GetSuggestions);
            Assert.AreEqual(firstError.RecommendedReplacement, string.Empty);

            var secondError = examples[1];

            Assert.AreEqual(secondError.StartIndex, 8);
            Assert.AreEqual(secondError.Length, 7);
            Assert.AreEqual(secondError.RecommendedAction, RecommendedAction.Replace);
            Assert.AreEqual(secondError.RecommendedReplacement, "receive");
        }
Exemplo n.º 18
0
		/*
				public static SpellCheckerOpenOfficeDictionary[] GetAllDictionaries()
				{
					var result = new List<SpellCheckerOpenOfficeDictionary>();

					var fileNames = getAllCompleteCultureFileNames();

					foreach ( var fileName in fileNames )
					{
						var normalizedFileName = fileName.Replace( @"_", @"-" );

						var dictionary =
							new SpellCheckerOpenOfficeDictionary
								{
									Culture = CultureInfo.GetCultureInfo( normalizedFileName ),
									DictionaryPath = ZlpPathHelper.Combine( dictionaryBaseFolderPath.FullName, fileName + @".dic" ),
									GrammarPath = ZlpPathHelper.Combine( dictionaryBaseFolderPath.FullName, fileName + @".aff" )
								};

						result.Add( dictionary );
					}

					return result.ToArray();
				}
		*/

		public static SpellChecker CreateSpellChecker(
			CultureInfo culture)
		{
			string dictionaryFilePath;
			string grammarFilePath;

			if (HasDictionariesForCulture(
				culture,
				out dictionaryFilePath,
				out grammarFilePath))
			{
				Trace.WriteLine(
					string.Format(
						@"Using spell checker with culture '{0}'.",
						culture));

				// http://www.devexpress.com/Help/?document=XtraSpellChecker/CustomDocument3158.htm&levelup=true.
				var spellChecker =
					new SpellChecker
					{
						Culture = culture,
						SpellCheckMode = SpellCheckMode.AsYouType,
					};
				spellChecker.CheckAsYouTypeOptions.CheckControlsInParentContainer = true;

				var dictionary =
					new SpellCheckerOpenOfficeDictionary
					{
						Culture = culture,
						DictionaryPath = dictionaryFilePath,
						GrammarPath = grammarFilePath
					};
				spellChecker.Dictionaries.Add(dictionary);

				return spellChecker;
			}
			else
			{
				Trace.WriteLine(
					string.Format(
						@"No spell checker with culture '{0}' because no dictionaries available.",
						culture));

				return null;
			}
		}
Exemplo n.º 19
0
 public void MoreThanOneCorrectionWithEditDistTwoAndChangedOrderInDict()
 {
     Assert.That(SpellChecker.CheckWord("Two", new string[] { "tewot", "van", "too", "three" }), Is.EqualTo("{tewot too}"));
 }
Exemplo n.º 20
0
 public RibbonUI()
 {
     InitializeComponent();
     this.spellChecker = SpellChecking.InitializeSpellChecker();
     OpenXmlLoadHelper.Load("MovieRentals.docx", richEdit);
 }
Exemplo n.º 21
0
 public void NoWhiteSpacesAtTextEnds()
 {
     Assert.That(SpellChecker.CheckText("one!\n  two-20\t'three apples , i yesh", new string[] { "apples", "too", "tree", "ys", "yeah", "y", "I" }), Is.EqualTo("{one?}!\n  too-20\t'tree apples , I {ys yeah}"));
 }
Exemplo n.º 22
0
        // IDisposable
        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposedValue & disposing)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).

                    if (clientTextBox != null)
                    {
                        this.ReleaseHandle();

                        clientTextBox.Invalidate();

                        clientTextBox.HandleCreated -= TextBoxBase_HandleCreated;
                        clientTextBox.ClientSizeChanged -= TextBoxBase_ClientSizeChanged;

                        clientTextBox.Dispose();
                        clientTextBox = null;
                    }

                    if (myBitmap != null)
                    {
                        myBitmap.Dispose();
                        myBitmap = null;
                    }

                    if (textBoxGraphics != null)
                    {
                        textBoxGraphics.Dispose();
                        textBoxGraphics = null;
                    }

                    if (bufferGraphics != null)
                    {
                        bufferGraphics.Dispose();
                        bufferGraphics = null;
                    }

                    if (mySpellChecker != null)
                    {
                        mySpellChecker = null;
                    }
                }

                // TODO: free unmanaged resources (unmanaged objects) and override Finalize() below.
                // TODO: set large fields to null.
            }
            this.disposedValue = true;
        }
Exemplo n.º 23
0
 public void UnsupportedLangTest()
 {
     var spell = new SpellChecker("zz-zz");
 }
Exemplo n.º 24
0
 public void WordIsCorrectIfInDictionaryIgnoreCase()
 {
     Assert.That(SpellChecker.CheckWord("абвгдеж", new string[] { "абвж", "АБВГдеж" }), Is.EqualTo("АБВГдеж"));
 }
Exemplo n.º 25
0
 bool ShouldWordBeMarkedAsMisspelled(ParsedTextSpan part) => part.IsWord && !SpellChecker.Check(part.Text);
        private bool EnsureWordBreakerAndSpellCheckerForCulture(CultureInfo culture, bool throwOnError = false)
        {
            if (_isDisposed || (culture == null))
            {
                return(false);
            }

            if (!_spellCheckers.ContainsKey(culture))
            {
                WordsSegmenter wordBreaker = null;

                try
                {
                    // Generally, we want to use the neutral language segmenter. This will ensure that the
                    // WordsSegmenter instance will not inadvertently de-compound words into stems. For e.g.,
                    // the dedicated segmenter for German will break down words like Hausnummer into {Haus, nummer},
                    // whereas the nuetral segmenter will not do so.
                    wordBreaker = WordsSegmenter.Create(culture.Name, shouldPreferNeutralSegmenter: true);
                }
                catch when(!throwOnError)
                {
                    // ArgumentException: culture name is malformed - unlikely given we use culture.Name
                    // PlatformNotSupportedException: OS is not supported
                    // NotSupportedException: culture name is likely well-formed, but not available currently for wordbreaking
                    wordBreaker = null;
                }

                // Even if wordBreaker.ResolvedLanguage == WordsSegmenter.Undetermined, we will use it
                // as an appropriate fallback wordbreaker as long as a corresponding ISpellChecker is found.
                if (wordBreaker == null)
                {
                    _spellCheckers[culture] = null;
                    return(false);
                }

                SpellChecker spellChecker = null;

                try
                {
                    using (new SpellerCOMActionTraceLogger(this, SpellerCOMActionTraceLogger.Actions.SpellCheckerCreation))
                    {
                        spellChecker = new SpellChecker(culture.Name);
                    }
                }
                catch (Exception ex)
                {
                    spellChecker = null;

                    // ArgumentException:
                    // Either the language name is malformed (unlikely given we use culture.Name)
                    //   or this language is not supported. It might be supported if the appropriate
                    //   input language is added by the user, but it is not available at this time.

                    if (throwOnError && ex is ArgumentException)
                    {
                        throw new NotSupportedException(string.Empty, ex);
                    }
                }

                if (spellChecker == null)
                {
                    _spellCheckers[culture] = null;
                }
                else
                {
                    _spellCheckers[culture] = new Tuple <WordsSegmenter, SpellChecker>(wordBreaker, spellChecker);
                }
            }

            return(_spellCheckers[culture] == null ? false : true);
        }
Exemplo n.º 27
0
 public AutoCorrect()
 {
     InitializeComponent();
     this.spellChecker = SpellChecking.InitializeSpellChecker();
     OpenXmlLoadHelper.Load("AutoCorrect.docx", richEdit);
 }
Exemplo n.º 28
0
 /// <summary>
 /// Initialize the SpellChecker for the current View Model
 /// </summary>
 private void InitializeSpellingChecker()
 {
     this.spellChecker = new SpellChecker();
     this.spellChecker.SpellCheckMode = SpellCheckMode.AsYouType;
 }
Exemplo n.º 29
0
 public static void InitDictionary(SpellChecker spellChecker)
 {
     if(LocalizationHelper.IsJapanese) spellChecker.SpellCheckMode = SpellCheckMode.OnDemand;
     if(spellChecker.Dictionaries.Count > 0) return;
     spellChecker.Dictionaries.Add(GetDefaultDictionary());
 }
 // Token: 0x06008615 RID: 34325 RVA: 0x0024B9A6 File Offset: 0x00249BA6
 public SpellerSegment(string sourceString, WordSegment segment, SpellChecker spellChecker, WinRTSpellerInterop owner) : this(sourceString, new WinRTSpellerInterop.TextRange(segment.SourceTextSegment), spellChecker, owner)
 {
 }
Exemplo n.º 31
0
 public void MoreThanOneEditCorrection()
 {
     Assert.That(SpellChecker.CheckWord("Three", new string[] { "van", "Tree", "Threek", "Threk", "sthree" }), Is.EqualTo("{Tree Threek sthree}"));
 }
 // Token: 0x06008614 RID: 34324 RVA: 0x0024B97A File Offset: 0x00249B7A
 public SpellerSegment(string sourceString, SpellerInteropBase.ITextRange textRange, SpellChecker spellChecker, WinRTSpellerInterop owner)
 {
     this._spellChecker = spellChecker;
     this._suggestions  = null;
     this.Owner         = owner;
     this.SourceString  = sourceString;
     this.TextRange     = textRange;
 }
Exemplo n.º 33
0
        public void DoubleDisposeTest()
        {
            var spell = new SpellChecker("en-AU");

            spell.Dispose();
            spell.Dispose(); // No error
        }
Exemplo n.º 34
0
 public int DetectOneOrTwoExtraLetters(string checkword, string dictword)
 {
     return(SpellChecker.CanReplace(checkword, dictword));
 }
Exemplo n.º 35
0
 public void TextbookExample()
 {
     Assert.That(SpellChecker.SpellCheck("rain spain plain plaint pain main mainly the in on fall falls his was ===\nhte rame in pain fells mainy oon teh lain was hints pliant ==="), Is.EqualTo("the {rame?} in pain falls {main mainly} on the plain was {hints?} plaint "));
 }
Exemplo n.º 36
0
 public void OneCorrectWordString()
 {
     Assert.That(SpellChecker.CheckText("a", new string[] { "abs", "ads", "b", "c", "a" }), Is.EqualTo("a"));
 }
Exemplo n.º 37
0
 public void SimpleSpellCheckTest()
 {
     Assert.That(SpellChecker.SpellCheck("rain spain===rain spain==="), Is.EqualTo("rain spain"));
 }
Exemplo n.º 38
0
 /// <summary>
 /// 检查词语是否为在典词语(仅中文)
 /// </summary>
 /// <param name="str"></param>
 /// <returns></returns>
 public static bool CheckSpell(this string str) =>
 ((_spellChecker ?? (_spellChecker = new SpellChecker())).Suggests(str) as string[]).Length > 0;
Exemplo n.º 39
0
 public int DetectOneIncorrectLetter(string checkword, string dictword)
 {
     return(SpellChecker.CanReplace(checkword, dictword));
 }
Exemplo n.º 40
0
 public void WhiteSpaceAndOtherNonAlphabetMustBeIntact()
 {
     Assert.That(SpellChecker.CheckText("  one!\n  two-20\t'three apples , yesh'! ", new string[] { "apples", "too", "tree", "ys", "yeah", "y" }), Is.EqualTo("  {one?}!\n  too-20\t'tree apples , {ys yeah}'! "));
 }
Exemplo n.º 41
0
        private Symbol LookupSymbolByName(string name, TextSpan span, NamespaceSymbol? @namespace)
        {
            NamespaceSymbol?FindNamespace(string name)
            {
                this.namespaces.TryGetValue(name, out NamespaceSymbol @namespace);
                return(@namespace);
            }

            Symbol?foundSymbol;

            if (@namespace == null)
            {
                // attempt to find name in the imported namespaces
                var namespaceSymbol = FindNamespace(name);

                if (namespaceSymbol != null)
                {
                    // namespace symbol found
                    return(ValidateFunctionFlags(namespaceSymbol, span));
                }

                // declarations must not have a namespace value, namespaces are used to fully qualify a function access.
                // There might be instances where a variable declaration for example uses the same name as one of the imported
                // functions, in this case to differentiate a variable declaration vs a function access we check the namespace value,
                // the former case must have an empty namespace value whereas the latter will have a namespace value.
                if (this.declarations.TryGetValue(name, out var localSymbol))
                {
                    // we found the symbol in the local namespace
                    return(ValidateFunctionFlags(localSymbol, span));
                }

                // attempt to find function in all imported namespaces
                var foundSymbols = this.namespaces
                                   .Select(kvp => kvp.Value.TryGetFunctionSymbol(name))
                                   .Where(symbol => symbol != null)
                                   .ToList();

                if (foundSymbols.Count() > 1)
                {
                    // ambiguous symbol
                    return(new UnassignableSymbol(DiagnosticBuilder.ForPosition(span)
                                                  .AmbiguousSymbolReference(name, this.namespaces.Keys)));
                }

                foundSymbol = foundSymbols.FirstOrDefault();

                if (foundSymbol == null)
                {
                    var nameCandidates = this.declarations.Values
                                         .Concat(this.namespaces.SelectMany(kvp => kvp.Value.Descendants))
                                         .Select(symbol => symbol.Name)
                                         .ToImmutableSortedSet();

                    var suggestedName = SpellChecker.GetSpellingSuggestion(name, nameCandidates);

                    return(suggestedName != null
                        ? new UnassignableSymbol(DiagnosticBuilder.ForPosition(span).SymbolicNameDoesNotExistWithSuggestion(name, suggestedName))
                        : new UnassignableSymbol(DiagnosticBuilder.ForPosition(span).SymbolicNameDoesNotExist(name)));
                }
            }
            else
            {
                foundSymbol = @namespace.TryGetFunctionSymbol(name);

                if (foundSymbol == null)
                {
                    return(new UnassignableSymbol(DiagnosticBuilder.ForPosition(span).FunctionNotFound(name, @namespace.Name)));
                }
            }

            return(ValidateFunctionFlags(foundSymbol, span));
        }
Exemplo n.º 42
0
 void Button_Click(object sender, RoutedEventArgs e)
 {
     SpellChecker.Check(richEdit);
 }
		public void Setup() {
			corrector = new SpellChecker (new string[] { "fuzzy", "fully", "funny", "fast" });
		}
Exemplo n.º 44
0
 private void codebox_TextChangedDelayed(object sender, TextChangedEventArgs e)
 {
     SpellChecker SpellChecker = new SpellChecker(Main.ActiveEditor.codebox, @"Dictionary.dic");
     SpellChecker.SpellCheck(sender);
 }
Exemplo n.º 45
0
 protected void PrepareAddToDictionaryButton()
 {
     btnAddToDictionary.Enabled = SpellChecker.GetCustomDictionary() != null;
 }
Exemplo n.º 46
0
 /// <summary>
 /// The dispose.
 /// </summary>
 /// <param name="disposing">
 /// The disposing.
 /// </param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         try
         {
             if (this.spellChecker != null)
             {
                 this.spellChecker.Dispose();
             }
         }
         finally
         {
             this.spellChecker = null;
         }
     }
 }
Exemplo n.º 47
0
 public void OneEditCorrection()
 {
     Assert.That(SpellChecker.CheckWord("Abcde", new string[] { "van", "abcdef", "abcdf" }), Is.EqualTo("abcdef"));
 }
Exemplo n.º 48
0
        public void LanguageIdTest()
        {
            var spell = new SpellChecker("en-AU");

            Assert.AreEqual(spell.LanguageTag, "en-AU");
        }
Exemplo n.º 49
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     SpellChecker.Check(textEdit);
 }
Exemplo n.º 50
0
 private SymbolTreeInfo(VersionStamp version, IReadOnlyList <Node> orderedNodes, SpellChecker spellChecker)
 {
     _version      = version;
     _nodes        = orderedNodes;
     _spellChecker = spellChecker;
 }
Exemplo n.º 51
0
 public void IsPlatformSupportedTest()
 {
     Assert.IsTrue(SpellChecker.IsPlatformSupported());
 }
        /// <summary>
        /// Evaluate spelling
        /// </summary>
        /// <returns>
        /// The result of the evaluation.
        /// </returns>
        protected override ValidatorResult Evaluate()
        {
            string controlValidationValue = this.ControlValidationValue;
              if (string.IsNullOrEmpty(controlValidationValue))
              {
            return ValidatorResult.Valid;
              }

              ItemUri itemUri = this.ItemUri;
              if (itemUri == null)
              {
            return ValidatorResult.Valid;
              }

              CultureInfo cultureInfo = itemUri.Language.CultureInfo;
              if (cultureInfo.IsNeutralCulture)
              {
            cultureInfo = Language.CreateSpecificCulture(cultureInfo.Name);
              }

              var checker = new SpellChecker(FileUtil.MapPath(FileUtilMapPath))
              {
            Text = controlValidationValue,
            DictionaryLanguage = cultureInfo.Name
              };
              if (checker.CheckText().Count <= 2)
              {
            return ValidatorResult.Valid;
              }

              this.Text = string.Format("The field \"{0}\" contains more than two spelling errors.", this.GetFieldDisplayName());

              return this.GetFailedResult(ValidatorResult.Error);
        }
Exemplo n.º 53
0
        public void LanguageIdTest()
        {
            var spell = new SpellChecker("en-AU");

            Assert.AreEqual(spell.LanguageTag, "en-AU");
        }
Exemplo n.º 54
0
 public void NoCorrections()
 {
     Assert.That(SpellChecker.CheckWord("abcdefg", new string[] { "van", "abcdr" }), Is.EqualTo("{abcdefg?}"));
 }
Exemplo n.º 55
0
 public void IsLanguageSupportedTest()
 {
     Assert.IsTrue(SpellChecker.IsLanguageSupported("en-us"));
     Assert.IsFalse(SpellChecker.IsLanguageSupported("zz-zz"));
 }
Exemplo n.º 56
0
 public void UnsupportedLangTest()
 {
     var spell = new SpellChecker("zz-zz");
 }
Exemplo n.º 57
0
 public void WordIsCorrectIfInDictionary()
 {
     Assert.That(SpellChecker.CanReplace("абвгдеж", "абвгдеж"), Is.EqualTo(0));
 }