Beispiel #1
0
        public void getWordsFromText(object parameter)
        {
            string        text  = (string)parameter;
            List <string> words = new List <string>();

            string pattern = @"[^\w’']|_|\x27";

            string[] splittedWords = Regex.Split(text, pattern).Where(s => s != "").ToArray();
            //Init progress bar on Form
            onProgressChangedListener.onProgressInitialized(splittedWords.Length);
            foreach (string splittedWord in splittedWords)
            {
                string word = splittedWord.Trim();
                if (word.Length > 0 && !Int32.TryParse(word, out int res))
                {
                    words.Add(word);
                }
                // Set new position on progress bar
                onProgressChangedListener.onProgressChanged();
            }
            onProgressChangedListener.onProgressCompleted();

            onWordsLoadedListener.onWordsFindingCompleted(words);
        }
Beispiel #2
0
        public void readTextFromFile()
        {
            string text = "";

            Word.Application wordApp = new Word.Application();
            wordApp.Documents.Open(ref fileName);
            Word.Document wordDoc = wordApp.ActiveDocument;
            //Init progress bar on Form
            onProgressChangedListener.onProgressInitialized(wordDoc.Paragraphs.Count);
            foreach (Word.Paragraph paragraph in wordDoc.Paragraphs)
            {
                string line = paragraph.Range.Text;
                text = string.Concat(text, line);
                //Set new position on progress bar
                onProgressChangedListener.onProgressChanged();
            }
            onProgressChangedListener.onProgressCompleted();
            wordApp.Quit();
            onTextLoadedListener.onTextLoadingCompleted(text);
        }