1- using System ;
2- using System . Collections . Generic ;
3- using System . Linq ;
1+ using System . Linq ;
42using System . Text ;
3+ using System . Collections . Generic ;
4+
55using PageRank . Rank ;
66using TextRank . Helpers ;
77using TextRank . POSTagger ;
@@ -15,19 +15,16 @@ internal sealed class ExtractSummary
1515 public string ExtractParagraphSummary ( string paragraph , int wordLength = 100 )
1616 {
1717 var taggedSentences = SentencePOSTagger . GetTaggedSentences ( paragraph ) ;
18-
1918 var directedGraph = GraphUtil . GraphInstance . BuildPOSGraph < string > ( taggedSentences ) ;
20-
21-
2219 var rankedDictionary = new PageRank < string > ( ) . Rank ( directedGraph ) ;
23-
2420 var rankedSentencesList = rankedDictionary ? . ToList ( ) . OrderByDescending ( p => p . Value ) . Select ( x => x . Key ) . ToList ( ) ;
25- var top_sentences = new List < string > ( ) ;
21+ var topSentences = new List < string > ( ) ;
2622
2723 if ( rankedSentencesList != null )
2824 {
2925 int wordCount = 0 ;
3026 int index = 0 ;
27+
3128 foreach ( var sentences in rankedSentencesList )
3229 {
3330 wordCount = sentences . Split ( null ) . Length + wordCount ;
@@ -36,31 +33,29 @@ public string ExtractParagraphSummary(string paragraph, int wordLength =100)
3633 break ;
3734 }
3835 index ++ ;
39-
4036 }
41- if ( wordCount < wordLength ) index -- ;
42-
43- top_sentences = rankedSentencesList . Take ( index ) . ToList ( ) ;
4437
38+ if ( wordCount < wordLength ) index -- ;
39+ topSentences = rankedSentencesList . Take ( index ) . ToList ( ) ;
4540 }
4641
4742 StringBuilder summry = new StringBuilder ( "" ) ;
4843
49- foreach ( var sent in taggedSentences )
44+ foreach ( var taggedSentence in taggedSentences )
5045 {
51- foreach ( var summary_sentence in top_sentences )
46+ foreach ( var summarySentence in topSentences )
5247 {
53- if ( summary_sentence . Equals ( sent ) )
48+ if ( summarySentence . Equals ( taggedSentence ) )
5449 {
55- summry . Append ( summary_sentence ) ;
50+ summry . Append ( summarySentence ) ;
5651 summry . Append ( "<br/><br/>" ) ;
5752 }
5853 }
5954 }
6055
61- var orig_length = paragraph . Length ;
62- var summary = summry . ToString ( ) ; //string.Join(" ", summary_word);
63- var summarized_length = summry . Length ;
56+ var origLength = paragraph . Length ;
57+ var summary = summry . ToString ( ) ;
58+ var summarizedLength = summry . Length ;
6459
6560 return summary ;
6661 }
0 commit comments