Example #1
0
 def deliver(self, message):
     """Sends the message to the next target, if any."""
     target = message.forward()
     if target is not None:
         self.logger.debug('Delivering message to %s', target)
         self.bus.publish(target, Serializer.to_json(message))
Example #2
0
 def perform(self, input):
     """The input is expected to be a JSON string that can be parsed into a Message object"""
     print 'Splitting ' + input
     message = Serializer.parse(input, Message)
     message.body = sent_tokenize(message.body)
     self.deliver(message)
Example #3
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