Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ecb3f93
commit 4f07a6b
Showing
8 changed files
with
204 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,10 @@ numpy==1.15.2 | |
scipy==1.1.0 | ||
nltk==3.3 | ||
allennlp==0.6.1 | ||
|
||
tqdm | ||
gensim | ||
faiss | ||
faiss | ||
|
||
tornado | ||
flask |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
html { position: relative; min-height: 100%; } | ||
body { margin-bottom: 60px; } | ||
.footer { position: absolute; bottom: 0; width: 100%; height: 40px; line-height: 15px; background-color: #f5f5f5; padding-top: 5px; font-size: 12px; text-align: center;} | ||
label, footer { user-select: none; } | ||
.list-group-item:first-of-type { background-color: #e0f2f1; color: #00695c; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<meta charset="utf-8"> | ||
<title>PIQA Demo</title> | ||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="files/style.css"> | ||
|
||
<script src="https://use.fontawesome.com/releases/v5.2.0/js/all.js"></script> | ||
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> | ||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> | ||
|
||
<body> | ||
<nav class="navbar navbar-expand-sm bg-dark navbar-dark"> | ||
<a class="navbar-brand" href="./">PIQA Demo</a> | ||
<ul class="navbar-nav"> | ||
<li class="nav-item"> <a class="nav-link" target="_blank" href="http://aclweb.org/anthology/D18-1052">Paper</a> </li> | ||
</ul> | ||
</nav> | ||
<div class="container"> | ||
<div class="mt-4 text-center"> | ||
<img src="files/pika.png" height="300" class="rounded" alt="pika" title="Ask me anything!"/> | ||
</div> | ||
|
||
<div class="input-group mb-1 mt-4"> | ||
<input id="question" type="text" class="form-control" placeholder="Write question" aria-label="Write question"> | ||
<div class="input-group-append"> | ||
<button id="search" class="btn btn-secondary" type="button"> | ||
<i class="fa fa-search"></i> | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div id="ret-time" class="text-secondary small ml-2 col">Elapsed Time: </div> | ||
<div class="custom-control custom-checkbox mr-3"> | ||
<input type="checkbox" class="custom-control-input small" id="realtime_chk"> | ||
<label class="custom-control-label small" for="realtime_chk">Real-time Search</label> | ||
</div> | ||
</div> | ||
<hr/> | ||
|
||
<div class="card"> | ||
<ul id="ret-results" class="list-group list-group-flush"> | ||
<li class="list-group-item"></li> | ||
</ul> | ||
</div> | ||
</div> | ||
|
||
<footer class="footer"> | ||
<div class="container"> | ||
<span class="text-muted"> | ||
<strong>Phrase-Indexed Question Answering: A New Challenge for Scalable Document Comprehension</strong><br/> | ||
Demo page made by <a target="_blank" href="https://antest1.github.io/">Gyeongbok Lee</a> | ||
</span> | ||
</div> | ||
</footer> | ||
|
||
|
||
<script> | ||
var tout_id = 0; | ||
$("#realtime_chk").prop('checked', true); | ||
|
||
$("#question").bind("input", function() { | ||
var query = $("#question").val(); | ||
clearTimeout(tout_id); | ||
var is_real = $("#realtime_chk").is(":checked") == true; | ||
if (is_real) { | ||
if (query.trim().length > 0) { | ||
tout_id = window.setTimeout(execute, 100, query); | ||
} else { | ||
init_result(); | ||
} | ||
} | ||
}); | ||
|
||
$("#search").click(function() { | ||
var query = $("#question").val(); | ||
if (query.trim().length > 0) { | ||
execute(query); | ||
} else { | ||
init_result(); | ||
} | ||
}); | ||
|
||
function init_result() { | ||
$("#ret-time").text("Elapsed time: "); | ||
$("#ret-results").html("<li class=\"list-group-item\"></li>"); | ||
} | ||
|
||
function highlight(item) { | ||
var text = item[0]; | ||
var start = item[1]; | ||
var end = item[2]-1; | ||
new_text = text.split(""); | ||
new_text[start] = "<strong>" + new_text[start]; | ||
new_text[end] = new_text[end] + "</strong>"; | ||
return new_text.join(""); | ||
} | ||
|
||
function execute(text) { | ||
$("#ret-time").text("Elapsed time: "); | ||
start_time = + new Date(); | ||
$.get("/api?query=" + encodeURIComponent(text), function(result) { | ||
end_time = + new Date(); | ||
$("#ret-time").text("Elapsed time: " + (end_time - start_time) / 1000 + "s"); | ||
$("#ret-results").empty(); | ||
for (var i = 0; i < result.length; i++) { | ||
$("#ret-results").append("<li class=\"list-group-item\"><div class=\"row\">" | ||
+ "<div class=\"col-10\">" + highlight(result[i]) + "</div>" | ||
+ "<div class=\"col-2 text-right\">" + result[i][3] + "</div>" | ||
+ "</div></li>") | ||
} | ||
}); | ||
} | ||
</script> | ||
|
||
</body> | ||
|
||
</html> |