Update to 3.0.0

- Add fromJson factories for all objects
- Make some properties use getters, to reduce redundant data
- Make all objects comparable with the equatable package
- Make all objects immutable with a constant constructor
    as a result of making them comparable
This commit is contained in:
Oystein Kristoffer Tveit 2022-05-08 02:06:45 +02:00
parent e37de1bdb1
commit a84cfe5c02
22 changed files with 1882 additions and 898 deletions

View File

@ -1,3 +1,11 @@
# 3.0.0
- Add fromJson factories for all objects
- Make some properties use getters, to reduce redundant data
- Make all objects comparable with the equatable package
- Make all objects immutable with a constant constructor
as a result of making them comparable
# 2.0.4 # 2.0.4
- Fixed bug where pieces were missing in example sentences - Fixed bug where pieces were missing in example sentences

View File

@ -39,6 +39,7 @@ void main() async {
final data = result.data; final data = result.data;
if (data != null) { if (data != null) {
print('Kanji: ${data.kanji}');
print('Taught in: ${data.taughtIn}'); print('Taught in: ${data.taughtIn}');
print('JLPT level: ${data.jlptLevel}'); print('JLPT level: ${data.jlptLevel}');
print('Newspaper frequency rank: ${data.newspaperFrequencyRank}'); print('Newspaper frequency rank: ${data.newspaperFrequencyRank}');
@ -63,6 +64,7 @@ This outputs the following:
``` ```
Found: true Found: true
Kanji: 語
Taught in: grade 2 Taught in: grade 2
JLPT level: N5 JLPT level: N5
Newspaper frequency rank: 301 Newspaper frequency rank: 301
@ -269,6 +271,10 @@ void main() async {
} }
``` ```
## Note on usage with web
Although the library is marked as ok for use with website outputs, you will not be able to reach through the CORS setup of jisho.org. You should set up a backend as a proxy if you want to make a website. See (#3)
## About ## About
Permission to scrape granted by Jisho's admin Kimtaro: https://jisho.org/forum/54fefc1f6e73340b1f160000-is-there-any-kind-of-search-api Permission to scrape granted by Jisho's admin Kimtaro: https://jisho.org/forum/54fefc1f6e73340b1f160000-is-there-any-kind-of-search-api

View File

@ -7,6 +7,7 @@ void main() {
final data = result.data; final data = result.data;
if (data != null) { if (data != null) {
print('Kanji: ${data.kanji}');
print('Taught in: ${data.taughtIn}'); print('Taught in: ${data.taughtIn}');
print('JLPT level: ${data.jlptLevel}'); print('JLPT level: ${data.jlptLevel}');
print('Newspaper frequency rank: ${data.newspaperFrequencyRank}'); print('Newspaper frequency rank: ${data.newspaperFrequencyRank}');

View File

@ -4,7 +4,6 @@ final JsonEncoder encoder = JsonEncoder.withIndent(' ');
void main() { void main() {
jisho.searchForPhrase('').then((result) { jisho.searchForPhrase('').then((result) {
// jisho.searchForPhrase('する').then((result) {
print(encoder.convert(result)); print(encoder.convert(result));
}); });
} }

View File

@ -53,10 +53,7 @@ Future<PhrasePageScrapeResult> scrapeForPhrase(String phrase) async {
final uri = uriForPhraseScrape(phrase); final uri = uriForPhraseScrape(phrase);
final response = await http.get(uri); final response = await http.get(uri);
if (response.statusCode == 404) { if (response.statusCode == 404) {
return PhrasePageScrapeResult( return PhrasePageScrapeResult(query: phrase);
query: phrase,
found: false,
);
} }
return parsePhrasePageData(response.body, phrase); return parsePhrasePageData(response.body, phrase);
} }

View File

@ -148,7 +148,6 @@ ExampleResults parseExamplePageData(String pageHtml, String phrase) {
return ExampleResults( return ExampleResults(
query: phrase, query: phrase,
found: results.isNotEmpty,
results: results, results: results,
uri: uriForExampleSearch(phrase).toString()); );
} }

View File

@ -14,7 +14,8 @@ Uri uriForKanjiSearch(String kanji) {
return Uri.parse('$scrapeBaseUri${Uri.encodeComponent(kanji)}%23kanji'); return Uri.parse('$scrapeBaseUri${Uri.encodeComponent(kanji)}%23kanji');
} }
String _getUriForStrokeOrderDiagram(String kanji) { /// Provides the URI for a stroke order diagram
String getUriForStrokeOrderDiagram(String kanji) {
return '$strokeOrderDiagramBaseUri${kanji.codeUnitAt(0)}_frames.png'; return '$strokeOrderDiagramBaseUri${kanji.codeUnitAt(0)}_frames.png';
} }
@ -155,6 +156,7 @@ List<String> _getParts(String pageHtml) {
return result; return result;
} }
/// Provides the URI for a SVG image of the kanji
String _getSvgUri(String pageHtml) { String _getSvgUri(String pageHtml) {
var svgRegex = RegExp('\/\/.*?.cloudfront.net\/.*?.svg'); var svgRegex = RegExp('\/\/.*?.cloudfront.net\/.*?.svg');
@ -167,7 +169,8 @@ String _getSvgUri(String pageHtml) {
return 'https:$regexResult'; return 'https:$regexResult';
} }
String _getGifUri(String kanji) { /// Provides the URI for a GIF of the kanji stroke order
String getGifUri(String kanji) {
final unicodeString = kanji.codeUnitAt(0).toRadixString(16); final unicodeString = kanji.codeUnitAt(0).toRadixString(16);
final fileName = '$unicodeString.gif'; final fileName = '$unicodeString.gif';
final animationUri = final animationUri =
@ -212,22 +215,17 @@ String? _getJlptLevel(String pageHtml) {
/// Parses a jisho kanji search page to an object /// Parses a jisho kanji search page to an object
KanjiResult parseKanjiPageData(String pageHtml, String kanji) { KanjiResult parseKanjiPageData(String pageHtml, String kanji) {
final result = KanjiResult( if (!_containsKanjiGlyph(pageHtml, kanji)) {
query: kanji, return KanjiResult(query: kanji);
found: _containsKanjiGlyph(pageHtml, kanji),
);
if (result.found == false) {
return result;
} }
result.data = KanjiResultData( return KanjiResult(
query: kanji,
data: KanjiResultData(
kanji: kanji,
strokeCount: _getStrokeCount(pageHtml), strokeCount: _getStrokeCount(pageHtml),
meaning: _getMeaning(pageHtml), meaning: _getMeaning(pageHtml),
strokeOrderDiagramUri: _getUriForStrokeOrderDiagram(kanji),
strokeOrderSvgUri: _getSvgUri(pageHtml), strokeOrderSvgUri: _getSvgUri(pageHtml),
strokeOrderGifUri: _getGifUri(kanji),
uri: uriForKanjiSearch(kanji).toString(),
parts: _getParts(pageHtml), parts: _getParts(pageHtml),
taughtIn: _getTaughtIn(pageHtml), taughtIn: _getTaughtIn(pageHtml),
jlptLevel: _getJlptLevel(pageHtml), jlptLevel: _getJlptLevel(pageHtml),
@ -237,7 +235,6 @@ KanjiResult parseKanjiPageData(String pageHtml, String kanji) {
kunyomiExamples: _getKunyomiExamples(pageHtml), kunyomiExamples: _getKunyomiExamples(pageHtml),
onyomiExamples: _getOnyomiExamples(pageHtml), onyomiExamples: _getOnyomiExamples(pageHtml),
radical: _getRadical(pageHtml), radical: _getRadical(pageHtml),
),
); );
return result;
} }

File diff suppressed because it is too large Load Diff

View File

@ -190,14 +190,11 @@ PhrasePageScrapeResult parsePhrasePageData(String pageHtml, String query) {
final document = parse(pageHtml); final document = parse(pageHtml);
if (!_resultWasFound(document)) { if (!_resultWasFound(document)) {
return PhrasePageScrapeResult(found: false, query: query); return PhrasePageScrapeResult(query: query);
} }
final data = _getMeaningsOtherFormsAndNotes(query, document);
return PhrasePageScrapeResult( return PhrasePageScrapeResult(
found: true,
query: query, query: query,
data: data, data: _getMeaningsOtherFormsAndNotes(query, document),
); );
} }

View File

@ -1,5 +1,5 @@
name: unofficial_jisho_api name: unofficial_jisho_api
version: 2.0.4 version: 3.0.0
description: An unofficial api for searching and scraping the japanese dictionary Jisho.org description: An unofficial api for searching and scraping the japanese dictionary Jisho.org
homepage: https://github.com/h7x4ABk3g/unofficial_jisho_api_dart/ homepage: https://github.com/h7x4ABk3g/unofficial_jisho_api_dart/
@ -12,6 +12,7 @@ dependencies:
http: ^0.13.3 http: ^0.13.3
html_unescape: ^2.0.0 html_unescape: ^2.0.0
html: ^0.15.0 html: ^0.15.0
equatable: ^2.0.3
dev_dependencies: dev_dependencies:
lints: ^1.0.1 lints: ^1.0.1

View File

@ -2,70 +2,15 @@
"query": "車", "query": "車",
"found": true, "found": true,
"results": [ "results": [
{
"english": "If we can't get the money in any other way, we can, as a last resort, sell the car.",
"kanji": "他の方法でお金がつくれなければ最後の手段として車を売り払えばよい。",
"kana": "ほかのほうほうでおかねがつくれなければさいごのしゅだんとしてくるまをうりはらえばよい。",
"pieces": [
{
"lifted": "ほか",
"unlifted": "他の"
},
{
"lifted": "ほうほう",
"unlifted": "方法"
},
{
"lifted": null,
"unlifted": "で"
},
{
"lifted": "おかね",
"unlifted": "お金"
},
{
"lifted": null,
"unlifted": "が"
},
{
"lifted": null,
"unlifted": "つくれ"
},
{
"lifted": null,
"unlifted": "なければ"
},
{
"lifted": "さいごのしゅだん",
"unlifted": "最後の手段"
},
{
"lifted": null,
"unlifted": "として"
},
{
"lifted": "くるま",
"unlifted": "車"
},
{
"lifted": null,
"unlifted": "を"
},
{
"lifted": "うりはら",
"unlifted": "売り払えば"
},
{
"lifted": null,
"unlifted": "よい"
}
]
},
{ {
"english": "Any car will do, as long as it runs.", "english": "Any car will do, as long as it runs.",
"kanji": "走りさえすれば、どんな車でもよいのです。", "kanji": "走りさえすれば、どんな車でもよいのです。",
"kana": "はしりさえすれば、どんなくるまでもよいのです。", "kana": "はしりさえすれば、どんなくるまでもよいのです。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "はし", "lifted": "はし",
"unlifted": "走り" "unlifted": "走り"
@ -74,6 +19,10 @@
"lifted": null, "lifted": null,
"unlifted": "さえすれば" "unlifted": "さえすれば"
}, },
{
"lifted": null,
"unlifted": "、"
},
{ {
"lifted": null, "lifted": null,
"unlifted": "どんな" "unlifted": "どんな"
@ -101,6 +50,10 @@
"kanji": "窓の外を見ると、車が1台来るのが見えた。", "kanji": "窓の外を見ると、車が1台来るのが見えた。",
"kana": "まどのそとをみると、くるまがいちだいきたるのがみえた。", "kana": "まどのそとをみると、くるまがいちだいきたるのがみえた。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "まど", "lifted": "まど",
"unlifted": "窓" "unlifted": "窓"
@ -125,6 +78,10 @@
"lifted": null, "lifted": null,
"unlifted": "と" "unlifted": "と"
}, },
{
"lifted": null,
"unlifted": "、"
},
{ {
"lifted": "くるま", "lifted": "くるま",
"unlifted": "車" "unlifted": "車"
@ -160,6 +117,10 @@
"kanji": "素敵な車じゃない。ずいぶん高かっただろう?", "kanji": "素敵な車じゃない。ずいぶん高かっただろう?",
"kana": "すてきなくるまじゃない。ずいぶんたかかっただろう?", "kana": "すてきなくるまじゃない。ずいぶんたかかっただろう?",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "すてき", "lifted": "すてき",
"unlifted": "素敵な" "unlifted": "素敵な"
@ -172,6 +133,10 @@
"lifted": null, "lifted": null,
"unlifted": "じゃない" "unlifted": "じゃない"
}, },
{
"lifted": null,
"unlifted": "。"
},
{ {
"lifted": null, "lifted": null,
"unlifted": "ずいぶん" "unlifted": "ずいぶん"
@ -191,6 +156,10 @@
"kanji": "祖母は列車で旅行をするのが好きだ。", "kanji": "祖母は列車で旅行をするのが好きだ。",
"kana": "そぼはれっしゃでりょこうをするのがすきだ。", "kana": "そぼはれっしゃでりょこうをするのがすきだ。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "そぼ", "lifted": "そぼ",
"unlifted": "祖母" "unlifted": "祖母"
@ -242,6 +211,10 @@
"kanji": "全員その車に乗った。", "kanji": "全員その車に乗った。",
"kana": "ぜんいんそのくるまにのった。", "kana": "ぜんいんそのくるまにのった。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "ぜんいん", "lifted": "ぜんいん",
"unlifted": "全員" "unlifted": "全員"
@ -269,6 +242,10 @@
"kanji": "前方に赤い車が見える。", "kanji": "前方に赤い車が見える。",
"kana": "ぜんぽうにあかいくるまがみえる。", "kana": "ぜんぽうにあかいくるまがみえる。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "ぜんぽう", "lifted": "ぜんぽう",
"unlifted": "前方" "unlifted": "前方"
@ -300,6 +277,10 @@
"kanji": "前の車は10年以上持っていた。", "kanji": "前の車は10年以上持っていた。",
"kana": "まえのくるまは10ねんいじょうもっていた。", "kana": "まえのくるまは10ねんいじょうもっていた。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "まえ", "lifted": "まえ",
"unlifted": "前" "unlifted": "前"
@ -316,6 +297,10 @@
"lifted": null, "lifted": null,
"unlifted": "は" "unlifted": "は"
}, },
{
"lifted": null,
"unlifted": ""
},
{ {
"lifted": "ねん", "lifted": "ねん",
"unlifted": "年" "unlifted": "年"
@ -335,6 +320,10 @@
"kanji": "船で旅行するのは車で旅行するよりも時間がかかる。", "kanji": "船で旅行するのは車で旅行するよりも時間がかかる。",
"kana": "ふねでりょこうするのはくるまでりょこうするよりもじかんがかかる。", "kana": "ふねでりょこうするのはくるまでりょこうするよりもじかんがかかる。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "ふね", "lifted": "ふね",
"unlifted": "船" "unlifted": "船"
@ -390,6 +379,10 @@
"kanji": "線路の上に鉄片があったために列車は脱線した。", "kanji": "線路の上に鉄片があったために列車は脱線した。",
"kana": "せんろのうえにてっぺんがあったためにれっしゃはだっせんした。", "kana": "せんろのうえにてっぺんがあったためにれっしゃはだっせんした。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "せんろ", "lifted": "せんろ",
"unlifted": "線路" "unlifted": "線路"
@ -445,10 +438,18 @@
"kanji": "洗えば、車は太陽の光をあびて輝くだろう。", "kanji": "洗えば、車は太陽の光をあびて輝くだろう。",
"kana": "あらえば、くるまはたいようのひかりをあびてかがやくだろう。", "kana": "あらえば、くるまはたいようのひかりをあびてかがやくだろう。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "あら", "lifted": "あら",
"unlifted": "洗えば" "unlifted": "洗えば"
}, },
{
"lifted": null,
"unlifted": "、"
},
{ {
"lifted": "くるま", "lifted": "くるま",
"unlifted": "車" "unlifted": "車"
@ -492,6 +493,10 @@
"kanji": "戦車や飛行機は軍隊を打ち破ることはできようが、国民を征服することはできない。", "kanji": "戦車や飛行機は軍隊を打ち破ることはできようが、国民を征服することはできない。",
"kana": "せんしゃやひこうきはぐんたいをうちやぶることはできようが、こくみんをせいふくすることはできない。", "kana": "せんしゃやひこうきはぐんたいをうちやぶることはできようが、こくみんをせいふくすることはできない。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "せんしゃ", "lifted": "せんしゃ",
"unlifted": "戦車" "unlifted": "戦車"
@ -536,6 +541,10 @@
"lifted": null, "lifted": null,
"unlifted": "が" "unlifted": "が"
}, },
{
"lifted": null,
"unlifted": "、"
},
{ {
"lifted": "こくみん", "lifted": "こくみん",
"unlifted": "国民" "unlifted": "国民"
@ -563,6 +572,10 @@
"kanji": "先生は新しい車が気に入っている。", "kanji": "先生は新しい車が気に入っている。",
"kana": "せんせいはあたらしいくるまがきにっている。", "kana": "せんせいはあたらしいくるまがきにっている。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "せんせい", "lifted": "せんせい",
"unlifted": "先生" "unlifted": "先生"
@ -594,6 +607,10 @@
"kanji": "先生は私の家まで車で送ってくれた。", "kanji": "先生は私の家まで車で送ってくれた。",
"kana": "せんせいはわたしのいえまでくるまでおくってくれた。", "kana": "せんせいはわたしのいえまでくるまでおくってくれた。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "せんせい", "lifted": "せんせい",
"unlifted": "先生" "unlifted": "先生"
@ -637,6 +654,10 @@
"kanji": "仙台行きの列車は出たばかりです。", "kanji": "仙台行きの列車は出たばかりです。",
"kana": "仙台いきのれっしゃはでたばかりです。", "kana": "仙台いきのれっしゃはでたばかりです。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n 仙台"
},
{ {
"lifted": "い", "lifted": "い",
"unlifted": "行き" "unlifted": "行き"
@ -672,6 +693,10 @@
"kanji": "雪のため列車は走れなかった。", "kanji": "雪のため列車は走れなかった。",
"kana": "ゆきのためれっしゃははしれなかった。", "kana": "ゆきのためれっしゃははしれなかった。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "ゆき", "lifted": "ゆき",
"unlifted": "雪" "unlifted": "雪"
@ -703,6 +728,10 @@
"kanji": "雪のため、列車が遅れた。", "kanji": "雪のため、列車が遅れた。",
"kana": "ゆきのため、れっしゃがおくれた。", "kana": "ゆきのため、れっしゃがおくれた。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "ゆき", "lifted": "ゆき",
"unlifted": "雪" "unlifted": "雪"
@ -715,6 +744,10 @@
"lifted": null, "lifted": null,
"unlifted": "ため" "unlifted": "ため"
}, },
{
"lifted": null,
"unlifted": "、"
},
{ {
"lifted": "れっしゃ", "lifted": "れっしゃ",
"unlifted": "列車" "unlifted": "列車"
@ -734,6 +767,10 @@
"kanji": "雪のせいで私は電車に乗り遅れた。", "kanji": "雪のせいで私は電車に乗り遅れた。",
"kana": "ゆきのせいでわたしはでんしゃにのりおくれた。", "kana": "ゆきのせいでわたしはでんしゃにのりおくれた。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "ゆき", "lifted": "ゆき",
"unlifted": "雪" "unlifted": "雪"
@ -769,6 +806,10 @@
"kanji": "切符なしで電車に乗ってはいけません。", "kanji": "切符なしで電車に乗ってはいけません。",
"kana": "きっぷなしででんしゃにのってはいけません。", "kana": "きっぷなしででんしゃにのってはいけません。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "きっぷ", "lifted": "きっぷ",
"unlifted": "切符" "unlifted": "切符"
@ -804,6 +845,10 @@
"kanji": "積み荷が落ちたので、トラックは停車しなければならなかった。", "kanji": "積み荷が落ちたので、トラックは停車しなければならなかった。",
"kana": "つみにがおちたので、トラックはていしゃしなければならなかった。", "kana": "つみにがおちたので、トラックはていしゃしなければならなかった。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "つみに", "lifted": "つみに",
"unlifted": "積み荷" "unlifted": "積み荷"
@ -820,6 +865,10 @@
"lifted": null, "lifted": null,
"unlifted": "ので" "unlifted": "ので"
}, },
{
"lifted": null,
"unlifted": "、"
},
{ {
"lifted": null, "lifted": null,
"unlifted": "トラック" "unlifted": "トラック"
@ -841,6 +890,49 @@
"unlifted": "なければならなかった" "unlifted": "なければならなかった"
} }
] ]
},
{
"english": "I'll come at noon to pick you up.",
"kanji": "正午に車で迎えに行くよ。",
"kana": "しょうごにくるまでむかえにいくよ。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "しょうご",
"unlifted": "正午"
},
{
"lifted": null,
"unlifted": "に"
},
{
"lifted": "くるま",
"unlifted": "車"
},
{
"lifted": null,
"unlifted": "で"
},
{
"lifted": "むか",
"unlifted": "迎え"
},
{
"lifted": null,
"unlifted": "に"
},
{
"lifted": "い",
"unlifted": "行く"
},
{
"lifted": null,
"unlifted": "よ"
}
]
} }
], ],
"uri": "https://jisho.org/search/%E8%BB%8A%23sentences" "uri": "https://jisho.org/search/%E8%BB%8A%23sentences"

View File

@ -7,10 +7,18 @@
"kanji": "戦後、日本人の勤勉さと節約はアメリカ人に強い印象を与えた。", "kanji": "戦後、日本人の勤勉さと節約はアメリカ人に強い印象を与えた。",
"kana": "せんご、にほんじんのきんべんさとせつやくはアメリカじんにつよいいんしょうをあたえた。", "kana": "せんご、にほんじんのきんべんさとせつやくはアメリカじんにつよいいんしょうをあたえた。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "せんご", "lifted": "せんご",
"unlifted": "戦後" "unlifted": "戦後"
}, },
{
"lifted": null,
"unlifted": "、"
},
{ {
"lifted": "にほんじん", "lifted": "にほんじん",
"unlifted": "日本人" "unlifted": "日本人"
@ -58,6 +66,10 @@
"kanji": "清潔は日本人の習性だ。", "kanji": "清潔は日本人の習性だ。",
"kana": "せいけつはにほんじんのしゅうせいだ。", "kana": "せいけつはにほんじんのしゅうせいだ。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "せいけつ", "lifted": "せいけつ",
"unlifted": "清潔" "unlifted": "清潔"
@ -89,6 +101,10 @@
"kanji": "乗船客は主に日本人だった。", "kanji": "乗船客は主に日本人だった。",
"kana": "じょうせんきゃくはおもににほんじんだった。", "kana": "じょうせんきゃくはおもににほんじんだった。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "じょうせん", "lifted": "じょうせん",
"unlifted": "乗船" "unlifted": "乗船"
@ -120,6 +136,10 @@
"kanji": "出席をしている人々は全部日本人です。", "kanji": "出席をしている人々は全部日本人です。",
"kana": "しゅっせきをしているひとびと々はぜんぶにほんじんです。", "kana": "しゅっせきをしているひとびと々はぜんぶにほんじんです。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "しゅっせき", "lifted": "しゅっせき",
"unlifted": "出席" "unlifted": "出席"
@ -159,6 +179,10 @@
"kanji": "若い日本人の中には、結婚するより独身でいることを好む者もいる。", "kanji": "若い日本人の中には、結婚するより独身でいることを好む者もいる。",
"kana": "わかいにほんじんのなかには、けっこんするよりどくしんでいることをこのむものもいる。", "kana": "わかいにほんじんのなかには、けっこんするよりどくしんでいることをこのむものもいる。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "わか", "lifted": "わか",
"unlifted": "若い" "unlifted": "若い"
@ -179,6 +203,10 @@
"lifted": null, "lifted": null,
"unlifted": "には" "unlifted": "には"
}, },
{
"lifted": null,
"unlifted": "、"
},
{ {
"lifted": "けっこん", "lifted": "けっこん",
"unlifted": "結婚する" "unlifted": "結婚する"
@ -230,6 +258,10 @@
"kanji": "私は彼が日本人だとは知らなかった。", "kanji": "私は彼が日本人だとは知らなかった。",
"kana": "わたしはかれがにほんじんだとはしらなかった。", "kana": "わたしはかれがにほんじんだとはしらなかった。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "わたし", "lifted": "わたし",
"unlifted": "私" "unlifted": "私"
@ -273,6 +305,10 @@
"kanji": "私は日本人一般について言っているのだ。", "kanji": "私は日本人一般について言っているのだ。",
"kana": "わたしはにほんじんいっぱんについていっているのだ。", "kana": "わたしはにほんじんいっぱんについていっているのだ。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "わたし", "lifted": "わたし",
"unlifted": "私" "unlifted": "私"
@ -308,6 +344,10 @@
"kanji": "私は日本人ですが、あなたはアメリカ人です。", "kanji": "私は日本人ですが、あなたはアメリカ人です。",
"kana": "わたしはにほんじんですが、あなたはアメリカじんです。", "kana": "わたしはにほんじんですが、あなたはアメリカじんです。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "わたし", "lifted": "わたし",
"unlifted": "私" "unlifted": "私"
@ -328,6 +368,10 @@
"lifted": null, "lifted": null,
"unlifted": "が" "unlifted": "が"
}, },
{
"lifted": null,
"unlifted": "、"
},
{ {
"lifted": null, "lifted": null,
"unlifted": "あなた" "unlifted": "あなた"
@ -351,6 +395,10 @@
"kanji": "私は仕事中毒者は日本人だけかと思っていました。", "kanji": "私は仕事中毒者は日本人だけかと思っていました。",
"kana": "わたしはしごとちゅうどくしゃはにほんじんだけかとおもっていました。", "kana": "わたしはしごとちゅうどくしゃはにほんじんだけかとおもっていました。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "わたし", "lifted": "わたし",
"unlifted": "私" "unlifted": "私"
@ -402,6 +450,10 @@
"kanji": "日本人ならそんなことはけっしてしないでしょう。", "kanji": "日本人ならそんなことはけっしてしないでしょう。",
"kana": "にほんじんならそんなことはけっしてしないでしょう。", "kana": "にほんじんならそんなことはけっしてしないでしょう。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "にほんじん", "lifted": "にほんじん",
"unlifted": "日本人" "unlifted": "日本人"
@ -441,6 +493,10 @@
"kanji": "こんな歌を残している明治天皇の一面を知っている日本人は少ないのではないだろうか。", "kanji": "こんな歌を残している明治天皇の一面を知っている日本人は少ないのではないだろうか。",
"kana": "こんなうたをのこしているめいじてんのうのいちめんをしっているにほんじんはすくないのではないだろうか。", "kana": "こんなうたをのこしているめいじてんのうのいちめんをしっているにほんじんはすくないのではないだろうか。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": null, "lifted": null,
"unlifted": "こんな" "unlifted": "こんな"
@ -508,6 +564,10 @@
"kanji": "私は日本人ですが、日本に住んでいません。", "kanji": "私は日本人ですが、日本に住んでいません。",
"kana": "わたしはにほんじんですが、にほんにすんでいません。", "kana": "わたしはにほんじんですが、にほんにすんでいません。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "わたし", "lifted": "わたし",
"unlifted": "私" "unlifted": "私"
@ -528,6 +588,10 @@
"lifted": null, "lifted": null,
"unlifted": "が" "unlifted": "が"
}, },
{
"lifted": null,
"unlifted": "、"
},
{ {
"lifted": "にほん", "lifted": "にほん",
"unlifted": "日本" "unlifted": "日本"
@ -547,6 +611,10 @@
"kanji": "向こうではセレブという言葉を「金持ち」の意味では使わない。という事で日本人と判明しました。", "kanji": "向こうではセレブという言葉を「金持ち」の意味では使わない。という事で日本人と判明しました。",
"kana": "むこうではセレブということばを「かねもち」のいみではつかわない。ということでにほんじんとはんめいしました。", "kana": "むこうではセレブということばを「かねもち」のいみではつかわない。ということでにほんじんとはんめいしました。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "む", "lifted": "む",
"unlifted": "向こう" "unlifted": "向こう"
@ -575,10 +643,18 @@
"lifted": null, "lifted": null,
"unlifted": "を" "unlifted": "を"
}, },
{
"lifted": null,
"unlifted": "「"
},
{ {
"lifted": "かねも", "lifted": "かねも",
"unlifted": "金持ち" "unlifted": "金持ち"
}, },
{
"lifted": null,
"unlifted": "」"
},
{ {
"lifted": null, "lifted": null,
"unlifted": "の" "unlifted": "の"
@ -599,6 +675,10 @@
"lifted": "つか", "lifted": "つか",
"unlifted": "使わない" "unlifted": "使わない"
}, },
{
"lifted": null,
"unlifted": "。"
},
{ {
"lifted": null, "lifted": null,
"unlifted": "と" "unlifted": "と"
@ -638,6 +718,10 @@
"kanji": "日本人で英語をうまく使える人はほとんどいません。", "kanji": "日本人で英語をうまく使える人はほとんどいません。",
"kana": "にほんじんでえいごをうまくつかえるひとはほとんどいません。", "kana": "にほんじんでえいごをうまくつかえるひとはほとんどいません。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "にほんじん", "lifted": "にほんじん",
"unlifted": "日本人" "unlifted": "日本人"
@ -685,6 +769,10 @@
"kanji": "日本人離れしたこの美しい相貌からもわかるように、優奈は実は生粋の日本人じゃない。西洋人をおばあちゃんに持つ、クォーターだったりする。", "kanji": "日本人離れしたこの美しい相貌からもわかるように、優奈は実は生粋の日本人じゃない。西洋人をおばあちゃんに持つ、クォーターだったりする。",
"kana": "にほんじんはなれしたこのうつくしいそうぼうからもわかるように、優奈はじつはきっすいのにほんじんじゃない。せいようじんをおばあちゃんにもつ、クォーターだったりする。", "kana": "にほんじんはなれしたこのうつくしいそうぼうからもわかるように、優奈はじつはきっすいのにほんじんじゃない。せいようじんをおばあちゃんにもつ、クォーターだったりする。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "にほんじん", "lifted": "にほんじん",
"unlifted": "日本人" "unlifted": "日本人"
@ -725,6 +813,10 @@
"lifted": null, "lifted": null,
"unlifted": "ように" "unlifted": "ように"
}, },
{
"lifted": null,
"unlifted": "、優奈"
},
{ {
"lifted": null, "lifted": null,
"unlifted": "は" "unlifted": "は"
@ -745,6 +837,10 @@
"lifted": null, "lifted": null,
"unlifted": "じゃない" "unlifted": "じゃない"
}, },
{
"lifted": null,
"unlifted": "。"
},
{ {
"lifted": "せいようじん", "lifted": "せいようじん",
"unlifted": "西洋人" "unlifted": "西洋人"
@ -765,6 +861,10 @@
"lifted": "も", "lifted": "も",
"unlifted": "持つ" "unlifted": "持つ"
}, },
{
"lifted": null,
"unlifted": "、"
},
{ {
"lifted": null, "lifted": null,
"unlifted": "クォーター" "unlifted": "クォーター"
@ -784,6 +884,10 @@
"kanji": "今日のトピックは「北朝鮮による日本人拉致問題」です。", "kanji": "今日のトピックは「北朝鮮による日本人拉致問題」です。",
"kana": "きょうのトピックは「きたちょうせんによるにほんじんらちもんだい」です。", "kana": "きょうのトピックは「きたちょうせんによるにほんじんらちもんだい」です。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "きょう", "lifted": "きょう",
"unlifted": "今日" "unlifted": "今日"
@ -800,6 +904,10 @@
"lifted": null, "lifted": null,
"unlifted": "は" "unlifted": "は"
}, },
{
"lifted": null,
"unlifted": "「"
},
{ {
"lifted": "きたちょうせん", "lifted": "きたちょうせん",
"unlifted": "北朝鮮" "unlifted": "北朝鮮"
@ -820,6 +928,10 @@
"lifted": "もんだい", "lifted": "もんだい",
"unlifted": "問題" "unlifted": "問題"
}, },
{
"lifted": null,
"unlifted": "」"
},
{ {
"lifted": null, "lifted": null,
"unlifted": "です" "unlifted": "です"
@ -831,6 +943,10 @@
"kanji": "外米はぼそぼそしていて、日本人の口には合わない。", "kanji": "外米はぼそぼそしていて、日本人の口には合わない。",
"kana": "がいまいはぼそぼそしていて、にほんじんのくちにはあわない。", "kana": "がいまいはぼそぼそしていて、にほんじんのくちにはあわない。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "がいまい", "lifted": "がいまい",
"unlifted": "外米" "unlifted": "外米"
@ -847,6 +963,10 @@
"lifted": null, "lifted": null,
"unlifted": "していて" "unlifted": "していて"
}, },
{
"lifted": null,
"unlifted": "、"
},
{ {
"lifted": "にほんじん", "lifted": "にほんじん",
"unlifted": "日本人" "unlifted": "日本人"
@ -874,10 +994,18 @@
"kanji": "毎年、多くの日本人が海外へ旅行する。", "kanji": "毎年、多くの日本人が海外へ旅行する。",
"kana": "まいとし、おおくのにほんじんがかいがいへりょこうする。", "kana": "まいとし、おおくのにほんじんがかいがいへりょこうする。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "まいとし", "lifted": "まいとし",
"unlifted": "毎年" "unlifted": "毎年"
}, },
{
"lifted": null,
"unlifted": "、"
},
{ {
"lifted": "おお", "lifted": "おお",
"unlifted": "多く" "unlifted": "多く"
@ -917,6 +1045,10 @@
"kanji": "彼女の父親は日本人だ。", "kanji": "彼女の父親は日本人だ。",
"kana": "かのじょのちちおやはにほんじんだ。", "kana": "かのじょのちちおやはにほんじんだ。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "かのじょ", "lifted": "かのじょ",
"unlifted": "彼女の" "unlifted": "彼女の"
@ -944,6 +1076,10 @@
"kanji": "彼らは日本人労働者が不足しているから外国人を雇う。", "kanji": "彼らは日本人労働者が不足しているから外国人を雇う。",
"kana": "かれらはにほんじんろうどうしゃがふそくしているからがいこくじんをやとう。", "kana": "かれらはにほんじんろうどうしゃがふそくしているからがいこくじんをやとう。",
"pieces": [ "pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{ {
"lifted": "かれ", "lifted": "かれ",
"unlifted": "彼ら" "unlifted": "彼ら"

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@
"query": "車", "query": "車",
"found": true, "found": true,
"data": { "data": {
"kanji": "車",
"taughtIn": "grade 1", "taughtIn": "grade 1",
"jlptLevel": "N5", "jlptLevel": "N5",
"newspaperFrequencyRank": 333, "newspaperFrequencyRank": 333,
@ -20,31 +21,31 @@
"meaning": "car, vehicle" "meaning": "car, vehicle"
}, },
{ {
"example": "車", "example": "車",
"reading": "シャケン", "reading": "シャ",
"meaning": "vehicle inspection" "meaning": "garage, carport, depot (trains, buses, etc.)"
}, },
{ {
"example": "見切り発車", "example": "車",
"reading": "ミキリハッシャ", "reading": "チュウシャ",
"meaning": "starting a train (or bus, etc.) before all the passengers are on board, making a snap decision, starting an action without considering objections to it any longer" "meaning": "parking (e.g. car)"
}, },
{ {
"example": "軽自動車", "example": "車",
"reading": "ケイジドウシャ", "reading": "ハッシャ",
"meaning": "light motor vehicle (up to 660cc and 64bhp), k-car, kei car" "meaning": "departure (of a train, car, etc.), starting, leaving"
} }
], ],
"kunyomiExamples": [ "kunyomiExamples": [
{ {
"example": "車", "example": "車",
"reading": "くるま", "reading": "くるま",
"meaning": "car, automobile, vehicle, wheel" "meaning": "car, automobile, vehicle, wheel, castor, caster"
}, },
{ {
"example": "車椅子", "example": "車椅子",
"reading": "くるまいす", "reading": "くるまいす",
"meaning": "wheelchair, folding push-chair" "meaning": "wheelchair"
}, },
{ {
"example": "火の車", "example": "火の車",

View File

@ -2,6 +2,7 @@
"query": "家", "query": "家",
"found": true, "found": true,
"data": { "data": {
"kanji": "家",
"taughtIn": "grade 2", "taughtIn": "grade 2",
"jlptLevel": "N4", "jlptLevel": "N4",
"newspaperFrequencyRank": 133, "newspaperFrequencyRank": 133,
@ -23,19 +24,19 @@
"meaning": "-ist, -er" "meaning": "-ist, -er"
}, },
{ {
"example": "家", "example": "家",
"reading": "カク", "reading": "カク",
"meaning": "house, building" "meaning": "family"
}, },
{ {
"example": "研究家", "example": "家",
"reading": "ケンキュウカ", "reading": "カ",
"meaning": "researcher, student (of)" "meaning": "painter, artist"
}, },
{ {
"example": "活動家", "example": "実業家",
"reading": "カツドウカ", "reading": "ジツギョウカ",
"meaning": "activist" "meaning": "businessman, entrepreneur, captain of industry"
}, },
{ {
"example": "家", "example": "家",
@ -47,15 +48,15 @@
"reading": "ケライ", "reading": "ケライ",
"meaning": "retainer, retinue, servant" "meaning": "retainer, retinue, servant"
}, },
{
"example": "分家",
"reading": "ブンケ",
"meaning": "branch family, cadet family, establishing a branch family"
},
{ {
"example": "本家", "example": "本家",
"reading": "ホンケ", "reading": "ホンケ",
"meaning": "head house (family), birthplace, originator" "meaning": "head house (family), birthplace, originator"
},
{
"example": "公家",
"reading": "クゲ",
"meaning": "court noble, nobility, Imperial Court"
} }
], ],
"kunyomiExamples": [ "kunyomiExamples": [
@ -82,23 +83,23 @@
{ {
"example": "屋", "example": "屋",
"reading": "や", "reading": "や",
"meaning": "(something) shop, somebody who sells (something) or works as (something), somebody with a (certain) personality trait, house, roof" "meaning": "shop, store, restaurant, someone who sells (something) or works as (something), someone with a (certain) personality trait, house, roof"
}, },
{ {
"example": "家内", "example": "家内",
"reading": "かない", "reading": "かない",
"meaning": "(my) wife, inside the home, one's family" "meaning": "(my) wife, inside the home, one's family"
}, },
{
"example": "隠れ家",
"reading": "かくれが",
"meaning": "hiding place, hideout, refuge, retreat, hideaway"
},
{ {
"example": "長屋", "example": "長屋",
"reading": "ながや", "reading": "ながや",
"meaning": "tenement house, row house" "meaning": "tenement house, row house"
}, },
{
"example": "本家",
"reading": "ほんけ",
"meaning": "head house (family), birthplace, originator"
},
{ {
"example": "家", "example": "家",
"reading": "うち", "reading": "うち",

View File

@ -2,6 +2,7 @@
"query": "楽", "query": "楽",
"found": true, "found": true,
"data": { "data": {
"kanji": "楽",
"taughtIn": "grade 2", "taughtIn": "grade 2",
"jlptLevel": "N4", "jlptLevel": "N4",
"newspaperFrequencyRank": 373, "newspaperFrequencyRank": 373,
@ -24,9 +25,9 @@
"meaning": "music, old Japanese court music, gagaku" "meaning": "music, old Japanese court music, gagaku"
}, },
{ {
"example": "楽", "example": "楽",
"reading": "ガクショウ", "reading": "ガク",
"meaning": "(musical) movement" "meaning": "score, sheet music"
}, },
{ {
"example": "邦楽", "example": "邦楽",
@ -49,14 +50,14 @@
"meaning": "paradise, Eden, Elysium" "meaning": "paradise, Eden, Elysium"
}, },
{ {
"example": "千秋楽", "example": "楽",
"reading": "センシュウラク", "reading": "ゴクラク",
"meaning": "concluding festivities, concluding program, concluding programme, final day of a tournament" "meaning": "Sukhavati (Amitabha's Pure Land), paradise, heaven on earth"
}, },
{ {
"example": "楽", "example": "楽",
"reading": "ウラク", "reading": "キョウラク",
"meaning": "outing, excursion, pleasure trip, going on a picnic" "meaning": "enjoyment, pleasure"
}, },
{ {
"example": "猿楽", "example": "猿楽",

View File

@ -2,6 +2,7 @@
"query": "贄", "query": "贄",
"found": true, "found": true,
"data": { "data": {
"kanji": "贄",
"taughtIn": null, "taughtIn": null,
"jlptLevel": null, "jlptLevel": null,
"newspaperFrequencyRank": null, "newspaperFrequencyRank": null,

View File

@ -2,6 +2,7 @@
"query": "水", "query": "水",
"found": true, "found": true,
"data": { "data": {
"kanji": "水",
"taughtIn": "grade 1", "taughtIn": "grade 1",
"jlptLevel": "N5", "jlptLevel": "N5",
"newspaperFrequencyRank": 223, "newspaperFrequencyRank": 223,
@ -21,19 +22,19 @@
"meaning": "Wednesday, shaved ice (served with flavored syrup), water (fifth of the five elements)" "meaning": "Wednesday, shaved ice (served with flavored syrup), water (fifth of the five elements)"
}, },
{ {
"example": "水", "example": "水曜日",
"reading": "スイ", "reading": "スイヨウビ",
"meaning": "water level" "meaning": "Wednesday"
}, },
{ {
"example": "水", "example": "水",
"reading": "ヨウスイ", "reading": "ダンスイ",
"meaning": "irrigation water, water for fire, city water, cistern water" "meaning": "suspension of water supply, water outage"
}, },
{ {
"example": "水", "example": "水",
"reading": "ジョウスイ", "reading": "センスイ",
"meaning": "clean water" "meaning": "diving, submerging, going underwater"
} }
], ],
"kunyomiExamples": [ "kunyomiExamples": [
@ -43,19 +44,19 @@
"meaning": "water (esp. cool, fresh water, e.g. drinking water), fluid (esp. in an animal tissue), liquid, flood, floodwaters, water offered to wrestlers just prior to a bout, break granted to wrestlers engaged in a prolonged bout" "meaning": "water (esp. cool, fresh water, e.g. drinking water), fluid (esp. in an animal tissue), liquid, flood, floodwaters, water offered to wrestlers just prior to a bout, break granted to wrestlers engaged in a prolonged bout"
}, },
{ {
"example": "水揚げ", "example": "水",
"reading": "みずあげ", "reading": "みず",
"meaning": "landing, unloading (e.g. a ship), catch (of fish), takings, sales (of a shop), defloration (e.g. of a geisha), preservation (of cut flowers, in ikebana)" "meaning": "bathing suit, swimsuit, swimmers"
}, },
{ {
"example": "飲み水", "example": "水",
"reading": "のみみず", "reading": "しゅっすい",
"meaning": "drinking water, potable water" "meaning": "flood, freshet, inundation"
}, },
{ {
"example": "呼び水", "example": "立て板に水",
"reading": "よびみず", "reading": "たていたにみず",
"meaning": "pump-priming, rousing, stimulation" "meaning": "eloquence, volubility, (like) water on a standing board"
} }
], ],
"radical": { "radical": {

View File

@ -71,6 +71,10 @@
{ {
"lifted": null, "lifted": null,
"unlifted": "ない" "unlifted": "ない"
},
{
"lifted": null,
"unlifted": "。"
} }
] ]
} }
@ -83,13 +87,18 @@
{ {
"seeAlsoTerms": [], "seeAlsoTerms": [],
"sentences": [], "sentences": [],
"definition": "wheel", "definition": "wheel; castor; caster",
"supplemental": [], "supplemental": [],
"definitionAbstract": null, "definitionAbstract": null,
"tags": [] "tags": []
} }
], ],
"otherForms": [], "otherForms": [
{
"kanji": "クルマ",
"kana": null
}
],
"audio": [ "audio": [
{ {
"uri": "https://d1vjc5dkcd3yh2.cloudfront.net/audio/7f47c2a8e633ca3a79ac199f55a212dd.mp3", "uri": "https://d1vjc5dkcd3yh2.cloudfront.net/audio/7f47c2a8e633ca3a79ac199f55a212dd.mp3",

View File

@ -10,7 +10,7 @@
{ {
"seeAlsoTerms": [], "seeAlsoTerms": [],
"sentences": [], "sentences": [],
"definition": "Japanese person; Japanese people", "definition": "Japanese person",
"supplemental": [], "supplemental": [],
"definitionAbstract": null, "definitionAbstract": null,
"tags": [] "tags": []

View File

@ -34,6 +34,10 @@
{ {
"lifted": "あい", "lifted": "あい",
"unlifted": "愛されている" "unlifted": "愛されている"
},
{
"lifted": null,
"unlifted": "。"
} }
] ]
} }
@ -71,6 +75,10 @@
{ {
"lifted": null, "lifted": null,
"unlifted": "しまった" "unlifted": "しまった"
},
{
"lifted": null,
"unlifted": "。"
} }
] ]
} }

View File

@ -14,9 +14,9 @@ List<String> getFilePaths(String dirname) {
.toList(); .toList();
} }
List getTestCases(String directoryName) { List<dynamic> getTestCases(String directoryName) {
final testCaseFiles = getFilePaths(directoryName); final testCaseFiles = getFilePaths(directoryName);
var result = []; final result = <dynamic>[];
for (var testCount = 0; testCount < testCaseFiles.length; testCount++) { for (var testCount = 0; testCount < testCaseFiles.length; testCount++) {
final file = File(testCaseFiles[testCount]).readAsStringSync(); final file = File(testCaseFiles[testCount]).readAsStringSync();
@ -27,32 +27,53 @@ List getTestCases(String directoryName) {
void main() { void main() {
group('searchForKanji', () { group('searchForKanji', () {
final testCases = getTestCases('kanji_test_cases'); final testCases = getTestCases('kanji_test_cases')
.map((e) => KanjiResult.fromJson(e))
.toList();
for (var testCase in testCases) { for (var testCase in testCases) {
test('Query "${testCase['query']}"', () async { test('Query "${testCase.query}"', () async {
final result = await searchForKanji(testCase['query']); final result = await searchForKanji(testCase.query);
expect(jsonEncode(result), jsonEncode(testCase)); expect(result, testCase);
}); });
} }
}); });
group('searchForExamples', () { group('searchForExamples', () {
final testCases = getTestCases('example_test_cases'); final testCases = getTestCases('example_test_cases')
.map((e) => ExampleResults.fromJson(e))
.toList();
for (var testCase in testCases) { for (var testCase in testCases) {
test('Query "${testCase['query']}"', () async { test('Query "${testCase.query}"', () async {
final result = await searchForExamples(testCase['query']); final result = await searchForExamples(testCase.query);
expect(jsonEncode(result), jsonEncode(testCase)); expect(result, testCase);
}); });
} }
}); });
group('scrapeForPhrase', () { group('scrapeForPhrase', () {
final testCases = getTestCases('phrase_scrape_test_cases'); final testCases = getTestCases('phrase_scrape_test_cases')
.map((e) => PhrasePageScrapeResult.fromJson(e))
.toList();
for (var testCase in testCases) { for (var testCase in testCases) {
test('Query "${testCase['query']}"', () async { test('Query "${testCase.query}"', () async {
final result = await scrapeForPhrase(testCase['query']); final result = await scrapeForPhrase(testCase.query);
expect(jsonEncode(result), jsonEncode(testCase)); expect(result, testCase);
}); });
} }
}); });
group('equatable', () {
// searchForExample returns random results, not stable for testing.
// I will assume it works if all the other works, and rather wait for
// reports in Github issues if something is broken.
final kanjiSearch = [searchForKanji(''), searchForKanji('')];
final phraseScrape = [scrapeForPhrase('関係'), scrapeForPhrase('関係')];
final phraseSearch = [searchForPhrase('関係'), searchForPhrase('関係')];
for (var testCase in [kanjiSearch, phraseScrape, phraseSearch]) {
test('Equate ${testCase[0].runtimeType}' , () async {
expect(await testCase[0], await testCase[1]);
});
}
});
} }