blob: b062c1c9911372c3ea38c3a798c7fec0c80ed102 (
plain)
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
|
import { ParseResult } from "./language/types.ts";
function prettyprintParseResult(input: ParseResult) {
for (var token of input.tokens) {
var out = "";
out += token.term_id;
out += ": ";
out += token.reading.map(r => r.text).reduce((a, b) => a + b);
out += " (";
out += token.reading.map(r => r.ruby ? r.ruby : r.text).reduce((a, b) => a + b);
out += ") ";
out += token.tags.map(a => `[${a}]`).join(" ");
console.log(out);
}
console.log(input.tokens.map(t => t.source).join(" "));
}
import API from "./core/api.ts";
import YomikunDirectAPIClient from "./core/direct/client.ts";
import YomikunRemoteAPIServer from "./core/http/server.ts";
import YomikunRemoteAPIClient from "./core/http/client.ts";
async function apiTest(api: API) {
prettyprintParseResult(await api.parseSentence("浮上したハイラル城の下にてゼルダ様達の捜索を行うこととなった"));
console.log("-------------");
prettyprintParseResult(await api.parseSentence("浮上した城の様"));
console.log("-------------");
prettyprintParseResult(await api.parseSentence("迷子になってしまった"));
}
// test 1 (direct api)
await (async () => {
var api = new YomikunDirectAPIClient();
await api.ready;
console.log("Prepare direct api done");
await apiTest(api);
})();
console.log("\n".repeat(2));
// test 2 (remote api)
await (async () => {
// default host = localhost:9400
new YomikunRemoteAPIServer().start();
var api = new YomikunRemoteAPIClient();
await api.ready;
console.log("Prepare remote api done");
await apiTest(api);
Deno.exit(0);
})();
|