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); }
public List <string> Priority2() { List <string> priority2 = new List <string>(); QuestionAnalysis questionFactory = new QuestionAnalysis(Question); string[] questionKeyword = questionFactory.FindKeywordInQuestion(); foreach (string s in Sentences) { if (KeywordResearcher.IsContainAtLeastOneKeyword(s, questionKeyword)) { priority2.Add(s); } } return(priority2); }
public List <string> FindTheBestPredictSentence(int NumberOfWords) { //int topWord = NumberOfWords; //List<string> priority1 = new List<string>(); //string[] keys = BestPredictWord(topWord); //foreach (string s in Sentences) //{ // if (IsContainAllQuestionKeyword(s, keys)) // { // priority1.Add(s + "\nTOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOP: "+ topWord +"The Words : " + DisplayTopWord(keys)); // } //} //return priority1; return(KeywordResearcher.FindTheBestPredictSentence(NumberOfWords, SplitWords(), Sentences)); }
public string[] BestPredictWord(int topNumberOfPredictWords) { //int topWord = topNumberOfPredictWords; //string[] keys = new string[topWord]; //Dictionary<string, int> wordCount = WordsCount(); //int count = 0; //foreach (KeyValuePair<string, int> word in wordCount.Take(topWord)) //{ // keys[count] = word.Key; // count++; //} ////IEnumerable<KeyValuePair<string,int>> test = wordCount.Take(5); //return keys; return(KeywordResearcher.BestPredictWord(topNumberOfPredictWords, SplitWords())); }
public Dictionary <string, int> WordsCount() { //Dictionary<string, int> wordCountDic = new Dictionary<string, int>(); //string[] allWords = SplitWords(); //foreach (string word in allWords) //{ // if (!wordCountDic.ContainsKey(word)) // { // wordCountDic.Add(word, 1); // } // else // { // wordCountDic[word] = wordCountDic[word] +1; // } //} //wordCountDic = wordCountDic.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value); //return wordCountDic; string[] allWords = SplitWords(); return(KeywordResearcher.WordsCount(allWords)); }
public string[] FindKeywordInQuestion() { return(KeywordResearcher.GetKeywordArray(question)); }