Esempio n. 1
0
    def save(self, path=None):
        if path is None:
            path = '/tmp/submission.json'

        self.logger.debug("Saving dataset to %s", path)
        dataset = DataSet()
        dataset.questions = self.questions
        json = Serializer.to_pretty_json(dataset)

        """ Kaichen Chen 0304 """
        try:
            fp = open(path, 'w')
        except:
            print "ResultsCollector: Cannot open path: {}".format(path)
            current_folder = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
            path = os.path.join(
                os.path.dirname(current_folder),
                'tmp/submission.json'
            )
            print "ResultsCollector: Switch to {}".format(path)
            fp = open(path, 'w')

        fp.write(json)
        fp.close()
        self.logger.info("Wrote %s", path)
        self.questions = []
Esempio n. 2
0
    def save(self, path=None):
        if path is None:
            path = '/tmp/submission.json'

        self.logger.debug("Saving dataset to %s", path)
        dataset = DataSet()
        dataset.questions = self.questions
        json = Serializer.to_pretty_json(dataset)
        fp = open(path, 'w')
        fp.write(json)
        fp.close()
        self.logger.info("Wrote %s", path)
        self.questions = []
Esempio n. 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'
        }]
    }
    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')