Esempio n. 1
0
        public void Upload(IEnumerable <string> paths, string language, string method)
        {
            foreach (var path in paths)
            {
                var termsFromFile = DocumentService.FromPDF(path);
                IDictionary <string, double> termsProbability = null;

                if (method == FrequencyWordLanguageRecognizer.MethodName)
                {
                    termsProbability = FrequencyWordRecognizer.GetWords(termsFromFile);
                }
                else if (method == ShortWordLanguageRecognizer.MethodName)
                {
                    termsProbability = ShortWordRecognizer.GetWords(termsFromFile);
                }

                foreach (var(word, probability) in termsProbability)
                {
                    var newWord = new LanguageWord
                    {
                        Language    = language,
                        Method      = method,
                        Probability = probability,
                        Word        = word
                    };

                    if (!LanguageWord.Words.Contains(newWord, new LanguageWord.Comparer()))
                    {
                        LanguageWord.Words.Add(newWord);
                    }
                }
            }

            ButtonRecognize.IsEnabled = true;
        }
Esempio n. 2
0
        private void ButtonRecognize_OnClick(object sender, RoutedEventArgs e)
        {
            var index = UploadPath.Text.IndexOf("*", StringComparison.Ordinal);
            var path  = UploadPath.Text.Substring(0, index <= 0 ? UploadPath.Text.Length : index);
            var text  = DocumentService.FromPDF(path);

            LangsLabel.Content = "Frequency M: " + FrequencyWordRecognizer.Recognize(text) +
                                 ", Short M: " + ShortWordRecognizer.Recognize(text) +
                                 ", Own M: " + OwnRecognizer.Recognize(text);
        }