Esempio n. 1
0
 def __init__(self, args):
     self.scorer = build_scorer(args)
Esempio n. 2
0
                        default=DEFAULT_PORT,
                        help='Server port number')

    args, _ = parser.parse_known_args()
    # fmt: on
    return args


def start_server(scorer,
                 hostname=DEFAULT_HOSTNAME,
                 port=DEFAULT_PORT,
                 debug=False):
    app = web.Application(
        [
            (r"/result", ResultHandler, dict(scorer=scorer)),
            (r"/src", SourceHandler, dict(scorer=scorer)),
            (r"/hypo", HypothesisHandler, dict(scorer=scorer)),
            (r"/", EvalSessionHandler, dict(scorer=scorer)),
        ],
        debug=debug,
    )
    app.listen(port, max_buffer_size=1024**3)
    sys.stdout.write(f"Evaluation Server Started. Listening to port {port}\n")
    ioloop.IOLoop.current().start()


if __name__ == "__main__":
    args = add_args()
    scorer = build_scorer(args)
    start_server(scorer, args.hostname, args.port, args.debug)