aboutsummaryrefslogtreecommitdiff
path: root/test/reading/test.ts
blob: 9d426d41acfd2125d4e40a6b804db30af0b929db (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
import * as path from 'https://deno.land/std@0.102.0/path/mod.ts';
Deno.chdir(path.dirname(path.fromFileUrl(Deno.mainModule)) + "/../..");

import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";

import YomikunDirectAPIClient from "../../core/direct/client.ts";

var api = new YomikunDirectAPIClient();
await api.prepare();

interface Test {
	test: {
		input: string;
		reading: string;
	};
	_original: string;
	tags: Array<string>;
};

const tests = JSON.parse(await Deno.readTextFile(path.resolve('test', 'reading', 'cases.json'))) as Test[];

console.log(`amount of sentences: ${tests.length}`);
console.log(`average sentence length: ${tests.map(t => t.test.input.length).reduce((a, b) => a + b) / tests.length}`);

console.time("parse");
for (var { test } of tests) {
	var result = await api.parseSentence(test.input);
	// TODO: add reading back into conjugated verb to complete this test
	
}
console.timeEnd("parse");