Example #1
0
    def test_read_summary(self):
        #<html>
        #<head>
        #<title>SL.P.10.R.A.SL062003-01</title>
        #</head>
        #<body bgcolor="white">
        #<a name="1">[1]</a> <a href="#1" id=1>Poor nations demand trade subsidies from developed nations.</a>
        #</body>
        #</html>
        summary_fname = os.path.join(DATA_DIR, "models/SL.P.10.R.A.SL062003-01.html")
        summary = Doc.from_see(open(summary_fname).read())
        self.assertEqual(summary.id, "SL.P.10.R.A.SL062003-01")
        self.assertEqual(len(summary.sents), 1)

        first_sent = summary.sents[0]
        self.assertEqual(first_sent.text, "Poor nations demand trade subsidies from developed nations.")
Example #2
0
 def score_summary(self, summary, references, summary_id='A'):
     """``summary'' is a system-generated summary.
     ``references'' is a list of human-made reference summaries"""
     try:
         self._write_config(references, Doc(summary_id, summary))
         output = self._run_rouge()
         output = output.decode("utf-8")
         return self._parse_output(output)
     except CalledProcessError as e:
         print("Rouge returned a non-zero error code. Output was: ", file=sys.stderr)
         print("BEGIN OUTPUT ", file=sys.stderr)
         print(e.output, file=sys.stderr)
         print("END OUTPUT", file=sys.stderr)
         raise e
     finally:
         self._cleanup()
    def test_read_summary(self):
        #<html>
        #<head>
        #<title>SL.P.10.R.A.SL062003-01</title>
        #</head>
        #<body bgcolor="white">
        #<a name="1">[1]</a> <a href="#1" id=1>Poor nations demand trade subsidies from developed nations.</a>
        #</body>
        #</html>
        summary_fname = os.path.join(DATA_DIR,
                                     "models/SL.P.10.R.A.SL062003-01.html")
        summary = Doc.from_see(open(summary_fname).read())
        self.assertEqual(summary.id, "SL.P.10.R.A.SL062003-01")
        self.assertEqual(len(summary.sents), 1)

        first_sent = summary.sents[0]
        self.assertEqual(
            first_sent.text,
            "Poor nations demand trade subsidies from developed nations.")
Example #4
0
def sl2003_summary(kind, filename):
    summary_dir = os.path.join(SL2003_DIR, kind)
    summary_contents = open(os.path.join(summary_dir, filename)).read()
    return Doc.from_see(summary_contents)
Example #5
0
def sl2003_summary(kind, filename):
    summary_dir = os.path.join(SL2003_DIR, kind)
    summary_contents = open(os.path.join(summary_dir, filename)).read()
    return Doc.from_see(summary_contents)