Exemplo n.º 1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (m_oHunspell != null && m_oEncoder != null)
     {
         frmAddNewWord dlg = new frmAddNewWord();
         if (Globals.ThisAddIn.ProgramSettings.OrthographyType == 1)
         {
             dlg.IsClassicOrthography = false;
         }
         dlg.HSWrapper = m_oHunspell;
         dlg.NewWord   = sUniInput;
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             string sNewWord = dlg.NewWord;
             string sExample = dlg.AffixExample;
             // add word to custom dictionary function
             if (sExample.Length > 0)
             {
                 m_oHunspell.AddWithAffix(sNewWord, sExample);
                 AddCustomWord(sNewWord, sExample);
             }
             else
             {
                 m_oHunspell.Add(sNewWord);
                 AddCustomWord(sNewWord);
             }
             Globals.ThisAddIn.ByPassAppWinSelectChange = true;
             CheckNext_U();
         }
     }
     SetSpellingState("Անտեսել");
 }
Exemplo n.º 2
0
        MultiSpell(List <DictionaryInfo> dictionaries)
        {
            Log.Source.TraceInformation("Loading RightWords data");

            // system dictionaries and spellers
            _dictionaries = dictionaries;
            _spells       = new List <Hunspell>(dictionaries.Count);

            // reset hit counters
            foreach (var dictionary in dictionaries)
            {
                dictionary.HitCount = 0;
            }

            // user dictionaries
            foreach (var dic in dictionaries)
            {
                var spell = new Hunspell(dic.HunspellAffFile, dic.HunspellDictFile);
                _spells.Add(spell);

                var userWordsPath = Actor.GetUserDictionaryPath(dic.Language, false);
                if (File.Exists(userWordsPath))
                {
                    using (var reader = File.OpenText(userWordsPath))
                    {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            var words = line.Split(' ');
                            if (words.Length == 1)
                            {
                                spell.Add(words[0]);
                            }
                            else if (words.Length == 2)
                            {
                                spell.AddWithAffix(words[0], words[1]);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void InitializeCustomDictionary(Hunspell _hunspell, string[] dictionaryLines)
        {
            foreach (var dictionaryLine in dictionaryLines)
            {
                if (string.IsNullOrEmpty(dictionaryLine) || dictionaryLine.StartsWith("#"))
                {
                    continue;
                }

                var tokens = dictionaryLine.Split(':');
                if (tokens.Length == 1)
                {
                    _hunspell.Add(tokens[0].Trim());
                }
                else
                {
                    _hunspell.AddWithAffix(tokens[0].Trim(), tokens[1].Trim());
                }
            }
        }
Exemplo n.º 4
0
    public void AddWordTest()
    {
        using (Hunspell hunspell = new Hunspell("en_us.aff", "en_us.dic"))
        {
            Assert.IsFalse(hunspell.Spell("phantasievord"));
            Assert.IsTrue(hunspell.Add("phantasievord"));
            Assert.IsTrue(hunspell.Spell("phantasievord"));
            Assert.IsTrue(hunspell.Remove("phantasievord"));
            Assert.IsFalse(hunspell.Spell("phantasievord"));

            Assert.IsFalse(hunspell.Spell("phantasos"));
            Assert.IsFalse(hunspell.Spell("phantasoses"));
            Assert.IsTrue(hunspell.AddWithAffix("phantasos", "fish"));
            Assert.IsTrue(hunspell.Spell("phantasos"));
            Assert.IsTrue(hunspell.Spell("phantasoses"));
            Assert.IsTrue(hunspell.Remove("phantasos"));
            Assert.IsFalse(hunspell.Spell("phantasos"));
            Assert.IsFalse(hunspell.Spell("phantasoses"));
        }
    }
Exemplo n.º 5
0
 protected override void SetStatusInternal(string word, bool isCorrect)
 {
     if (isCorrect)
     {
         if (IsVernacular)
         {
             // Custom vernacular-only dictionary.
             // want it 'affixed' like the prototype, which has been marked to suppress other-case matches
             _hunspellHandle.AddWithAffix(MarshallAsUtf8Bytes(word), MarshallAsUtf8Bytes(SpellingHelper.PrototypeWord));
         }
         else
         {
             // not our custom dictionary, some majority language, we can't (and probably don't want)
             // to be restrictive about case.
             _hunspellHandle.Add(MarshallAsUtf8Bytes(word));
         }
     }
     else
     {
         _hunspellHandle.Remove(MarshallAsUtf8Bytes(word));
     }
 }
Exemplo n.º 6
0
 public void AddWord(string customWord, string similarWord)
 {
     hunspell.AddWithAffix(customWord, similarWord);
 }