diff --git a/README.md b/README.md index 6aa2239..d4073c3 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This repository contains the code for replicating results from * [Kenton Lee](https://homes.cs.washington.edu/~kentonl), [Luheng He](https://homes.cs.washington.edu/~luheng), [Mike Lewis](https://research.fb.com/people/lewis-mike) and [Luke Zettlemoyer](https://www.cs.washington.edu/people/faculty/lsz) * In Proceedings of the Conference on Empirical Methods in Natural Language Process (EMNLP), 2017 -A demo of the code can be found here: https://kentonl.github.io/e2e-coref. +A demo of the code can be found here: http://www.kentonl.com/e2e-coref. ### Requirements * Python 2.7 diff --git a/demo.py b/demo.py index 5f02888..0208f2b 100755 --- a/demo.py +++ b/demo.py @@ -56,14 +56,6 @@ if __name__ == "__main__": else: port = None - if len(sys.argv) > 3: - # For https. See https://certbot.eff.org - keyfile = sys.argv[3] - certfile = sys.argv[4] - else: - keyfile = None - certfile = None - print "Running experiment: {}.".format(name) config = util.get_config("experiments.conf")[name] config["log_dir"] = util.mkdirs(os.path.join(config["log_root"], name)) @@ -80,29 +72,29 @@ if __name__ == "__main__": if port is not None: class CorefRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): - def do_GET(self): - idx = self.path.find("?") - if idx >= 0: - args = cgi.parse_qs(self.path[idx+1:]) - if "text" in args: - text_arg = args["text"] - if len(text_arg) == 1 and len(text_arg[0]) <= 10000: - text = text_arg[0].decode("utf-8") - print(u"Document text: {}".format(text)) - example = make_predictions(text, model) - print_predictions(example) - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write("jsonCallback({})".format(json.dumps(example))) - return + def do_POST(self): + form = cgi.FieldStorage( + fp=self.rfile, + headers=self.headers, + environ={"REQUEST_METHOD":"POST", + "CONTENT_TYPE":self.headers["Content-Type"] + }) + if "text" in form: + text = form["text"].value.decode("utf-8") + if len(text) <= 10000: + print(u"Document text: {}".format(text)) + example = make_predictions(text, model) + print_predictions(example) + self.send_response(200) + self.send_header("Content-Type", "application/json") + self.end_headers() + self.wfile.write(json.dumps(example)) + return self.send_response(400) self.send_header("Content-Type", "application/json") self.end_headers() server = BaseHTTPServer.HTTPServer(("", port), CorefRequestHandler) - if keyfile is not None: - server.socket = ssl.wrap_socket(server.socket, keyfile=keyfile, certfile=certfile, server_side=True) print("Running server at port {}".format(port)) server.serve_forever() else: diff --git a/docs/index.html b/docs/index.html index 8b920ab..74c901c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5,7 +5,6 @@ -
@@ -13,56 +12,9 @@This is the demo for the coreference resolution system described in:
-Submit an input document below. A simple example is provided.
-On the right side, the highest-scoring spans are shown. On the left side, the predicted coreference cluster (mentions of the same entity) are shown.
-Hover over the mentions on either side to highlight their location in the document and render the attention weights of the words.
-The code is available here.
-