1
0
mirror of https://github.com/h7x4/unofficial_jisho_api_dart.git synced 2024-12-22 03:57:32 +01:00

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
- Fixed bug where pieces were missing in example sentences

View File

@ -39,6 +39,7 @@ void main() async {
final data = result.data;
if (data != null) {
print('Kanji: ${data.kanji}');
print('Taught in: ${data.taughtIn}');
print('JLPT level: ${data.jlptLevel}');
print('Newspaper frequency rank: ${data.newspaperFrequencyRank}');
@ -63,6 +64,7 @@ This outputs the following:
```
Found: true
Kanji: 語
Taught in: grade 2
JLPT level: N5
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
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;
if (data != null) {
print('Kanji: ${data.kanji}');
print('Taught in: ${data.taughtIn}');
print('JLPT level: ${data.jlptLevel}');
print('Newspaper frequency rank: ${data.newspaperFrequencyRank}');

View File

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

View File

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

View File

@ -147,8 +147,7 @@ ExampleResults parseExamplePageData(String pageHtml, String phrase) {
final results = divs.map(_parseExampleDiv).toList();
return ExampleResults(
query: phrase,
found: results.isNotEmpty,
results: results,
uri: uriForExampleSearch(phrase).toString());
query: phrase,
results: results,
);
}

View File

@ -14,7 +14,8 @@ Uri uriForKanjiSearch(String kanji) {
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';
}
@ -155,6 +156,7 @@ List<String> _getParts(String pageHtml) {
return result;
}
/// Provides the URI for a SVG image of the kanji
String _getSvgUri(String pageHtml) {
var svgRegex = RegExp('\/\/.*?.cloudfront.net\/.*?.svg');
@ -167,7 +169,8 @@ String _getSvgUri(String pageHtml) {
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 fileName = '$unicodeString.gif';
final animationUri =
@ -212,32 +215,26 @@ String? _getJlptLevel(String pageHtml) {
/// Parses a jisho kanji search page to an object
KanjiResult parseKanjiPageData(String pageHtml, String kanji) {
final result = KanjiResult(
query: kanji,
found: _containsKanjiGlyph(pageHtml, kanji),
);
if (result.found == false) {
return result;
if (!_containsKanjiGlyph(pageHtml, kanji)) {
return KanjiResult(query: kanji);
}
result.data = KanjiResultData(
strokeCount: _getStrokeCount(pageHtml),
meaning: _getMeaning(pageHtml),
strokeOrderDiagramUri: _getUriForStrokeOrderDiagram(kanji),
strokeOrderSvgUri: _getSvgUri(pageHtml),
strokeOrderGifUri: _getGifUri(kanji),
uri: uriForKanjiSearch(kanji).toString(),
parts: _getParts(pageHtml),
taughtIn: _getTaughtIn(pageHtml),
jlptLevel: _getJlptLevel(pageHtml),
newspaperFrequencyRank: _getNewspaperFrequencyRank(pageHtml),
kunyomi: _getKunyomi(pageHtml),
onyomi: _getOnyomi(pageHtml),
kunyomiExamples: _getKunyomiExamples(pageHtml),
onyomiExamples: _getOnyomiExamples(pageHtml),
radical: _getRadical(pageHtml),
return KanjiResult(
query: kanji,
data: KanjiResultData(
kanji: kanji,
strokeCount: _getStrokeCount(pageHtml),
meaning: _getMeaning(pageHtml),
strokeOrderSvgUri: _getSvgUri(pageHtml),
parts: _getParts(pageHtml),
taughtIn: _getTaughtIn(pageHtml),
jlptLevel: _getJlptLevel(pageHtml),
newspaperFrequencyRank: _getNewspaperFrequencyRank(pageHtml),
kunyomi: _getKunyomi(pageHtml),
onyomi: _getOnyomi(pageHtml),
kunyomiExamples: _getKunyomiExamples(pageHtml),
onyomiExamples: _getOnyomiExamples(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);
if (!_resultWasFound(document)) {
return PhrasePageScrapeResult(found: false, query: query);
return PhrasePageScrapeResult(query: query);
}
final data = _getMeaningsOtherFormsAndNotes(query, document);
return PhrasePageScrapeResult(
found: true,
query: query,
data: data,
data: _getMeaningsOtherFormsAndNotes(query, document),
);
}

View File

@ -1,5 +1,5 @@
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
homepage: https://github.com/h7x4ABk3g/unofficial_jisho_api_dart/
@ -12,6 +12,7 @@ dependencies:
http: ^0.13.3
html_unescape: ^2.0.0
html: ^0.15.0
equatable: ^2.0.3
dev_dependencies:
lints: ^1.0.1

View File

@ -2,70 +2,15 @@
"query": "車",
"found": true,
"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.",
"kanji": "走りさえすれば、どんな車でもよいのです。",
"kana": "はしりさえすれば、どんなくるまでもよいのです。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "はし",
"unlifted": "走り"
@ -74,6 +19,10 @@
"lifted": null,
"unlifted": "さえすれば"
},
{
"lifted": null,
"unlifted": "、"
},
{
"lifted": null,
"unlifted": "どんな"
@ -101,6 +50,10 @@
"kanji": "窓の外を見ると、車が1台来るのが見えた。",
"kana": "まどのそとをみると、くるまがいちだいきたるのがみえた。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "まど",
"unlifted": "窓"
@ -125,6 +78,10 @@
"lifted": null,
"unlifted": "と"
},
{
"lifted": null,
"unlifted": "、"
},
{
"lifted": "くるま",
"unlifted": "車"
@ -160,6 +117,10 @@
"kanji": "素敵な車じゃない。ずいぶん高かっただろう?",
"kana": "すてきなくるまじゃない。ずいぶんたかかっただろう?",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "すてき",
"unlifted": "素敵な"
@ -172,6 +133,10 @@
"lifted": null,
"unlifted": "じゃない"
},
{
"lifted": null,
"unlifted": "。"
},
{
"lifted": null,
"unlifted": "ずいぶん"
@ -191,6 +156,10 @@
"kanji": "祖母は列車で旅行をするのが好きだ。",
"kana": "そぼはれっしゃでりょこうをするのがすきだ。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "そぼ",
"unlifted": "祖母"
@ -242,6 +211,10 @@
"kanji": "全員その車に乗った。",
"kana": "ぜんいんそのくるまにのった。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "ぜんいん",
"unlifted": "全員"
@ -269,6 +242,10 @@
"kanji": "前方に赤い車が見える。",
"kana": "ぜんぽうにあかいくるまがみえる。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "ぜんぽう",
"unlifted": "前方"
@ -300,6 +277,10 @@
"kanji": "前の車は10年以上持っていた。",
"kana": "まえのくるまは10ねんいじょうもっていた。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "まえ",
"unlifted": "前"
@ -316,6 +297,10 @@
"lifted": null,
"unlifted": "は"
},
{
"lifted": null,
"unlifted": ""
},
{
"lifted": "ねん",
"unlifted": "年"
@ -335,6 +320,10 @@
"kanji": "船で旅行するのは車で旅行するよりも時間がかかる。",
"kana": "ふねでりょこうするのはくるまでりょこうするよりもじかんがかかる。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "ふね",
"unlifted": "船"
@ -390,6 +379,10 @@
"kanji": "線路の上に鉄片があったために列車は脱線した。",
"kana": "せんろのうえにてっぺんがあったためにれっしゃはだっせんした。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "せんろ",
"unlifted": "線路"
@ -445,10 +438,18 @@
"kanji": "洗えば、車は太陽の光をあびて輝くだろう。",
"kana": "あらえば、くるまはたいようのひかりをあびてかがやくだろう。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "あら",
"unlifted": "洗えば"
},
{
"lifted": null,
"unlifted": "、"
},
{
"lifted": "くるま",
"unlifted": "車"
@ -492,6 +493,10 @@
"kanji": "戦車や飛行機は軍隊を打ち破ることはできようが、国民を征服することはできない。",
"kana": "せんしゃやひこうきはぐんたいをうちやぶることはできようが、こくみんをせいふくすることはできない。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "せんしゃ",
"unlifted": "戦車"
@ -536,6 +541,10 @@
"lifted": null,
"unlifted": "が"
},
{
"lifted": null,
"unlifted": "、"
},
{
"lifted": "こくみん",
"unlifted": "国民"
@ -563,6 +572,10 @@
"kanji": "先生は新しい車が気に入っている。",
"kana": "せんせいはあたらしいくるまがきにっている。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "せんせい",
"unlifted": "先生"
@ -594,6 +607,10 @@
"kanji": "先生は私の家まで車で送ってくれた。",
"kana": "せんせいはわたしのいえまでくるまでおくってくれた。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "せんせい",
"unlifted": "先生"
@ -637,6 +654,10 @@
"kanji": "仙台行きの列車は出たばかりです。",
"kana": "仙台いきのれっしゃはでたばかりです。",
"pieces": [
{
"lifted": null,
"unlifted": "\n 仙台"
},
{
"lifted": "い",
"unlifted": "行き"
@ -672,6 +693,10 @@
"kanji": "雪のため列車は走れなかった。",
"kana": "ゆきのためれっしゃははしれなかった。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "ゆき",
"unlifted": "雪"
@ -703,6 +728,10 @@
"kanji": "雪のため、列車が遅れた。",
"kana": "ゆきのため、れっしゃがおくれた。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "ゆき",
"unlifted": "雪"
@ -715,6 +744,10 @@
"lifted": null,
"unlifted": "ため"
},
{
"lifted": null,
"unlifted": "、"
},
{
"lifted": "れっしゃ",
"unlifted": "列車"
@ -734,6 +767,10 @@
"kanji": "雪のせいで私は電車に乗り遅れた。",
"kana": "ゆきのせいでわたしはでんしゃにのりおくれた。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "ゆき",
"unlifted": "雪"
@ -769,6 +806,10 @@
"kanji": "切符なしで電車に乗ってはいけません。",
"kana": "きっぷなしででんしゃにのってはいけません。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "きっぷ",
"unlifted": "切符"
@ -804,6 +845,10 @@
"kanji": "積み荷が落ちたので、トラックは停車しなければならなかった。",
"kana": "つみにがおちたので、トラックはていしゃしなければならなかった。",
"pieces": [
{
"lifted": null,
"unlifted": "\n "
},
{
"lifted": "つみに",
"unlifted": "積み荷"
@ -820,6 +865,10 @@
"lifted": null,
"unlifted": "ので"
},
{
"lifted": null,
"unlifted": "、"
},
{
"lifted": null,
"unlifted": "トラック"
@ -841,6 +890,49 @@
"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"

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@
"query": "車",
"found": true,
"data": {
"kanji": "車",
"taughtIn": "grade 1",
"jlptLevel": "N5",
"newspaperFrequencyRank": 333,
@ -20,31 +21,31 @@
"meaning": "car, vehicle"
},
{
"example": "車",
"reading": "シャケン",
"meaning": "vehicle inspection"
"example": "車",
"reading": "シャ",
"meaning": "garage, carport, depot (trains, buses, etc.)"
},
{
"example": "見切り発車",
"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"
"example": "車",
"reading": "チュウシャ",
"meaning": "parking (e.g. car)"
},
{
"example": "軽自動車",
"reading": "ケイジドウシャ",
"meaning": "light motor vehicle (up to 660cc and 64bhp), k-car, kei car"
"example": "車",
"reading": "ハッシャ",
"meaning": "departure (of a train, car, etc.), starting, leaving"
}
],
"kunyomiExamples": [
{
"example": "車",
"reading": "くるま",
"meaning": "car, automobile, vehicle, wheel"
"meaning": "car, automobile, vehicle, wheel, castor, caster"
},
{
"example": "車椅子",
"reading": "くるまいす",
"meaning": "wheelchair, folding push-chair"
"meaning": "wheelchair"
},
{
"example": "火の車",

View File

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

View File

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

View File

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

View File

@ -2,6 +2,7 @@
"query": "水",
"found": true,
"data": {
"kanji": "水",
"taughtIn": "grade 1",
"jlptLevel": "N5",
"newspaperFrequencyRank": 223,
@ -21,19 +22,19 @@
"meaning": "Wednesday, shaved ice (served with flavored syrup), water (fifth of the five elements)"
},
{
"example": "水",
"reading": "スイ",
"meaning": "water level"
"example": "水曜日",
"reading": "スイヨウビ",
"meaning": "Wednesday"
},
{
"example": "水",
"reading": "ヨウスイ",
"meaning": "irrigation water, water for fire, city water, cistern water"
"example": "水",
"reading": "ダンスイ",
"meaning": "suspension of water supply, water outage"
},
{
"example": "水",
"reading": "ジョウスイ",
"meaning": "clean water"
"example": "水",
"reading": "センスイ",
"meaning": "diving, submerging, going underwater"
}
],
"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"
},
{
"example": "水揚げ",
"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)"
"example": "水",
"reading": "みず",
"meaning": "bathing suit, swimsuit, swimmers"
},
{
"example": "飲み水",
"reading": "のみみず",
"meaning": "drinking water, potable water"
"example": "水",
"reading": "しゅっすい",
"meaning": "flood, freshet, inundation"
},
{
"example": "呼び水",
"reading": "よびみず",
"meaning": "pump-priming, rousing, stimulation"
"example": "立て板に水",
"reading": "たていたにみず",
"meaning": "eloquence, volubility, (like) water on a standing board"
}
],
"radical": {

View File

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

View File

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

View File

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

View File

@ -14,9 +14,9 @@ List<String> getFilePaths(String dirname) {
.toList();
}
List getTestCases(String directoryName) {
List<dynamic> getTestCases(String directoryName) {
final testCaseFiles = getFilePaths(directoryName);
var result = [];
final result = <dynamic>[];
for (var testCount = 0; testCount < testCaseFiles.length; testCount++) {
final file = File(testCaseFiles[testCount]).readAsStringSync();
@ -27,32 +27,53 @@ List getTestCases(String directoryName) {
void main() {
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) {
test('Query "${testCase['query']}"', () async {
final result = await searchForKanji(testCase['query']);
expect(jsonEncode(result), jsonEncode(testCase));
test('Query "${testCase.query}"', () async {
final result = await searchForKanji(testCase.query);
expect(result, testCase);
});
}
});
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) {
test('Query "${testCase['query']}"', () async {
final result = await searchForExamples(testCase['query']);
expect(jsonEncode(result), jsonEncode(testCase));
test('Query "${testCase.query}"', () async {
final result = await searchForExamples(testCase.query);
expect(result, testCase);
});
}
});
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) {
test('Query "${testCase['query']}"', () async {
final result = await scrapeForPhrase(testCase['query']);
expect(jsonEncode(result), jsonEncode(testCase));
test('Query "${testCase.query}"', () async {
final result = await scrapeForPhrase(testCase.query);
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]);
});
}
});
}