Example #1
0
        private void EditNetSpellLoad(object sender, EventArgs e)
        {
            MistakeFont = new Font(TextBox.Font, FontStyle.Underline);

            components = new Container();
            _spelling  =
                new Spelling(components)
            {
                ShowDialog            = false,
                IgnoreAllCapsWords    = true,
                IgnoreWordsWithDigits = true
            };

            //
            // spelling
            //
            _spelling.ReplacedWord   += SpellingReplacedWord;
            _spelling.DeletedWord    += SpellingDeletedWord;
            _spelling.MisspelledWord += SpellingMisspelledWord;

            //
            // wordDictionary
            //
            LoadDictionary();
        }
        public void FindWord(string text)
        {
            bool   wordFound = false;
            string foundText = "";

            Spelling oSpell = new Spelling();

            for (int key = 1; key <= 95; key++)
            {
                string   textToTest = Decrypt(text, key);
                string[] words      = textToTest.Split(' ');

                foreach (string word in words)
                {
                    if (oSpell.TestWord(word))
                    {
                        wordFound = true;
                        foundText = textToTest;
                        break;
                    }
                }
            }

            Console.WriteLine(wordFound ? foundText : "Kein Wort gefunden!");
        }
        private void button2_Click(object sender, EventArgs e)
        {
            label4.Text = "";
            Stopwatch sw = new Stopwatch();

            listBox2.Items.Clear();
            dosyauzantisi = ".html";
            string aranan = textBox1.Text;

            sw.Start();
            dosyadanOku(aranan, dosyauzantisi);
            sw.Stop();
            Spelling spelling = new Spelling();
            string   word     = "";

            word = textBox1.Text;
            if (word != spelling.Correct(word))
            {
                linkLabel1.Text = spelling.Correct(word);
            }
            if (listBox2.Items.Count != 0)
            {
                label4.Text += listBox2.Items.Count + " adet sonuç " + sw.ElapsedMilliseconds.ToString() + " milisaniyede bulunmuştur";
            }
        }
        public void WhenIsSkippedFlagAsSkipped()
        {
            // Arrange
            var mockSpeachService = new Mock <ISpeachService>();
            var spellings         = new ObservableCollection <SpellingViewModel>();
            var s = new Spelling()
            {
                Word = "Dog", ContextSentence = "The dog and bone"
            };
            var svm = new SpellingViewModel(s);

            spellings.Add(svm);

            var sut = new SpellTestService(spellings, mockSpeachService.Object);

            sut.NextQuestion();

            // Act
            sut.SkipQuestion();


            // Assert
            Assert.Equal(svm.CorrectCount, 0);
            Assert.Equal(svm.ErrorCount, 0);
            Assert.Equal(svm.Skipped, true);
        }
        private void button3_Click(object sender, EventArgs e)
        {
            label4.Text = "";
            Stopwatch sw = new Stopwatch();

            listBox2.Items.Clear();
            string aranan = textBox1.Text;
            string text;

            dosyauzantisi = ".docx";
            ComponentInfo.SetLicense("FREE-LIMITED-KEY");
            var document = new DocumentModel();

            document = DocumentModel.Load(@"C:\Users\raman\Desktop\Osman\kelime-listesi-turkce.docx");
            text     = document.Sections[0].Blocks.Cast <Paragraph>(0).Inlines.Cast <Run>(0).Text;
            sw.Start();
            BruteForce(aranan, text);
            sw.Stop();
            Spelling spelling = new Spelling();
            string   word     = "";

            word = textBox1.Text;
            if (word != spelling.Correct(word))
            {
                linkLabel1.Text = spelling.Correct(word);
            }
            if (listBox2.Items.Count != 0)
            {
                label4.Text += listBox2.Items.Count + " adet sonuç " + sw.ElapsedMilliseconds.ToString() + " milisaniyede bulunmuştur";
            }
        }
        public void Next_Should_Return_Null_When_All_Answered()
        {
            // Arrange
            var mockSpeachService = new Mock <ISpeachService>();
            var spellings         = new ObservableCollection <SpellingViewModel>();
            var s = new Spelling()
            {
                Word = "Dog", ContextSentence = "The dog and bone"
            };
            var svm = new SpellingViewModel(s);

            spellings.Add(svm);

            var sut = new SpellTestService(spellings, mockSpeachService.Object);
            var q   = sut.NextQuestion();

            // Act
            q = sut.AnswerQuestion("Dog");

            // Assert
            Assert.Null(q);

            q = sut.NextQuestion();
            Assert.Null(q);
        }
        private void AnalyzeName(string text, WordNetEngine.POS pOS)
        {
            if (text.Length < 2)
            {
                throw new Exception("Length is less than 2 char");
            }
            Spelling oSpell = new Spelling();
            var      words  = Regex.Split(text, @"([A-Z _][a-z]+)");

            foreach (var word in words.Where(c => !string.IsNullOrEmpty(c) && c != "_"))
            {
                if (!oSpell.TestWord(word))
                {
                    throw new Exception("FieldName Is not a Valid Word");
                }
                if (pOS == WordNetEngine.POS.Noun)
                {
                    SynSet token = WordNetEngine.GetMostCommonSynSet(word, pOS);
                    if (token == null)
                    {
                        throw new Exception("FieldName Is Not A Valid noun");
                    }
                }
            }
            if (pOS == WordNetEngine.POS.Verb)
            {
                var    word  = string.Join(" ", words.Where <string>(c => c.Length > 0));
                SynSet token = WordNetEngine.GetMostCommonSynSet(word, pOS);
                if (token == null)
                {
                    throw new Exception("MethodName Is Not A Valid Verb");
                }
            }
        }
Example #8
0
        private void EditNetSpellLoad(object sender, EventArgs e)
        {
            MistakeFont = new Font(TextBox.Font, FontStyle.Underline);
            TextBoxFont = TextBox.Font;
            ShowWatermark();

            components = new Container();
            _spelling  =
                new Spelling(components)
            {
                ShowDialog            = false,
                IgnoreAllCapsWords    = true,
                IgnoreWordsWithDigits = true
            };

            _autoCompleteListTask.ContinueWith(
                w => _spelling.AddAutoCompleteWords(w.Result.Select(x => x.Word)),
                _autoCompleteCancellationTokenSource.Token,
                TaskContinuationOptions.NotOnCanceled,
                TaskScheduler.FromCurrentSynchronizationContext()
                );
            //
            // spelling
            //
            _spelling.ReplacedWord   += SpellingReplacedWord;
            _spelling.DeletedWord    += SpellingDeletedWord;
            _spelling.MisspelledWord += SpellingMisspelledWord;

            //
            // wordDictionary
            //
            LoadDictionary();
        }
Example #9
0
        static void Main(string[] args)
        {
            Spelling spelling = new Spelling();
            string   word     = "";

            word = "speling";
            Console.WriteLine("{0} => {1}", word, spelling.Correct(word));

            word = "korrecter"; // 'correcter' is not in the dictionary file so this doesn't work
            Console.WriteLine("{0} => {1}", word, spelling.Correct(word));

            word = "korrect";
            Console.WriteLine("{0} => {1}", word, spelling.Correct(word));

            word = "acess";
            Console.WriteLine("{0} => {1}", word, spelling.Correct(word));

            word = "supposidly";
            Console.WriteLine("{0} => {1}", word, spelling.Correct(word));

            // A sentence
            string sentence   = "I havve speled thes woord wwrong"; // sees speed instead of spelled (see notes on norvig.com)
            string correction = "";

            foreach (string item in sentence.Split(' '))
            {
                correction += " " + spelling.Correct(item);
            }
            Console.WriteLine("Did you mean:" + correction);

            Console.Read();
        }
    // Found target
    public void OnFoundTarget()
    {
        Controller.Instance.particle.SetActive(false);
        Controller.Instance.particle.SetActive(true);
        Controller.Instance.spellingArea.SetActive(false);

        curState = State.ON_TARGET;

        string n = gameObject.name;

        spelling = Controller.Instance.spellingData.spellingList.Find(x => x.English == n);

        Controller.Instance.curObjSpellingData = spelling;

        Debug.Log("English : " + spelling.English);
        Debug.Log("Myanmar : " + spelling.Myanmar);

        // Make the first letter to Upper Case.
        string pathName = n.First().ToString().ToUpper() + n.Substring(1);

        // Default audio file for object.
        engAudio = Resources.Load("Pronunciation/ENUS/" + pathName) as AudioClip;

        PlayAnimation();

        ResetAll();

        DoEnable();
    }
Example #11
0
        public void TestWord()
        {
            Spelling _SpellChecker = NewSpellChecker();

            Assert.IsTrue(_SpellChecker.TestWord("test"), "Did not find test word");
            Assert.IsFalse(_SpellChecker.TestWord("tst"), "Found tst word and shouldn't have");
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            // if not in cache, create new
            WordDictionary = new NetSpell.SpellChecker.Dictionary.WordDictionary();
            WordDictionary.EnableUserFile = false;

            //getting folder for dictionaries
            string          dicFolder = Path.Combine(Utils.GetDataFolderPath(), @"dictionary");
            WebmailSettings settings  = (new WebMailSettingsCreator()).CreateWebMailSettings();
            string          defLang   = settings.DefaultLanguage;
            Account         acct      = (Account)Session[Constants.sessionAccount];

            if (acct != null)
            {
                defLang = acct.UserOfAccount.Settings.DefaultLanguage;
            }
            string dictionaryFile = "en-US.dic";

            switch (defLang)
            {
            case "French": dictionaryFile = "fr-FR.dic"; break;

            case "German": dictionaryFile = "de-DE.dic"; break;
            }
            WordDictionary.DictionaryFolder = dicFolder;
            WordDictionary.DictionaryFile   = dictionaryFile;

            //load and initialize the dictionary
            WordDictionary.Initialize();

            // create spell checker
            SpellChecker            = new Spelling();
            SpellChecker.ShowDialog = false;
            SpellChecker.Dictionary = WordDictionary;
        }
Example #13
0
        public void NoText()
        {
            Spelling _SpellChecker = NewSpellChecker();

            Assert.AreEqual(string.Empty, _SpellChecker.CurrentWord, "Incorrect Current Word");

            _SpellChecker.WordIndex = 1;
            Assert.AreEqual(0, _SpellChecker.WordIndex, "Incorrect Word Index");

            Assert.AreEqual(0, _SpellChecker.WordCount, "Incorrect Word Count");

            Assert.AreEqual(0, _SpellChecker.TextIndex, "Incorrect Text Index");

            _SpellChecker.DeleteWord();
            Assert.AreEqual(string.Empty, _SpellChecker.Text, "Incorrect Text");

            _SpellChecker.IgnoreWord();
            Assert.AreEqual(string.Empty, _SpellChecker.Text, "Incorrect Text");

            _SpellChecker.ReplaceWord("Test");
            Assert.AreEqual(string.Empty, _SpellChecker.Text, "Incorrect Text");

            Assert.IsFalse(_SpellChecker.SpellCheck(), "Spell Check not false");

            _SpellChecker.Suggest();
            Assert.AreEqual(0, _SpellChecker.Suggestions.Count, "Generated Suggestions with no text");
        }
Example #14
0
 internal Worker(SpellChecker spellChecker, CultureInfo cultureInfo, System.ComponentModel.IContainer container)
 {
     this._cultureInfo    = cultureInfo;
     this._currentResult  = null;
     this._currentReason  = CallReasons.None;
     this._currentText    = null;
     this._currentTextBox = null;
     this._spelling       = new Spelling();
     if (container == null)
     {
         this._spelling.Dictionary = new WordDictionary();
     }
     else
     {
         this._spelling.Dictionary = new WordDictionary(container);
     }
     this._spelling.Dictionary.DictionaryFolder = spellChecker.DictionaryFolderPath;
     this._spelling.Dictionary.DictionaryFile   = spellChecker.GetDictionaryFileName(this._cultureInfo);
     this._spelling.Dictionary.EnableUserFile   = true;
     this._spelling.Dictionary.UserFile         = spellChecker.GetUserDictionaryFileName(this._cultureInfo);
     this._spelling.IgnoreAllCapsWords          = false;
     this._spelling.IgnoreHtml            = false;
     this._spelling.IgnoreWordsWithDigits = false;
     this._spelling.DoubledWord          += this._spelling_DoubledWord;
     this._spelling.MisspelledWord       += this._spelling_MisspelledWord;
     this._spelling.DeletedWord          += this._spelling_DeletedWord;
     this._spelling.ReplacedWord         += this._spelling_ReplacedWord;
 }
        public void WhenIsAnsweredIncorrectlyErrorCountIncreases()
        {
            // Arrange
            var mockSpeachService = new Mock <ISpeachService>();
            var spellings         = new ObservableCollection <SpellingViewModel>();
            var s = new Spelling()
            {
                Word = "Dog", ContextSentence = "The dog and bone"
            };
            var svm = new SpellingViewModel(s);

            spellings.Add(svm);

            var sut = new SpellTestService(spellings, mockSpeachService.Object);

            sut.NextQuestion();

            // Act
            sut.AnswerQuestion("Dogg");


            // Assert
            Assert.Equal(svm.CorrectCount, 0);
            Assert.Equal(svm.ErrorCount, 1);
            Assert.Equal(svm.Skipped, false);
        }
Example #16
0
        // constructor - takes a course dictionary file name
        private Search(string courseDictionary)
        {
            this.spelling         = new Spelling(courseDictionary);
            this.courseDictionary = courseDictionary;

            this.lastSearchResults = new SearchResults();
            this.options           = new AdvancedOptions();
        }
Example #17
0
        public SearchResults lastSearchResults; // Stores the search results after using searchForQuery()

        // constructor - uses default course dictionary filename
        private Search()
        {
            this.spelling         = new Spelling("course_dictionary.txt");
            this.courseDictionary = "course_dictionary.txt";

            this.lastSearchResults = new SearchResults();
            this.options           = new AdvancedOptions();
        }
Example #18
0
        public void EditDistance()
        {
            Spelling _SpellChecker = NewSpellChecker();

            Assertion.AssertEquals("Incorrect EditDistance", 1, _SpellChecker.EditDistance("test", "tst"));
            Assertion.AssertEquals("Incorrect EditDistance", 2, _SpellChecker.EditDistance("test", "tes"));
            Assertion.AssertEquals("Incorrect EditDistance", 0, _SpellChecker.EditDistance("test", "test"));
        }
Example #19
0
        public void EditDistance()
        {
            Spelling _SpellChecker = NewSpellChecker();

            Assert.True(1 == _SpellChecker.EditDistance("test", "tst"), "Incorrect EditDistance");
            Assert.True(2 == _SpellChecker.EditDistance("test", "tes"), "Incorrect EditDistance");
            Assert.True(0 == _SpellChecker.EditDistance("test", "test"), "Incorrect EditDistance");
        }
Example #20
0
        private Spelling NewSpellChecker()
        {
            Spelling _SpellChecker = new Spelling();

            _SpellChecker.Dictionary = _dictionary;

            return(_SpellChecker);
        }
Example #21
0
        /// <summary>
        ///     Default Constructor
        /// </summary>
        public SuggestionForm(Spelling spell)
        {
            this.SpellChecker = spell;
            this.AttachEvents();
            InitializeComponent();
#if BEPOE_EXTENSIONS
            this.Shown += new EventHandler(this.Form_Shown);
#endif
        }
Example #22
0
        //constructors
        public SpellCheckCore(char lineDelim)
        {
            this.lineDelim            = lineDelim;
            spellCheck                = new Spelling();
            spellCheck.SuggestionMode = Spelling.SuggestionEnum.PhoneticNearMiss;
            spellCheck.Dictionary     = LoadValidNames();

            registeredPairs = LoadNamePairs();
        }
Example #23
0
        private Spelling NewSpellChecker()
        {
            Spelling _SpellChecker = new Spelling();

            _SpellChecker.Dictionary = _dictionary;

            _SpellChecker.ShowDialog = false;
            return(_SpellChecker);
        }
Example #24
0
        public void Should_lower_case_sentence_correction(string mispelled, string expected)
        {
            var spelling = new Spelling();

            // Act
            string actual = spelling.CorrectSentence(mispelled);

            // Assert
            Assert.AreEqual(expected, actual);
        }
Example #25
0
        public void SpellCheck()
        {
            Spelling _SpellChecker = NewSpellChecker();

            _SpellChecker.Text = "this is an errr tst";

            _SpellChecker.SpellCheck();
            Assert.True(3 == _SpellChecker.WordIndex, "Incorrect WordOffset");
            Assert.True("errr" == _SpellChecker.CurrentWord, "Incorrect CurrentWord");
        }
Example #26
0
        public Dictionary(WordDictionary dictionary, Spelling spellChecker, IAnagramsEndpoint anagramsEndpoint)
        {
            _dictionary                = dictionary;
            _spellChecker              = spellChecker;
            _anagramsEndpoint          = anagramsEndpoint;
            _dictionary.DictionaryFile = "en-US.dic";

            _dictionary.Initialize();
            _spellChecker.Dictionary = _dictionary;
        }
        public void Add(Spelling spelling)
        {
            if (spelling == null)
            {
                throw new ArgumentNullException(nameof(spelling));
            }

            _spellings.AddOrUpdate(spelling.GetHashCode(), spelling, (key, oldValue) => spelling);
            UpdateSortedSpellings();
        }
        public void Remove(Spelling spelling)
        {
            if (spelling == null)
            {
                throw new ArgumentNullException(nameof(spelling));
            }

            _ = _spellings.TryRemove(spelling.GetHashCode(), out _);
            UpdateSortedSpellings();
        }
Example #29
0
        public void SpellCheck()
        {
            Spelling _SpellChecker = NewSpellChecker();

            _SpellChecker.Text = "this is an errr tst";

            _SpellChecker.SpellCheck();
            Assertion.AssertEquals("Incorrect WordOffset", 3, _SpellChecker.WordIndex);
            Assertion.AssertEquals("Incorrect CurrentWord", "errr", _SpellChecker.CurrentWord);
        }
Example #30
0
        static void Main(string[] args)
        {
            //char[] arr = { 'A', 'C', 'T', 'P' };
            Console.WriteLine("Enter the word");
            string input = Console.ReadLine();

            char[] arr = input.ToCharArray();

            // int r = 2;
            int n = arr.Length;

            for (int i = 3; i <= n; i++)
            {
                Console.WriteLine("Printing words with {0} characters", i);
                printCombination(arr, n, i);
                // permute(arr, 0, i);
            }

            Console.WriteLine("Printing all strings");
            foreach (var item in output)
            {
                Console.WriteLine("For {0}, possible permutations", item);
                //if (item.Length > 1)
                permute(item.ToCharArray(), 0, item.Length - 1);
            }

            WordDictionary oDict = new WordDictionary();

            oDict.DictionaryFile = "en-US.dic";
            oDict.Initialize();
            // string wordToCheck = "door";
            Spelling oSpell = new Spelling();

            oSpell.Dictionary = oDict;

            foreach (var item in output1)
            {
                // Console.WriteLine(item);
                if (oSpell.TestWord(item))
                {
                    output2.Add(item);
                    Console.WriteLine("Word {0} is a valid english word", item);
                }
            }

            Console.WriteLine("\n\n Final output is ===================== ");
            var distinctList = output2.Distinct().ToList();

            foreach (var item in distinctList)
            {
                Console.WriteLine(item);
            }

            Console.ReadLine();
        }
		public void should_correct_single_words(string mispelled, string expected)
		{
			// Arrange
			var spelling = new Spelling(_dictionary);

			// Act
			string actual = spelling.Correct(mispelled);

			// Assert
			Assert.AreEqual(expected, actual);
		}
		public void should_correct_sentences(string mispelled, string expected)
		{
			// Arrange
			string dictionary = File.ReadAllText("big.txt");
			var spelling = new Spelling(dictionary);

			// Act
			string actual = spelling.CorrectSentence(mispelled);

			// Assert
			Assert.AreEqual(expected, actual);
		}
    /// <summary>
    /// Did you mean suggestion.
    /// </summary>
    private static string DidYouMean(string dictionaryFile, string searchQuery, List<string> searchTerms)
    {
        if (searchTerms != null)
        {
            Spelling SpellChecker = null;
            WordDictionary WordDictionary = null;

            #region "Word dictionary"

            // If not in cache, create new
            WordDictionary = new WordDictionary();
            WordDictionary.EnableUserFile = false;

            // Getting folder for dictionaries
            string folderName = HttpContext.Current.Request.MapPath("~/App_Data/Dictionaries/");

            // Check if dictionary file exists
            string fileName = Path.Combine(folderName, dictionaryFile);
            if (!File.Exists(fileName))
            {
                EventLogProvider eventLog = new EventLogProvider();
                eventLog.LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "DidYouMean webpart", "Dictionary file not found!");

                return String.Empty;
            }

            WordDictionary.DictionaryFolder = folderName;
            WordDictionary.DictionaryFile = dictionaryFile;

            // Load and initialize the dictionary
            WordDictionary.Initialize();

            #endregion

            #region "SpellCheck"

            // Prepare spellchecker
            SpellChecker = new Spelling();
            SpellChecker.Dictionary = WordDictionary;
            SpellChecker.SuggestionMode = Spelling.SuggestionEnum.NearMiss;

            bool suggest = false;

            // Check all searched terms
            foreach (string term in searchTerms)
            {
                if (term.Length > 2)
                {
                    SpellChecker.Suggest(term);
                    ArrayList al = SpellChecker.Suggestions;

                    // If there are some suggestions
                    if ((al != null) && (al.Count > 0))
                    {
                        suggest = true;

                        // Expression to find term
                        Regex regex = RegexHelper.GetRegex("([\\+\\-\\s\\(]|^)" + term + "([\\s\\)]|$)");

                        // Change term in original search query
                        string suggestion = "$1" + startTag + al[0] + endTag + "$2";
                        searchQuery = regex.Replace(searchQuery, suggestion);
                    }
                }
            }

            #endregion

            if (suggest)
            {
                return searchQuery;
            }
        }

        return String.Empty;
    }
Example #34
0
 public void SetSpellChecker(TextBoxBase extendee, Spelling value)
 {
     _spellChecker = value;
 }
    protected void Page_Init(object sender, EventArgs e)
    {
        string cacheName = "WordDictionary|" + LocalizationContext.PreferredCultureCode;

        // Get dictionary from cache
        WordDictionary = (WordDictionary)CacheHelper.GetItem(cacheName);
        if (WordDictionary == null)
        {
            // If not in cache, create new
            WordDictionary = new WordDictionary();
            WordDictionary.EnableUserFile = false;

            // Getting folder for dictionaries
            string folderName = "~/App_Data/Dictionaries";
            folderName = MapPath(folderName);

            string culture = LocalizationContext.PreferredCultureCode;
            string dictFile = culture + ".dic";
            string dictPath = Path.Combine(folderName, dictFile);
            if (!File.Exists(dictPath))
            {
                // Get default culture
                string defaultCulture = ValidationHelper.GetString(SettingsHelper.AppSettings["CMSDefaultSpellCheckerCulture"], String.Empty);
                if (!String.IsNullOrEmpty(defaultCulture))
                {
                    culture = defaultCulture;
                    dictFile = defaultCulture + ".dic";
                    dictPath = Path.Combine(folderName, dictFile);
                }
            }

            if (!File.Exists(dictPath))
            {
                lblError.Text = string.Format(GetString("SpellCheck.DictionaryNotExists"), culture);
                lblError.Visible = true;
                return;
            }

            mDictExists = true;
            WordDictionary.DictionaryFolder = folderName;
            WordDictionary.DictionaryFile = dictFile;

            // Load and initialize the dictionary
            WordDictionary.Initialize();

            // Store the Dictionary in cache
            var path = Path.Combine(folderName, WordDictionary.DictionaryFile);
            var cd = CacheHelper.GetFileCacheDependency(path);

            CacheHelper.Add(cacheName, WordDictionary, cd, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration);
        }
        else
        {
            mDictExists = true;
        }

        // Create spell checker
        SpellChecker = new Spelling();
        SpellChecker.ShowDialog = false;
        SpellChecker.Dictionary = WordDictionary;
        SpellChecker.IgnoreAllCapsWords = false;

        // Adding events
        SpellChecker.MisspelledWord += SpellChecker_MisspelledWord;
        SpellChecker.EndOfText += SpellChecker_EndOfText;
        SpellChecker.DoubledWord += SpellChecker_DoubledWord;
    }
Example #36
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 public SuggestionForm(Spelling spell)
 {
     this.SpellChecker = spell;
     this.AttachEvents();
     InitializeComponent();
 }
Example #37
0
    protected void Page_Init(object sender, EventArgs e)
    {
        string cacheName = "WordDictionary|" + CMSContext.PreferredCultureCode;
        // Get dictionary from cache
        this.WordDictionary = (WordDictionary)HttpContext.Current.Cache[cacheName];
        if (this.WordDictionary == null)
        {
            // If not in cache, create new
            this.WordDictionary = new NetSpell.SpellChecker.Dictionary.WordDictionary();
            this.WordDictionary.EnableUserFile = false;

            // Getting folder for dictionaries
            string folderName = "~/App_Data/Dictionaries";
            folderName = this.MapPath(folderName);

            string culture = CMSContext.PreferredCultureCode;
            string dictFile = culture + ".dic";
            string dictPath = Path.Combine(folderName, dictFile);
            if (!File.Exists(dictPath))
            {
                // Get default culture
                string defaultCulture = ValidationHelper.GetString(SettingsHelper.AppSettings["CMSDefaultSpellCheckerCulture"], "");
                if (defaultCulture != "")
                {
                    culture = defaultCulture;
                    dictFile = defaultCulture + ".dic";
                    dictPath = Path.Combine(folderName, dictFile);
                }
            }

            if (!File.Exists(dictPath))
            {
                this.lblError.Text = string.Format(GetString("SpellCheck.DictionaryNotExists"), culture);
                this.lblError.Visible = true;
                return;
            }

            mDictExists = true;
            this.WordDictionary.DictionaryFolder = folderName;
            this.WordDictionary.DictionaryFile = dictFile;

            // Load and initialize the dictionary
            this.WordDictionary.Initialize();

            // Store the Dictionary in cache
            HttpContext.Current.Cache.Insert(cacheName, this.WordDictionary, new CacheDependency(Path.Combine(folderName, this.WordDictionary.DictionaryFile)));
        }
        else
        {
            mDictExists = true;
        }

        // Create spell checker
        this.SpellChecker = new NetSpell.SpellChecker.Spelling();
        this.SpellChecker.ShowDialog = false;
        this.SpellChecker.Dictionary = this.WordDictionary;

        // Adding events
        this.SpellChecker.MisspelledWord += new NetSpell.SpellChecker.Spelling.MisspelledWordEventHandler(this.SpellChecker_MisspelledWord);
        this.SpellChecker.EndOfText += new NetSpell.SpellChecker.Spelling.EndOfTextEventHandler(this.SpellChecker_EndOfText);
        this.SpellChecker.DoubledWord += new NetSpell.SpellChecker.Spelling.DoubledWordEventHandler(this.SpellChecker_DoubledWord);
    }
Example #38
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 public OptionForm(ref Spelling spell)
 {
     this.SpellChecker = spell;
     InitializeComponent();
 }