-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.php
221 lines (213 loc) · 9.51 KB
/
view.php
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?php defined('DICROOT') or die('Äîñòóï çàïðåù¸í'); ?>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="windows-1251">
<title>Àíàëèçàòîð òåêñòà</title>
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<div class="hero-unit<?php if ($text) echo " fold"; ?>">
<form id="form" action="" method="POST" enctype="multipart/form-data">
<p><label for="text">Âñòàâüòå òåêñò (äî 200000 ñèìâîëîâ) <textarea name="text" id="text" class="input-block-level" cols="150" rows="10" autofocus="autofocus"><?php if (!empty($_POST['text'])) echo $_POST['text']; ?></textarea></label></p>
<p><label for="file">Èëè çàãðóçèòå ôàéë ñ òåêñòîì (äî <?php echo $fmsize; ?>Ìá / Windows-1251) <input type="file" name="file" id="file" /></label></p>
<p>
<label class="checkbox" for="freq"><input type="checkbox" id="freq" name="freq" value="1" checked="checked"> Ñîçäàòü ÷àñòîòíûé ñëîâàðü</label>
<label class="checkbox" for="stop"><input type="checkbox" id="stop" name="stop" value="1"> Ñîçäàòü ÷àñòîòíûé ñëîâàðü áåç <a href="/stop_words_ru.txt" target="_blank" title="Ñêà÷àòü ñïèñîê ñòîï-ñëîâ">ñòîï-ñëîâ</a></label>
<label class="checkbox" for="morph"><input type="checkbox" id="morph" name="morph" value="1"> Ñîçäàòü ÷àñòîòíûé ñëîâàðü ñ îáðàáîòêîé ìîðôîëîãè÷åñêèì àíàëèçàòîðîì</label>
<span class="typeofmorph">
<label class="radio inline" for="mtypes"><input type="radio" name="mtype" id="mtypes" value="1" checked="checked"/> mystem <span class="label label-success">ðåêîìåíäóåòñÿ</span></label>
<label class="radio inline" for="mtypem"><input type="radio" name="mtype" id="mtypem" value="2"/> phpmorphy</label>
</span>
</p>
<p><button type="submit" class="btn btn-primary btn-large"><i class="icon-cog icon-white"></i> Àíàëèçèðîâàòü</button></p>
</form>
<div class="more"><button class="btn btn-info btn-small">Äðóãîé òåêñò</button></div>
</div>
<?php if ($text) { ?>
<div class="results tabbable tabs-left">
<ul class="nav nav-tabs">
<li class="active"><a href="#stat" data-toggle="tab">Ñòàòèñòèêà</a></li>
<li><a href="#words" data-toggle="tab">Ñëîâà</a></li>
<li><a href="#stop-words" data-toggle="tab">Ñòîï-ñëîâà</a></li>
<li><a href="#files" data-toggle="tab">Ôàéëû</a></li>
<li><a href="#bench" data-toggle="tab">Ðåñóðñû</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="stat">
<table class="table table-bordered table-hover table-condensed">
<tr>
<td>Ñèìâîëîâ</td>
<td><?php echo $number_of_symbols; ?></td>
</tr>
<tr>
<td>Ñèìâîëîâ áåç ïðîáåëîâ</td>
<td><?php echo $number_of_symbols - $spaces; ?></td>
</tr>
<tr>
<td>Ñëîâ</td>
<td><?php echo sizeof($words); ?></td>
</tr>
<tr>
<td>Ñòîï-ñëîâ</td>
<td><?php echo sizeof($stop_words_actual); ?></td>
</tr>
<tr>
<td>Óíèêàëüíûõ ñëîâ</td>
<td><?php echo sizeof($dict); ?></td>
</tr>
<tr>
<td>Óíèêàëüíûõ ñëîâ (áåç ñòîï-ñëîâ)</td>
<td><?php echo sizeof($dict_stop); ?></td>
</tr>
</table>
<div class="well well-large">
<button type="button" class="graph-toggle btn btn-large btn-block" data-toggle="collapse" data-target="#dynamics-holder" data-graph="dict-dynamics">
Ãðàôèê çàâèñèìîñòè ðàçìåðà ñëîâàðÿ îò äëèíû òåêñòà
</button>
<div id="dynamics-holder" class="collapse">
<div id="dict-dynamics"></div>
</div>
<button type="button" class="graph-toggle btn btn-large btn-block" data-toggle="collapse" data-target="#zipf-holder" data-graph="dict-zipf">
Ãðàôèê çàâèñèìîñòè ÷àñòîòû âñòðå÷àåìîñòè ñëîâà îò åãî ðàíãà
</button>
<div id="zipf-holder" class="collapse">
<div id="dict-zipf"></div>
</div>
</div>
</div>
<div class="tab-pane" id="words">
<table class="table table-bordered table-hover table-condensed">
<tr>
<th>Ñëîâî</th>
<th>Êîë-âî</th>
<th>×àñòîòà, %</th>
</tr>
<?php foreach ($dict_stop as $w => $ws) { ?>
<tr>
<td><?php echo $w; ?></td>
<td><?php echo $ws[0]; ?></td>
<td><?php echo $ws[1]; ?></td>
</tr>
<?php } ?>
</table>
</div>
<div class="tab-pane" id="stop-words">
<table class="table table-bordered table-hover table-condensed">
<tr>
<th>Ñòîï-ñëîâî</th>
<th>Êîë-âî</th>
<th>×àñòîòà, %</th>
</tr>
<?php foreach ($stop_words_array as $a => $av) { ?>
<tr>
<td><?php echo $a; ?></td>
<td><?php echo $av[0]; ?></td>
<td><?php echo $av[1]; ?></td>
</tr>
<?php } ?>
</table>
</div>
<div class="tab-pane" id="files">
<div class="row">
<?php
if ($files) {
foreach ($files as $f => $fv) { ?>
<div class="well well-large span3">
<a href="<?php echo $fv['file']; ?>" target="_blank"><i class="icon-book"></i> <?php echo $f .' ('. $fv['size'] . ' Êá)' ?></a>
</div>
<?php }
}
?>
</div>
</div>
<div class="tab-pane" id="bench">
<table class="table table-bordered table-hover table-condensed">
<tr>
<th>Çàäà÷à</th>
<th>Âðåìÿ</th>
<th>Ïàìÿòü</th>
</tr>
<?php foreach ($stats as $s => $sv) { ?>
<tr>
<td><?php echo $s; ?></td>
<td><?php echo $sv['time'] . ' ñ'; ?></td>
<td><?php echo $sv['mem'] . ' á'; ?></td>
</tr>
<?php } ?>
</table>
</div>
</div>
</div>
<?php } ?>
</div>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery.flot.min.js"></script>
<script type="text/javascript" src="js/jquery.flot.axislabels.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<?php if ($text) { ?>
<script type="text/javascript">
$(document).ready(function() {
var dynamics = [
<?php foreach ($dict_dynamics as $l => $d)
{
echo "[{$l}, {$d}],";
}
?>
];
var zipf = [
<?php foreach ($zipf as $r => $f)
{
echo "[{$r}, {$f}],";
}
?>
];
$('.graph-toggle').on('click', function() {
var self = $(this),
graph = self.data('graph');
if (!self.hasClass('builded')) {
if (self.data('graph') == 'dict-dynamics') {
//console.log('build dict-dyn');
$.plot('#dict-dynamics', [
{
data: dynamics,
color: '#00adee'
}
],
{
xaxis: {
axisLabel: "äëèíà òåêñòà"
},
yaxis: {
axisLabel: "ðàçìåð ñëîâàðÿ"
}
}
);
} else if (self.data('graph') == 'dict-zipf') {
$.plot('#dict-zipf', [
{
data: zipf,
color: '#eead00'
}
],
{
xaxis: {
axisLabel: "ðàíã (ïîñëåäîâàòåëüíîñòü ñëîâà)"
},
yaxis: {
axisLabel: "÷àñòîòà ñëîâà"
}
}
);
}
self.addClass('builded');
}
})
});
</script>
<?php } ?>
</body>
</html>