Exemple #1
0
        public void DeleteCorrectWords()
        {
            var    _chkSpell        = new CheakSpell();
            var    f                = File.ReadAllLines(Environment.CurrentDirectory + @"\..\..\..\File\All_word.txt");
            string _correctWord     = string.Empty;
            string _failWord        = string.Empty;
            string _isFalseWord     = string.Empty;
            string _isInSuggestList = string.Empty;
            string _isDefineYet     = string.Empty;
            string result;

            foreach (var l in f)
            {
                if (l.Length > 2)
                {
                    var words = l.Split(',');

                    _correctWord = words[0];
                    _failWord    = words[1];

                    if (_chkSpell.Cheak_Spell(_correctWord) == false)
                    {
                        _isDefineYet = "not_define";
                    }
                    else
                    {
                        _isDefineYet = "define";
                    }


                    if (_chkSpell.Cheak_Spell(_failWord) == false)
                    {
                        _isFalseWord = "false_word";

                        if (_chkSpell.Suggest(_failWord).Contains(_correctWord))
                        {
                            _isInSuggestList = "Suggested";
                        }
                        else
                        {
                            _isInSuggestList = "NoSuggest";
                        }
                    }
                    else
                    {
                        _isFalseWord = "true_word";
                    }

                    result = _isDefineYet + @"," + _correctWord + @"," + _failWord + @"," + _isFalseWord + @"," + _isInSuggestList;



                    File.AppendAllText(Environment.CurrentDirectory + @"\..\..\..\File\All_data.txt",
                                       result + Environment.NewLine);
                    Thread.Sleep(1000);
                }
            }
        }
Exemple #2
0
        private void Application_WindowBeforeRightClickEvent(Word.Selection curselection, ref bool cancel)
        {
            GlobalClass.myselection = curselection;
            var wordrange = GlobalClass.myword.Selection.Range;

            int left, top, width, height;

            GlobalClass.myword.ActiveWindow.GetPoint(out left, out top, out width, out height, wordrange);

            var curword      = curselection.Range.Words[1].Text;
            var curwordcount = curselection.Range.Words.Count;

            PunchPattern punckPattern = null;

            if (_listpukPattern != null)
            {
                punckPattern = _listpukPattern.Find(t =>
                                                    t.IndexStart <= curselection.Range.Start && t.IndexEnd >= curselection.Range.End);
            }

            if (punckPattern != null && punckPattern.ErrorCode > 0)
            {
                cancel = true;
                _currentPuncPattern    = punckPattern;
                _cpuncForm             = new CPPPunctuation();
                _cpuncForm.Deactivate += CpPuncForm_Deactivate;
                _cpuncForm.ShowBallonScreen(new Point(left, top));
                _cpuncForm.ShowFormWithMessage =
                    punckPattern.ErroMessage + Environment.NewLine + punckPattern.ErrorCorrection;
            }
            else
            {
                // else spell
                var isSpellisCorrect = _chkSpell.Cheak_Spell(curword.Trim());

                if (curword.Trim().Length > 1 && curwordcount == 1 && isSpellisCorrect == false)
                {
                    cancel                  = true;
                    _cspellForm             = new CPPSPell();
                    _cspellForm.Deactivate += cpSpellForm_Deactivate;
                    _cspellForm.ShowBallonScreen(new Point(left, top));

                    var suggestList = _chkSpell.Suggest(curword);
                    _cspellForm.ShowDlg(suggestList);
                }
            }
        }
Exemple #3
0
        private void ProcessOcr(List <string> currentImages)
        {
            try
            {
                var datapath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\\tessdata";

                Results.AutoCorrect = chkSpell.Checked;

                using (var engine = new TesseractEngine(datapath, "fas+eng", EngineMode.Default))
                {
                    foreach (var image in currentImages)
                    {
                        using (var img = Pix.LoadFromFile(image))
                        {
                            using (var page = engine.Process(img))
                            {
                                var text = page.GetText();
                                Results.OcrResult += Environment.NewLine + text;
                            }
                        }
                    }
                } // engine

                var correctedSentance = string.Empty;
                if (Results.OcrResult.Trim().Length != 0)
                {
                    //Application.StatusBar = Util.UtilMessagesEnum.Processing;
                    if (Results.AutoCorrect)
                    {
                        //Results.OcrResult =Regex.Replace(Results.OcrResult, @"\r\n?|\n", " ");
                        var words = Results.OcrResult.Split(' ');

                        foreach (var word in words)
                        {
                            if (_checkSpell.Cheak_Spell(word.Trim()) == false)
                            {
                                correctedSentance += " " + _checkSpell.SuggestOne(word.Trim());
                            }
                            else
                            {
                                correctedSentance += " " + word;
                            }
                        }
                    }
                    else
                    {
                        correctedSentance = Results.OcrResult.Trim();
                    }

                    Results.OcrResult = correctedSentance;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message + exception.StackTrace);
            }
        }