def main():
starttime = time.time()
#parser = argparse.ArgumentParser(description='')
#parser.add_argument("action", choices=["start", "stop"])
#parser.add_argument("--basemodel", dest="model", help="base model path")
#parser.add_argument("-t", "--test", action="store_true",
# help="run a test instead of the server")
#parser.add_argument("--log", action="store", dest="loglevel", default="WARNING", help="Log level")
#options = parser.parse_args()
numeric_level = getattr(logging, "DEBUG", None)
#if not isinstance(numeric_level, int):
# raise ValueError('Invalid log level: %s' % options.loglevel)
#while len(logging.root.handlers) > 0:
# logging.root.removeHandler(logging.root.handlers[-1])
logging_format = '%(asctime)s %(levelname)s %(filename)s:%(lineno)s:%(funcName)s %(message)s'
logging.basicConfig(level=numeric_level, format=logging_format)
logging.getLogger().setLevel(numeric_level)
logging.debug("Initializing the server...")
server = IBENT(entities=[("mirtex_train_mirna_sner", "stanfordner", "mirna"),
("chemdner_train_all", "stanfordner", "chemical"),
("banner", "banner", "gene"),
("genia_sample_gene", "stanfordner", "gene")],
relations=[("all_ddi_train_slk", "jsre", "ddi"),
("mil_classifier4k", "smil", "mirna-gene")])
logging.debug("done.")
# Test server
bottle.route("/ibent/status")(server.hello)
# Fetch an existing document
bottle.route("/ibent/<doctag>")(server.get_document)
# Create a new document
bottle.route("/ibent/<doctag>", method='POST')(server.new_document)
# Get new entity annotations i.e. run a classifier again
bottle.route("/ibent/entities/<doctag>/<annotator>", method='POST')(server.run_entity_annotator)
# Get entity annotations i.e. fetch from the database
bottle.route("/ibent/entities/<doctag>/<annotator>")(server.get_annotations)
# Get new entity annotations i.e. run a classifier again
bottle.route("/ibent/relations/<doctag>/<annotator>", method='POST')(server.run_relation_annotator)
# Get new entity annotations i.e. run a classifier again
bottle.route("/ibent/relations/<doctag>/<annotator>")(server.get_relations)
# Get entity annotations i.e. fetch from the database
#bottle.route("/ibent/entities/<doctag>/<annotator>")(server.get_annotations)
#bottle.route("/iice/chemical/<text>/<modeltype>", method='POST')(server.process)
#bottle.route("/ibent/interactions", method='POST')(server.get_relations)
#daemon_run(host='10.10.4.63', port=8080, logfile="server.log", pidfile="server.pid")
bottle.run(host=config.host_ip, port=8080, DEBUG=True)
评论列表
文章目录