-
Notifications
You must be signed in to change notification settings - Fork 3
/
standalone.html
45 lines (42 loc) · 1.29 KB
/
standalone.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
<!doctype html>
<html>
<head>
<style type="text/css">
#container {
width: 40%;
margin: 0 auto;
}
textarea {
width: 100%;
display: block;
margin: 10px 0;
}
#in { height: 3em; }
#out { height: 15em; }
</style>
<script type="module">
import Mecab from "https://unpkg.com/mecab-wasm@1.0.2/lib/mecab.js";
function init() {
document.getElementById('button').addEventListener('click', function() {
let text = document.getElementById('in').value;
let result = Mecab.query(text);
document.getElementById('out').value = JSON.stringify(result, null, 2);
});
}
window.addEventListener('load', function() {
Mecab.waitReady().then(init);
});
</script>
</head>
<body>
<div id="container">
<div>
<textarea id="in">吾輩は猫である</textarea>
<button id="button">Analyze</button>
</div>
<div>
<textarea id="out"></textarea>
</div>
<div>
</body>
</html>