예제 #1
0
 def test_spacy_summarization(self):
     """Pass the intervals to summarizer"""
     if "spacy" in SUMMS:
         asd = [
             {"minutes": 60, "size": 2, "txt": u"Summary for first 60 minutes:\n"},
             {"hours": 12, "size": 1, "txt": u"Summary for last 12 hours:\n"},
         ]
         summ = None
         lsa_summ = lsa.LsaSummarizer()
         summ = SpacyTsSummarizer()
         for rs in asd:
             summ.set_summarizer(lsa_summ)
             summ.set_channel("elasticsearch")
             logger.debug("Testing spacy summarizer")
             sumry = summ.summarize(TestSummarize.test_msgs, range_spec=rs)
             logger.debug("Summary is %s, length %s", sumry, len(sumry))
             self.assertTrue(len(sumry) > 1)
     else:
         pass
예제 #2
0
 def get_summary(self, **args):
     channel_id = args['channel_id'] if 'channel_id' in args else None
     channel_name = args['channel_name'] if 'channel_name' in args else None
     user_id = args['user_id'] if 'user_id' in args else None
     user_name = args['user_name'] if 'user_name' in args else None
     params = args['params'] if 'params' in args else None
     request_id = uuid.uuid1()
     response = None
     msgs = None
     if self.test:
         with io.open(TEST_JSON, encoding='utf-8') as iot:
             msgs = json.load(iot)[u'messages']
     else:
         msgs = self.get_messages(channel_id, params)
     summ_object = args['summ']
     summ_impl = None
     summary = u''
     if summ_object and "spacy" in SUMMS:
         self.logger.info(u'Using spacy')
         summ_impl = SpacyTsSummarizer()
         summ_impl.set_summarizer(summ_object)
     elif "gensim" in SUMMS:
         self.logger.info(u'Using gensim')
         summ_impl = TextRankTsSummarizer()
     if summ_impl:
         summ_impl.set_channel(channel_name)
         summary = summ_impl.summarize(msgs)
     else:
         self.logger.warn(u'No summarizer was set!')
     self.logger.info(u'Summary request %s user_id: %s', request_id,
                      user_id)
     self.logger.info(u'Summary request %s channel_name: %s', request_id,
                      channel_name)
     self.logger.info(u'Summary request %s parameters: %s', request_id,
                      params)
     self.logger.debug(u'Summary request %s messages: %s', request_id, msgs)
     self.logger.info(u'Summary request %s summary:\n %s', request_id,
                      summary)
     res = u"*Chat Summary:* \n " + summary + "\n \n"
     return res
예제 #3
0
    def get_summary(self, **args):
        channel_id = args['channel_id'] if 'channel_id' in args else None
        channel_name = args['channel_name'] if 'channel_name' in args else None
        user_id = args['user_id'] if 'user_id' in args else None
        user_name = args['user_name'] if 'user_name' in args else None
        params = args['params'] if 'params' in args else None
        request_id = uuid.uuid1()
        response = None
        msgs = None
        if self.test:
            with io.open(TEST_JSON, encoding='utf-8') as iot:
                msgs = json.load(iot)[u'messages']
        else:
            msgs = self.get_messages(channel_id, params)
        summ_object = args['summ']
        summ_impl = None
        summary = u''
        if summ_object and "spacy" in SUMMS:
            self.logger.info(u'Using spacy')
            summ_impl = SpacyTsSummarizer()
            summ_impl.set_summarizer(summ_object)
        elif "gensim" in SUMMS:
            self.logger.info(u'Using gensim')
            summ_impl = TextRankTsSummarizer()
        if summ_impl:
            summ_impl.set_channel(channel_name)
            summary = summ_impl.summarize(msgs)
        else:
            self.logger.warn(u'No summarizer was set!')
        self.logger.info(u'Summary request %s user_id: %s', request_id, user_id)
        self.logger.info(u'Summary request %s channel_name: %s', request_id, channel_name)
        self.logger.info(u'Summary request %s parameters: %s', request_id, params)
        self.logger.debug(u'Summary request %s messages: %s', request_id, msgs)
        self.logger.info(u'Summary request %s summary:\n %s', request_id, summary)
	res = u"*Chat Summary:* \n " + summary + "\n \n"
        return res
예제 #4
0
 def test_spacy_summarization(self):
     """Pass the intervals to summarizer"""
     if "spacy" in SUMMS:
         asd = [{
             'minutes': 60,
             'size': 2,
             'txt': u'Summary for first 60 minutes:\n'
         }, {
             'hours': 12,
             'size': 1,
             'txt': u'Summary for last 12 hours:\n'
         }]
         summ = None
         lsa_summ = lsa.LsaSummarizer()
         summ = SpacyTsSummarizer()
         for rs in asd:
             summ.set_summarizer(lsa_summ)
             summ.set_channel('elasticsearch')
             logger.debug("Testing spacy summarizer")
             sumry = summ.summarize(TestSummarize.test_msgs, range_spec=rs)
             logger.debug("Summary is %s, length %s", sumry, len(sumry))
             self.assertTrue(len(sumry) > 1)
     else:
         pass