Пример #1
0
    def perform(self, input):
        self.logger.info('Received results')
        message = Serializer.parse(input, Message)
        if message.type == 'command':
            self.logger.debug("Received command message")
            if message.body == 'DIE':
                self.logger.info('Received the poison pill')
                self.stop()
            elif message.body.startswith('SAVE'):
                self.logger.debug("Received the SAVE command.")
                parts = message.body.split(' ')
                if len(parts) > 1:
                    self.save(parts[1])
                else:
                    self.save()
            elif message.body == 'RESET':
                self.logger.info("Clearing the question list.")
                self.questions = list()
            else:
                self.logger.warn("Unknown command message: %s", message.body)
            return

        question = Question(message.body)
        self.logger.debug("Received results for question %s", question.id)
        self.questions.append(Question(message.body))
Пример #2
0
    def perform(self, input):
        message = Serializer.parse(input, Message)
        if message.type == 'command':
            self.logger.debug("Received command message")
            if message.body == 'DIE':
                self.logger.info('Received the poison pill')
                self.stop()
                return
            else:
                self.logger.warn("Unknown command message: %s", message.body)

        question = Question(message.body)
        question.exact_answer = self.tileSentences(question.ranked)
        message.body = question
        self.logger.debug('Delivering the message to next target')
        self.deliver(message)
Пример #3
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)
Пример #4
0
    def perform(self, input):
        self.logger.info("Input received from route %s", self.route)
        message = Serializer.parse(input, Message)
        if message.type == 'command':
            self.logger.debug("Received command message")
            if message.body == 'DIE':
                self.logger.info("Received the poison pill.")
                self.stop()
            else:
                self.logger.warn("Unknown command message: %s", message.body)
        else:
            self.logger.info('Ranking sentences.')
            self.logger.debug("Message body is a %s", str(type(message.body)))
            question = Question(message.body)
            question.ranked = self.getRankedList(question)
            message.body = question

        self.logger.debug('Delivering the message to next target')
        self.deliver(message)
Пример #5
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)
Пример #6
0
            u'offsetInEndSection': 1716,
            u'text':
            u' Overall, in post menopausal women, HRT use appeared to confer a non-significant protective effect, and was not associated with low or high PR expressing meningiomas.CONCLUSION: This study found little evidence of associations between meningioma and exogenous hormone exposures in women but did suggest that some hormonal exposures may influence tumor biology in those women who develop meningioma.',
            u'beginSection': u'abstract',
            u'document': u'http://www.ncbi.nlm.nih.gov/pubmed/16759391',
            u'endSection': u'abstract'
        }, {
            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(input)
    sci = SoftMMR()
    sentences = sci.getRankedList(question)
    print 'Q. ' + question.body
    for i, s in enumerate(sentences):
        print "{}. {}".format(i, s)
Пример #7
0
            u'offsetInEndSection': 1716,
            u'text':
            u' Overall, in post menopausal women, HRT use appeared to confer a non-significant protective effect, and was not associated with low or high PR expressing meningiomas.CONCLUSION: This study found little evidence of associations between meningioma and exogenous hormone exposures in women but did suggest that some hormonal exposures may influence tumor biology in those women who develop meningioma.',
            u'beginSection': u'abstract',
            u'document': u'http://www.ncbi.nlm.nih.gov/pubmed/16759391',
            u'endSection': u'abstract'
        }, {
            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)
    sci = Splitter()
    sentences = sci.perform(question)
    print 'Q. ' + question.body
    for i, s in enumerate(sentences):
        print "{}. {}".format(i, s)
Пример #8
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)
Пример #9
0
from deiis.model import Question

if __name__ == '__main__':
    question = Question({
        'body': 'Why are we using Python?',
        'ranked': ['1', '2', '3']
    })
    print question.body
    print question.ranked
Пример #10
0
            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(input)
    # print question.body

    message = Message()
    message.route.append('results')
    message.body = input

    json = Serializer.to_pretty_json(message)
    print json
    message = Serializer.parse(json, Message)

    print 'Route: ' + ', '.join(message.route)
    question = Question(message.body)
    print question.body
    for snippet in question.snippets:
        print snippet.text