public string DisplaySummarize() { string result = "------------------------WORD COUNT-------------------\n"; string document = BuildTheDocument(); string[] allWords = KeywordResearcher.splitTheWordInString(document); Dictionary <string, int> wordCount = KeywordResearcher.WordsCount(allWords); foreach (KeyValuePair <string, int> d in wordCount) { result += d.Key + " : " + d.Value + " \n"; } result += "\n------------------QUESTION KEYWORD--------------------------------\n"; string[] questionKeyword = KeywordResearcher.GetKeywordArray(PageList[0].Question); foreach (string question in questionKeyword) { result += "question keyword : " + question + "\n"; } result += "\n----------------------SENTENCES--------------------------------------\n"; List <string> predictSentenceAllPage = CollectAllPredictSentenceAllPages(); foreach (string sentence in predictSentenceAllPage) { result += sentence + "\n***************\n"; } result += "\n--------------------------sentence analysis----------------\n"; List <string> sentences = FindBestPredictSentenceAllPages(); foreach (string sen in sentences) { result += sen + "\n********\n"; } return(result); }
//public bool IsContainAllQuestionKeyword( string sentence, string[] keys) //{ // return keys.All(x => sentence.ToLower().Contains(x)); //} //public bool IsContainAtLeastOneKeyword(string sentence, string[] keys) //{ // return keys.Any(w => sentence.ToLower().Contains(w)); //} public string[] SplitWords() { //string doc = Document.ToLower(); //doc = KeywordResearcher.FindKeyWord(doc); //doc = Regex.Replace(doc, @"[^a-zA-z]", " "); //return doc.Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries); return(KeywordResearcher.splitTheWordInString(Document)); }
public List <string> FindBestPredictSentenceAllPages() { string document = BuildTheDocument(); string[] allWords = KeywordResearcher.splitTheWordInString(document); string[] questionKeyword = KeywordResearcher.GetKeywordArray(PageList[0].Question); List <string> predictSentenceAllPage = CollectAllPredictSentenceAllPages(); QuestionAnalysis questionAnalysis = new QuestionAnalysis(PageList[0].Question); int count = questionKeyword.Length; List <string> sentences = new List <string>(); string key = ""; if (questionAnalysis.isShortAnswer()) { int num = PageList[0].Question.Split(' ').Count(); if (num > 8) { while (count > 0) { //sentences = KeywordResearcher.FindTheBestPredictSentence(count, questionKeyword, predictSentenceAllPage); key = QuestionWordCombine(count, questionKeyword); sentences = SentencesContainKeyCombine(key, predictSentenceAllPage); count = (sentences.Count != 0) ? 0 : --count; } } else { List <string> allquestionPosibleCombine = QuestionWordConbime2(PageList[0].Question); int predict = 0; for (int i = 0; i < allquestionPosibleCombine.Count; i++) { sentences.AddRange(SentencesContainKeyCombine(allquestionPosibleCombine[i], predictSentenceAllPage)); if (predict == 0 || predict <= allquestionPosibleCombine[i].Split(' ').Count() - 1 || sentences.Count == 0) { predict = allquestionPosibleCombine[i].Split(' ').Count() - 1; } else { break; } } } } else { while (count > 0) { sentences = KeywordResearcher.FindTheBestPredictSentence(count, questionKeyword, predictSentenceAllPage); count = (sentences.Count != 0) ? 0 : --count; } } return(sentences); }