Пример #1
0
        private void OnRecognizeText(object parameter)
        {
            if (!CanRecognizeText(parameter))
            {
                return;
            }

            int i           = 0;
            var textBuilder = new StringBuilder();

            foreach (var word in CharacterIsolation.Words)
            {
                if (word.LineIndex != i)
                {
                    i = word.LineIndex;
                    textBuilder.Append("\n");
                    Correction.Text = textBuilder.ToString();
                }

                foreach (var character in word.Characters)
                {
                    CharacterRecognition.CharacterZone = character;
                    CharacterRecognition.Compute();
                    textBuilder.Append(CharacterRecognition.RecognizedCharacter);
                }

                textBuilder.Append(" ");
            }

            Correction.Text = textBuilder.ToString();
            CorrectTextCommand.RaiseCanExecuteChanged();
        }
Пример #2
0
        private void OnLoadDictionary(object parameter)
        {
            if (!CanLoadDictionary(parameter))
            {
                return;
            }

            var dialog = new OpenFileDialog();

            dialog.Title  = "Select dictionary ...";
            dialog.Filter = "Dictionary (*.txt)|*.txt";

            if (dialog.ShowDialog() == true)
            {
                LoadDictionary(dialog.FileName);
            }

            CorrectTextCommand.RaiseCanExecuteChanged();
        }
Пример #3
0
        private void OnDistanceChanged()
        {
            if (UseHammingDistance)
            {
                Correction = new Correction(Original, new WordTree(new HammingDistance(false),
                                                                   new HammingDistance('?', false), new FrequencyResolver()));
            }
            if (UseLevenstheinDistance)
            {
                Correction = new Correction(Original, new WordTree(new LevenshteinDistance(),
                                                                   new LevenshteinDistance(), new FrequencyResolver()));
            }

            if (!string.IsNullOrEmpty(DictionaryFilePath))
            {
                LoadDictionary(DictionaryFilePath);
            }

            CorrectTextCommand.RaiseCanExecuteChanged();
        }