_binary From 993a7c72cc380b98936760849f83fae86d5aaf96 Mon Sep 17 00:00:00 2001
From: diesal9 <charles.bocage@sjsu.edu>
Date: Wed, 18 May 2016 22:00:48 -0700
Subject: [PATCH] I found a bug in the Graph Based summarizer.  There were two
 methods with the same name and the getsentence method would return an empty
 array component at the end of the array sometimes.

---
 src/library/summarizers/GraphBasedSummarizer.php | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/library/summarizers/GraphBasedSummarizer.php b/src/library/summarizers/GraphBasedSummarizer.php
index 6851186..c90ed67 100644
--- a/src/library/summarizers/GraphBasedSummarizer.php
+++ b/src/library/summarizers/GraphBasedSummarizer.php
@@ -84,7 +84,8 @@ class GraphBasedSummarizer extends Summarizer
             $sentences, $lang, $unmodified_doc);
         $p = self::getSentenceRanks($adjacency);
         $sentences_with_punctuation = self::getSentences($page . " ", true);
-        $summary = self::getSummary($sentences_with_punctuation, $p, $lang);
+        $summary = self::getFinalSummary($sentences_with_punctuation, $p,
+            $lang);
         return [$summary, []];
     }
     /**
@@ -95,7 +96,7 @@ class GraphBasedSummarizer extends Summarizer
      *     call proper tokenizer.php of the specified language.
      * @return string a string that represents the summary
      */
-    public static function getSummary($sentences, $p, $lang)
+    public static function getFinalSummary($sentences, $p, $lang)
     {
         $output_file_contents = "";
         $result = "";
@@ -318,6 +319,7 @@ class GraphBasedSummarizer extends Summarizer
      */
     public static function getSentences($content, $keep_punctuation)
     {
+        $result = [];
         if ($keep_punctuation) {
             $sentences =
                 preg_split('/(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?|\!)/u',
@@ -326,12 +328,14 @@ class GraphBasedSummarizer extends Summarizer
             for ($i = 0; $i < $n; $i++ ) {
                 $sentences[$i] = trim($sentences[$i]);
             }
-            return $sentences;
+            $result = array_filter($sentences);
         } else {
-            return preg_split(
+            $sentences = preg_split(
                 '/(\.|\||\!|\?|！|？|。)\s+|(\n|\r)(\n|\r)+|\s{5}/u',
                 $content, 0, PREG_SPLIT_NO_EMPTY);
+            $result = array_filter($sentences);
         }
+        return $result;
     }
     /**
      * Normalize the term frequencies based on the sum of the squares.
-- 
1.9.5.github.0

