Beispiel #1
0
    def perform(self, input):
        message = Serializer.parse(input, Message)
        if message.type == 'command':
            if message.body == 'DIE':
                self.logger.info("Received command message DIE")
                self.stop()
            else:
                self.logger.error('Unknown command message: %s', message.body)

            self.deliver(message)

        question = Question(message.body)
        question.tokens = word_tokenize(question.body)
        for snippet in question.snippets:
            snippet.sentences = self.tokenize(snippet.text)

        message.body = question
        self.deliver(message)
Beispiel #2
0
    def perform(self, input):
        """"""
        """ Kaichen Chen 0304 """
        print "Splitter {}: received, start to perform.".format(time())

        message = Serializer.parse(input, Message)
        if message.type == 'command':
            if message.body == 'DIE':
                self.logger.info("Received command message DIE")
                self.stop()
            else:
                self.logger.error('Unknown command message: %s', message.body)

            self.deliver(message)

        question = Question(message.body)
        question.tokens = word_tokenize(question.body)
        for snippet in question.snippets:
            snippet.sentences = self.tokenize(snippet.text)

        message.body = question
        self.deliver(message)
Beispiel #3
0
        }, {
            u'offsetInBeginSection': 1276,
            u'offsetInEndSection': 1608,
            u'text':
            u'The increased odds ratios with African Americans was retained in post-menopausal women, while the protective odds ratios for pregnancy, smoking and oral contraceptives (OCs) became stronger in pre-menopausal women. The pattern by duration and timing of use does not suggest an etiologic role for OCs or hormone replacement therapy. ',
            u'beginSection': u'abstract',
            u'document': u'http://www.ncbi.nlm.nih.gov/pubmed/16570277',
            u'endSection': u'abstract'
        }, {
            u'offsetInBeginSection': 1044,
            u'offsetInEndSection': 1221,
            u'text':
            u'The use of hormone replacement therapy in symptomatic postmenopausal women either with previously treated disease or with dormant tumors is discussed, but remains controversial.',
            u'beginSection': u'abstract',
            u'document': u'http://www.ncbi.nlm.nih.gov/pubmed/15006250',
            u'endSection': u'abstract'
        }]
    }
    question = Question(data)
    question.tokens = word_tokenize(question.body)
    for snippet in question.snippets:
        snippet.sentences = tokenize(snippet.text)
    sci = CoreMMR()
    sentences = sci.getRankedList(question)

    print sentences

    print 'Q. ' + question.body
    for i, s in enumerate(sentences):
        print "{} {}".format(i, s)