-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
115 lines (106 loc) · 3.08 KB
/
index.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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>هضم</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<style type="text/css">
body {
direction: rtl;
}
.controls {
margin-top: 5px;
}
.container {
max-width: 600px;
}
</style>
<div class="header">
<div class="container">
<h1>هضم</h1>
<p>برای پردازش زبان فارسی در پایتون</p>
</div>
</div>
<div class="container content">
<div id="query">
<h3>متن ورودی</h3>
<textarea class="form-control" style="min-height: 80px">در میزند و دوباره وارد ميشود . همه مي گویند قدمش پربرکت است .</textarea>
<div class="controls">
<button id="process" class="btn btn-primary">پردازش</button>
</div>
</div>
<div class="demo" id="parsed">
<h3>تجزیه نحوی</h3>
<textarea id="conll" class="form-control" style="min-height: 500px">
1 در در N N _ 2 NVE _ _
2 میزند زد#زن V V _ 3 PREDEP _ _
3 و و CONJ CONJ _ 6 VCONJ _ _
4 دوباره دوباره ADV ADV _ 6 ADV _ _
5 وارد وارد N N _ 6 NVE _ _
6 میشود میشود V V _ 0 ROOT _ _
7 . . PUNC PUNC _ 6 PUNC _ _
1 همه همه PRO PRO _ 2 SBJ _ _
2 میگویند گفت#گو V V _ 0 ROOT _ _
3 قدمش قدم N N _ 5 SBJ _ _
4 پربرکت پربرکت AJ AJ _ 5 MOS _ _
5 است #است V V _ 2 VCL _ _
6 . . PUNC PUNC _ 2 PUNC _ _
</textarea>
</div>
<div class="controls">
<button id="draw" class="btn btn-primary">نمایش</button>
</div>
<div id="parsed" style="margin-bottom: 300px;">
<div></div>
</div>
</div>
<script type="text/javascript" src="jquery-3.3.1.min.js"></script>
<link rel="stylesheet" href="tree.css">
<script type="text/javascript" src="d3.js"></script>
<script type="text/javascript" src="dependency-tree.js"></script>
<script type="text/javascript">
var server = 'http://api.sobhe.ir:5000/api';
var normalize = function(data) {
$.post(server + '/normalize', data)
.done(function(normalized_text) {
tokenize({'normalized_text': normalized_text});
})
};
var tokenize = function(data) {
$.post(server + '/tokenize', data)
.done(function(tokenized_text) {
tag({'tokenized_text': tokenized_text});
});
};
var tag = function(data) {
$.post(server + '/tag', data)
.done(function(tagged_text) {
parse({'tagged_text': tagged_text});
});
};
var parse = function(data) {
$.post(server + '/parse', data)
.done(function(parsed_text) {
$('#conll').val($.parseJSON(parsed_text).join('\n\n'));
d3.select('#draw').on('click')();
});
};
$('#process').click(function() {
normalize({'text': $('#query textarea').val()});
});
d3.select('#draw').on('click', function() {
sentences = d3.select('#conll')[0][0].value.split('\n\n');
div = $('#parsed > div'); div.empty();
for (s in sentences) {
if (sentences[s].length) {
div.append('<div class="tree"><svg id="tree'+ s +'"></svg></div>');
drawTree('#tree'+ s, sentences[s].replace(/_/g,' '));
}
}
});
d3.select('#draw').on('click')();
</script>
</body>
</html>