public static List <string> SentenceRankingForGeneralSum(List <string> docs, int sumLen, int lineLenght, int wordCount, int ngramsNum) { /* * Sentence Ranking and extraction * for a document represented as a fileName: * 1) first the sentence similarity graph is formed * 2) than the fast node (sentence) ranking is applied * 3) top scoring sentences are extracted into final summary */ //Stopwatch sw = new Stopwatch(); //sw.Start(); SentenceSimilarityGraph ssGraph = new SentenceSimilarityGraph(); ssGraph.ngramsNum = ngramsNum; ssGraph.GenerateSSGraph(docs); int nn = ssGraph.senteceNames.Count; float beta = 0.15f; float[] pr = new float[nn]; float[] newpr = new float[nn]; for (int i = 0; i < nn; i++) { pr[i] = 1 / (float)nn; } for (int i = 0; i < nn; i++) { newpr[i] = (1 - beta) / (float)nn; } for (int k = 0; k < 10; k++) { for (int i = 0; i < ssGraph.OFF.Count - 1; i++) { int outd = ssGraph.OFF[i + 1] - ssGraph.OFF[i]; for (int j = ssGraph.OFF[i]; j <= (ssGraph.OFF[i + 1] - 1); j++) { newpr[ssGraph.NB[j]] += beta * (pr[i] / outd); } } pr = newpr; } List <string> summary = penaltyRankingExtraction(pr, ssGraph, sumLen, lineLenght, wordCount, docs); /* Dictionary<string, float> rankedOut = new Dictionary<string, float>(); * for (int k = 0; k < pr.Length; k++) * { * rankedOut[ssGraph.senteceNames[k]] = pr[k]; * } * * rankedOut = rankedOut.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value); * * var sorted = pr.Select((x, i) => new KeyValuePair<double, int>(x, i)).OrderByDescending(x => x.Key).ToList(); * * List<double> B = sorted.Select(x => x.Key).ToList(); * List<int> idx = sorted.Select(x => x.Value).ToList(); * * List<string> summary = new List<string>(); * int len = 0; * foreach (string line in rankedOut.Keys) * { * if (len < sumLen) // timeLine sumLen = 50; * { * if (line.Length > lineLenght && Helpers.GetWords(line).Count() > wordCount) // 80 6 * { * int index1 = line.IndexOf("- "); * string line1; * if (index1 > 0) * { * line1 = line.Substring(index1 + 2); * } * else * { * line1 = line; * } * * summary.Add(line1); * len += Helpers.GetWords(line1).Count(); * } * } * } * //sw.Stop(); * //Console.WriteLine(sw.ElapsedMilliseconds / (double)1000);*/ return(summary); }