コード例 #1
0
ファイル: pipeline.py プロジェクト: alex-kaichenc/temp
    print 'Processing ' + filename
    fp = open(filename, 'r')
    dataset = Serializer.parse(fp, DataSet)
    fp.close()

    # The list of services to send the questions to.

    """ Kaichen Chen 0304 """
    if not debug:
        pipeline = ['mmr.core', 'tiler.concat', 'results']
    else:
        pipeline = ['splitter', 'mmr.core', 'tiler.concat', 'results']

    """ kaichenc 0307 """
    host = os.environ.get('HOST', 'localhost')
    print "DEBUG: Current host of Message Bus: {}".format(host)

    count=0
    bus = MessageBus(host = host)
    for index in range(0,10):
        question = dataset.questions[index]
    # for question in dataset.questions:
        message = Message(body=question, route=pipeline)
        bus.publish('expand.none', message)
        # bus.publish('splitter', message)
        count = count + 1

    print 'Sent {} questions for ranking.'.format(count)
    print 'Done.'

コード例 #2
0
ファイル: save.py プロジェクト: liboyue/BioASQ-Rabbit
#!/usr/bin/env python

import sys
from deiis.rabbit import Message, MessageBus

destination = '/tmp/submission.json'
if len(sys.argv) > 1:
    destination = sys.argv[1]

message = Message.Command('SAVE ' + destination, [])

bus = MessageBus()
bus.publish('results', message)
print 'Save command sent. Saving to ' + destination
コード例 #3
0
import sys
from deiis.rabbit import Message, MessageBus

if __name__ == '__main__':
    message = Message(body='start', route=sys.argv[1:])
    bus = MessageBus()
    bus.send(message)
コード例 #4
0
ファイル: stop.py プロジェクト: alex-kaichenc/temp
import sys
from deiis.rabbit import MessageBus, Message
""" kaichenc 0307 """
import os

print 'stop.py: called'

# All the services that may be running.
all = [
    'mmr.hard', 'mmr.soft', 'mmr.core', 'expand.none', 'expand.snomed',
    'expand.umls', 'tiler.concat', 'results', 'splitter'
]

# The shutdown message for the services.
die = Message.Command('DIE', [])
""" kaichenc 0307 """
host = os.environ.get('HOST', 'localhost')
print "DEBUG: Current host of Message Bus: {}".format(host)
bus = MessageBus(host=host)

if len(sys.argv) > 1:
    if sys.argv[1] == 'all':
        services = all
    else:
        services = sys.argv[1:]
else:
    services = all

# Send the shutdown message to each of the services.
for service in services:
コード例 #5
0
ファイル: test.py プロジェクト: alex-kaichenc/temp
            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'
        }]
    }
    logger = logging.getLogger('main')
    message = Message(route=['tiler.concat', 'results'], body=input)
    json = Serializer.to_pretty_json(message)

    logger.info('publishing question')
    bus = MessageBus()
    bus.publish('mmr.core', json)
    # bus.publish('mmr.soft', json)
    # bus.publish('mmr.hard', json)

    # logger.info('Waiting for the thread to stop')
    # results.wait_for()
    #
    # logger.info('Killing the ranker services')
    # message = Message.Command('DIE', route=['mmr.hard', 'mmr.core'])
    # bus.publish('mmr.soft', Serializer.to_json(message))
    logger.info('Done')
コード例 #6
0
ファイル: splitter.py プロジェクト: alex-kaichenc/temp
            for token in sentence:
                print token
            print ''


if __name__ == '__main__':
    splitter = Splitter()
    tokenizer = Tokenizer()
    printer = Printer()

    services = (splitter, tokenizer, printer)

    for service in services:
        print 'Staring service ' + str(type(service))
        service.start()

    print 'Sending the message to the splitter'
    message = Message(body="Goodbye cruel world. I am leaving you today.",
                      route=['tokenizer', 'printer'])
    bus = MessageBus()
    bus.publish('splitter', message)

    print 'Sleeping...'
    time.sleep(1)

    print 'Stopping all the services'
    for service in services:
        service.stop()

    print 'Done.'
コード例 #7
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