blob: 2d15a47790007bd661b51fce738c433228d3a25c (
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
59
60
|
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.writing;
out += " (";
out += token.reading;
out += ") ";
out += token.tags.map(a => `[${a}]`).join(" ");
console.log(out);
}
console.log(input.tokens.map(t => t.source).join(" "));
}
import Core from "./core/api.ts";
import DirectCoreClient from "./core/direct/client.ts";
import RemoteCoreServer from "./core/http/server.ts";
import RemoteCoreClient from "./core/http/client.ts";
async function coreTest(core: Core) {
prettyprintParseResult(await core.parseSentence("浮上したハイラル城の下にてゼルダ様達の捜索を行うこととなった"));
console.log("-------------");
prettyprintParseResult(await core.parseSentence("浮上した城の様"));
console.log("-------------");
prettyprintParseResult(await core.parseSentence("迷子になってしまった"));
console.log("-------------");
prettyprintParseResult(await core.parseSentence("日本に来て一番驚いたことは自動販売機の多さだ。"));
}
// test 1 (direct core)
await (async () => {
var core = new DirectCoreClient();
await core.ready;
console.log("Prepare direct core done");
await coreTest(core);
})();
// console.log("\n".repeat(2));
//
// // test 2 (remote core)
// await (async () => {
// // default host = localhost:9400
// new RemoteCoreServer().start();
//
// var core = new RemoteCoreClient();
// await core.ready;
//
// console.log("Prepare remote core done");
// await coreTest(core);
//
// Deno.exit(0);
// })();
|