/// <summary>
        /// Populates result after indexer completes
        /// </summary>
        private void BackgroundWorker_WorkCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            ProgressValue        = 0;
            IsIndexingInProgress = false;
            HasIndexingResult    = true;
            NotifyPropertyChanged(() => HasIndexingResult);
            UpdateCanStartIndexing();

            if (e.Error != null)
            {
                Status = e.Error.Message;
                return;
            }

            if (e.Cancelled)
            {
                Status = "Process Cancelled.";
                return;
            }

            IndexerResult result = (IndexerResult)e.Result;

            if (result == null)
            {
                Status = "Process did not return any result.";
                return;
            }

            IdentifierCount        = result.GetSplitResultList().Count;
            DictionaryWordsCount   = result.GetDictionaryWordList().Count;
            TokensCount            = result.GetTokenList().Count;
            UnidentifiedWordsCount = result.GetUnidentifiedList().Count;

            DictionaryWords   = string.Join(Environment.NewLine, result.GetDictionaryWordList().Keys.OrderBy(x => x).ThenBy(x => x.Length));
            Tokens            = string.Join(Environment.NewLine, result.GetTokenList().Keys.OrderBy(x => x).ThenBy(x => x.Length));
            UnidentifiedWords = string.Join(Environment.NewLine, result.GetUnidentifiedList().Keys.OrderBy(x => x.Length).ThenBy(x => x));
            CorrectedWords    = string.Join(Environment.NewLine, result.GetCorrectionDictionary().OrderBy(x => x.Key).Select(x => x.Key + ": " + x.Value.Word));
            StemmedWords      = string.Join(Environment.NewLine, result.GetStemmedDictionary().OrderBy(x => x.Key).Select(x => x.Key + ": " + x.Value.Word));

            NotifyPropertyChanged(() => IdentifierCount);
            NotifyPropertyChanged(() => DictionaryWordsCount);
            NotifyPropertyChanged(() => TokensCount);
            NotifyPropertyChanged(() => UnidentifiedWordsCount);
            NotifyPropertyChanged(() => DictionaryWords);
            NotifyPropertyChanged(() => UnidentifiedWords);
            NotifyPropertyChanged(() => Tokens);
            NotifyPropertyChanged(() => StemmedWords);
            NotifyPropertyChanged(() => CorrectedWords);

            _result = result;
            Status  = "";
        }
        public void Export(string exportFolderPath)
        {
            exportFolderPath = exportFolderPath.TrimEnd('\\');
            using (StreamWriter fileWriter = new StreamWriter(exportFolderPath + "\\" + _projectStat.Name + "_file.txt", true))
            {
                SelectedFiles.ToList().ForEach(file =>
                {
                    var allWords = _result.GetDictionaryWordList().Where(x => x.Value.Contains(file)).Select(x => x.Key).OrderBy(x => x).ThenBy(x => x.Length)
                                   .Union(_result.GetTokenList().Where(x => x.Value.Contains(file)).Select(x => x.Key).OrderBy(x => x).ThenBy(x => x.Length))
                                   .Union(_result.GetUnidentifiedList().Where(x => x.Value.Contains(file)).Select(x => x.Key).OrderBy(x => x.Length).ThenBy(x => x))
                                   .Union(_result.GetCorrectionDictionary().Where(x => x.Value.IndexerFiles.Contains(file)).Select(x => x.Key).OrderBy(x => x))
                                   .Union(_result.GetStemmedDictionary().OrderBy(x => x.Key).Where(x => x.Value.IndexerFiles.Contains(file)).Select(x => x.Key).OrderBy(x => x));
                    fileWriter.WriteLine(file.Name + " " + string.Join(" ", allWords));
                    fileWriter.Flush();
                });
            }

            File.WriteAllLines(exportFolderPath + "\\" + _projectStat.Name + "_tokens.txt",
                               new[] { "Natural Words:" }
                               .Union(_result.GetDictionaryWordList().Keys.OrderBy(x => x).ThenBy(x => x.Length))
                               .Union(new[] { "Abbreviations:" })
                               .Union(_result.GetTokenList().Keys.OrderBy(x => x).ThenBy(x => x.Length))
                               .Union(new[] { "Unidentified Words:" })
                               .Union(_result.GetUnidentifiedList().Keys.OrderBy(x => x.Length).ThenBy(x => x))
                               .Union(new[] { "Spell Checking:" })
                               .Union(_result.GetCorrectionDictionary().OrderBy(x => x.Key).Select(x => x.Key + ": " + x.Value.Word))
                               .Union(new[] { "Stemmed Words:" })
                               .Union(_result.GetStemmedDictionary().OrderBy(x => x.Key).Select(x => x.Key + ": " + x.Value.Word)));

            using (StreamWriter fileWriter = new StreamWriter(exportFolderPath + "\\" + _projectStat.Name + "_split.html", false))
            {
                fileWriter.WriteLine("<!DOCTYPE HTML><html><head><style>span{margin: 5px;}.unidentified{color: red;}.identified{color: black;}.token{color: blue;}.misspelled{color: green}.stemmed{color: #AA3333;}</style></head><body>");
                fileWriter.WriteLine("<h3>Color Index</h3>");
                fileWriter.WriteLine("<span class='identified'>Natural word</span><br />");
                fileWriter.WriteLine("<span class='unidentified'>Unidentified word</span><br />");
                fileWriter.WriteLine("<span class='token'>Abbreviation</span><br />");
                fileWriter.WriteLine("<span class='misspelled'>Misspelled word</span><br />");
                fileWriter.WriteLine("<span class='stemmed'>Stemmed/Lemmatized word</span><br />");
                fileWriter.WriteLine("<br />");
                fileWriter.WriteLine("<h3>Splits</h3>");
                StringBuilder stringBuilder = new StringBuilder();
                _result.GetSplitResultList().ToList().ForEach(identifierSplitResult =>
                {
                    stringBuilder.Append("<div class='");
                    if (identifierSplitResult.Splits.Any(x => x.SplitIdentification == SplitIdentification.Unidentified))
                    {
                        stringBuilder.Append("has-unidentified");
                    }
                    if (identifierSplitResult.Splits.Any(x => x.SplitIdentification == SplitIdentification.Token || x.SplitIdentification == SplitIdentification.MergedToken))
                    {
                        stringBuilder.Append("has-token");
                    }
                    if (identifierSplitResult.Splits.Any(x => x.SplitIdentification == SplitIdentification.TokenMisspelled || x.SplitIdentification == SplitIdentification.WordMisspelled))
                    {
                        stringBuilder.Append("has-misspelled");
                    }
                    stringBuilder.Append("'>" + identifierSplitResult.Identifier + ": ");
                    identifierSplitResult.Splits.ToList().ForEach(split =>
                    {
                        switch (split.SplitIdentification)
                        {
                        case SplitIdentification.Identified:
                            stringBuilder.Append("<span class='identified'>");
                            break;

                        case SplitIdentification.Unidentified:
                            stringBuilder.Append("<span class='unidentified'>");
                            break;

                        case SplitIdentification.MergedToken:
                        case SplitIdentification.Token:
                        case SplitIdentification.SingleLetterIdentifier:
                            stringBuilder.Append("<span class='token'>");
                            break;

                        case SplitIdentification.TokenMisspelled:
                        case SplitIdentification.WordMisspelled:
                            stringBuilder.Append("<span class='misspelled'>");
                            break;

                        case SplitIdentification.WordStemmed:
                        case SplitIdentification.TokenStemmed:
                            stringBuilder.Append("<span class='stemmed'>");
                            break;
                        }
                        stringBuilder.Append(split.Split);
                        stringBuilder.Append("</span>");
                    });
                    stringBuilder.Append("</div>");
                    fileWriter.WriteLine(stringBuilder.ToString());
                    stringBuilder.Clear();
                });

                fileWriter.WriteLine("</body></html>");
            }
        }