Beispiel #1
0
    def test_summary_sentences(self):
        # Check to see that we can break up the summary
        # back into its original sentences.

        from argos.core.brain import summarizer
        title = 'Syria Misses New Deadline as It Works to Purge Arms'
        text = 'Syria missed a revised deadline on Sunday for completing the export or destruction of chemicals in its weapons arsenal, but the government of the war-ravaged country may be only days away from finishing the job, according to international experts overseeing the process. The Syrian government had agreed to complete the export or destruction of about 1,200 tons of chemical agents by April 27 after missing a February deadline, but by Sunday, it had shipped out or destroyed 92.5 percent of the arsenal, said Sigrid Kaag, the coordinator of the joint mission by the United Nations and the watchdog agency the Organization for the Prohibition of Chemical Weapons.'
        expected_sents = summarizer.summarize(title, text)

        source = Source()
        source.name = 'Super Cool Times'

        article = Article(
                        title=title,
                        text=text,
                        score=100)
        article.source = source
        article.ext_url = 'http://foo.com'

        self.event=Event([article])

        expected = [{
            'sentence': sent,
            'source': 'Super Cool Times',
            'url': 'http://foo.com'
        } for sent in expected_sents]

        self.assertEqual(self.event.summary_sentences, expected)
Beispiel #2
0
    def test_summary_sentences(self):
        # Check to see that we can break up the summary
        # back into its original sentences.

        from argos.core.brain import summarizer
        title = 'Syria Misses New Deadline as It Works to Purge Arms'
        text = 'Syria missed a revised deadline on Sunday for completing the export or destruction of chemicals in its weapons arsenal, but the government of the war-ravaged country may be only days away from finishing the job, according to international experts overseeing the process. The Syrian government had agreed to complete the export or destruction of about 1,200 tons of chemical agents by April 27 after missing a February deadline, but by Sunday, it had shipped out or destroyed 92.5 percent of the arsenal, said Sigrid Kaag, the coordinator of the joint mission by the United Nations and the watchdog agency the Organization for the Prohibition of Chemical Weapons.'
        expected_sents = summarizer.summarize(title, text)

        source = Source()
        source.name = 'Super Cool Times'

        article = Article(title=title, text=text, score=100)
        article.source = source
        article.ext_url = 'http://foo.com'

        self.event = Event([article])

        expected = [{
            'sentence': sent,
            'source': 'Super Cool Times',
            'url': 'http://foo.com'
        } for sent in expected_sents]

        self.assertEqual(self.event.summary_sentences, expected)
Beispiel #3
0
 def summarize(self):
     """
     Generate a summary for this cluster.
     """
     if len(self.members) == 1:
         member = self.members[0]
         self.summary = ' '.join(summarize(member.title, member.text))
     else:
         self.summary = ' '.join(multisummarize([m.text for m in self.members]))
     return self.summary
Beispiel #4
0
 def summarize(self):
     """
     Generate a summary for this cluster.
     """
     if len(self.members) == 1:
         member = self.members[0]
         self.summary = ' '.join(summarize(member.title, member.text))
     else:
         self.summary = ' '.join(
             multisummarize([m.text for m in self.members]))
     return self.summary
Beispiel #5
0
 def summarize(self):
     """
     Generate a summary for this cluster.
     """
     if self.members.count() == 1:
         member = self.members[0]
         summary_sentences = summarizer.summarize(member.title, member.text)
         self.summary = ' '.join(summary_sentences)
     else:
         summary_sentences = summarizer.multisummarize([m.text for m in self.members])
         self.summary = ' '.join(summary_sentences)
     return self.summary
Beispiel #6
0
 def summarize(self):
     """
     Generate a summary for this cluster.
     """
     if self.members.count() == 1:
         member = self.members[0]
         summary_sentences = summarizer.summarize(member.title, member.text)
         self.summary = ' '.join(summary_sentences)
     else:
         summary_sentences = summarizer.multisummarize(
             [m.text for m in self.members])
         self.summary = ' '.join(summary_sentences)
     return self.summary
Beispiel #7
0
 def test_summarize(self):
     doc = open('tests/data/multidoc/1.txt', 'r').read()
     summary = summarizer.summarize('Why the Middle Class Is Declining', doc, summary_length=5)
     summary_without_nones = list(filter(None, summary))
     self.assertEqual(len(summary_without_nones), 5)