private DocX CreateDocX(ArticleGradingInfo i_ArticleGradingInfo, string i_Path)
        {
            using (DocX doc = DocX.Create(i_Path))
            {
                Paragraph stat = doc.InsertParagraph("Result:").Font(new System.Drawing.FontFamily("Arial")).FontSize(15D).Bold().UnderlineStyle(UnderlineStyle.singleLine);
                stat.AppendLine(string.Format("Common: {0}%, {1}  \nNormal: {2}%, {3} \nRare: {4}%, {5} \nScore: {6} \nNumber Of Words: {7}\n\n\n"
                                              , Math.Round((double)i_ArticleGradingInfo.CommonWords.Count / i_ArticleGradingInfo.CleanedWords.Count * 100), i_ArticleGradingInfo.CommonWords.Count
                                              , Math.Round((double)i_ArticleGradingInfo.NormalWords.Count / i_ArticleGradingInfo.CleanedWords.Count * 100), i_ArticleGradingInfo.NormalWords.Count
                                              , Math.Round((double)i_ArticleGradingInfo.RareWords.Count / i_ArticleGradingInfo.CleanedWords.Count * 100), i_ArticleGradingInfo.RareWords.Count
                                              , Math.Round(100 - ((i_ArticleGradingInfo.NormalWords.Count * 0.5f + i_ArticleGradingInfo.RareWords.Count) * 100 / i_ArticleGradingInfo.CleanedWords.Count)).ToString()
                                              , i_ArticleGradingInfo.CleanedWords.Count.ToString()));

                stat.FontSize(13D);

                Paragraph wordParagraph = doc.InsertParagraph();

                foreach (string word in i_ArticleGradingInfo.Words)
                {
                    string cleanedWord = TextGrading.CleanWord(word).ToLower();

                    wordParagraph.Append(word);
                    wordParagraph.Font(new System.Drawing.FontFamily("Arial"));
                    wordParagraph.FontSize(12D);
                    wordParagraph.Bold();

                    if (i_ArticleGradingInfo.RareWords.Contains(cleanedWord))
                    {
                        wordParagraph.Color(System.Drawing.Color.Red);
                    }
                    else if (i_ArticleGradingInfo.NormalWords.Contains(cleanedWord))
                    {
                        wordParagraph.Color(System.Drawing.Color.Orange);
                    }
                    else
                    {
                        wordParagraph.Color(System.Drawing.Color.Black);
                    }
                }

                doc.Save();

                return(doc);
            }
        }
        public ActionResult Index(string ContentTA, HttpPostedFileBase ArticleFU)
        {
            ArticleGradingInfo articleGradingInfo = null;
            bool   fileCantBeGraded = false;
            string text             = null;

            if (ArticleFU != null)
            {
                if (ArticleFU.VerifyArticleType())
                {
                    try
                    {
                        string extension = ArticleFU.FileName.ToLower().Substring(ArticleFU.FileName.LastIndexOf('.') + 1);
                        text = TextGrading.LoadTextFromFile(ArticleFU.InputStream, extension);
                        articleGradingInfo      = TextGrading.AnalyzeSingleText(text);
                        articleGradingInfo.Name = ArticleFU.FileName.Substring(0, ArticleFU.FileName.LastIndexOf('.'));

                        Logger.UpdateNumberOfUses(1);
                    }
                    catch
                    {
                        fileCantBeGraded = true;
                    }
                }
                else
                {
                    fileCantBeGraded = true;
                }
            }
            else
            {
                articleGradingInfo = TextGrading.AnalyzeSingleText(ContentTA);
                Logger.UpdateNumberOfUses(1);
            }


            if (fileCantBeGraded)
            {
                articleGradingInfo       = new ArticleGradingInfo();
                articleGradingInfo.Error = "File can not be graded.";
            }

            return(View(articleGradingInfo));
        }
        private List <ArticleGradingInfo> getArticlesGradingInfoList(IEnumerable <HttpPostedFileBase> i_Articles)
        {
            List <ArticleGradingInfo> articlesGradingInfo = new List <ArticleGradingInfo>();
            string text = null, name;

            if (i_Articles != null)
            {
                foreach (var article in i_Articles)
                {
                    ArticleGradingInfo currentArticleInfo = null;

                    if (article.VerifyArticleType())
                    {
                        try
                        {
                            string extension = article.FileName.ToLower().Substring(article.FileName.LastIndexOf('.') + 1);
                            name = article.FileName.ToLower().Substring(0, article.FileName.LastIndexOf('.'));
                            text = TextGrading.LoadTextFromFile(article.InputStream, extension);

                            currentArticleInfo      = TextGrading.AnalyzeSingleText(text);
                            currentArticleInfo.Name = name + extension;
                        }
                        catch
                        {
                            articlesGradingInfo.Clear();
                            break;
                        }
                    }
                    else
                    {
                        articlesGradingInfo.Clear();
                        break;
                    }

                    if (!string.IsNullOrEmpty(text) && currentArticleInfo.Error == null)
                    {
                        articlesGradingInfo.Add(currentArticleInfo);
                    }
                }
            }

            return(articlesGradingInfo);
        }