forked from mideind/GreynirServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalysis.html
145 lines (111 loc) · 3.52 KB
/
analysis.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
{% extends "container-normal.html" %}
{% block styles %}
<link href="{{ url_for('static', filename='css/main-bootstrap.css') }}" rel='stylesheet' type='text/css'>
{% endblock %}
{% block content %}
<div class="input-analysis">
<div class="row">
<div class="col-xs-12" id="txt-div">
<textarea rows="8" class="form-control input-lg"
id="txt" tabindex="1" maxlength="4096" autofocus required placeholder="Sláðu inn texta til að málgreina">
{{- default_text -}}
</textarea>
</div>
</div>
<div class="row">
<div class="col-xs-4 col-sm-3 col-md-2 pull-right">
<button class="btn btn-info btn-lg btn-block"
id="txt-ok" title="Greina" tabindex="3" onclick="analyze()">
<span class="glyphicon glyphicon-cogwheel"></span> Greina
</button>
</div>
</div>
</div>
<div id="output" style="display: none;">
<h3 class="help">Málgreining <small>Smelltu á málsgrein til að sjá trjágreiningu hennar</small></h3>
<div id="result" class="result">
{% include 'hover-infobox.html' %}
<div id="pgs"></div>
</div>
<div id="register">
<!-- Name register goes here -->
<h3>Nafnalisti</h3>
<ul id="namelist"></ul>
</div>
<div id="statistics">
<!-- Statistics go here -->
<h3>Tölfræði</h3>
<ul id="statistics-summary">
<!-- Statistics get populated in page.js -->
</ul>
</div>
</div>
{% endblock %}
{% block endscripts %}
<script src="{{ url_for('static', filename='js/common.js') }}"></script>
<script src="{{ url_for('static', filename='js/page.js') }}"></script>
<script>
function wait(state) {
// Start or stop a wait spinner
if (state) {
$("#txt-ok, #txt").attr("disabled", "disabled");
$("#txt-ok").html("<span class='glyphicon glyphicon-restart glyphicon-spin-white'></span>");
$("div#output").hide();
}
else {
$("#txt-ok, #txt").removeAttr("disabled");
$("#txt-ok").html("<span class='glyphicon glyphicon-cogwheel'></span> Greina");
$("div#output").show();
}
}
function clearResult() {
// Clear previous result
$("div#pgs").html("");
$("div#statistics").hide();
$("div#register").hide();
// Display progress indicator
wait(true);
}
function handleError(xhr, status, errorThrown) {
/* An error occurred on the server or in the communications */
$("div#pgs").html("<p><b>Villa kom upp</b> í samskiptum við netþjón Greynis</p>");
wait(false);
}
function populateResult(json) {
wait(false);
// Display the tokens
displayTokens(json.result);
populateStats(json.stats);
nameDict = json.register;
populateRegister();
}
function analyzeText(txt) {
// Ask the server to tokenize and parse the given text
clearResult();
// Launch the query
serverQuery('/analyze.api', // Endpoint with .api suffix are not cached
{
text : txt
},
populateResult,
null,
handleError
);
}
function analyze() {
// Submit the contents of the textarea to the server
// for tokenization and parsing
var s = $("#txt").val().trim();
if (s && s.length) {
analyzeText(s);
} else {
$("#txt").focus();
}
}
function init() {
// Activate the top navbar
$("#navid-analysis").addClass("active");
}
$(document).ready(init);
</script>
{% endblock %}