Update README

This commit is contained in:
Oystein Kristoffer Tveit 2021-07-26 00:04:14 +02:00
parent c75f252a9c
commit 7f578f8d97
3 changed files with 83 additions and 58 deletions

View File

@ -1,3 +1,7 @@
## 2.0.1
- Fixed the readme
## 2.0.0 ## 2.0.0
- Upgrade library to use null-safety - Upgrade library to use null-safety

View File

@ -36,21 +36,25 @@ import 'package:unofficial_jisho_api/api.dart' as jisho;
void main() async { void main() async {
await jisho.searchForKanji('語').then((result) { await jisho.searchForKanji('語').then((result) {
print('Found: ${result.found}'); print('Found: ${result.found}');
print('Taught in: ${result.taughtIn}');
print('JLPT level: ${result.jlptLevel}'); final data = result.data;
print('Newspaper frequency rank: ${result.newspaperFrequencyRank}'); if (data != null) {
print('Stroke count: ${result.strokeCount}'); print('Taught in: ${data.taughtIn}');
print('Meaning: ${result.meaning}'); print('JLPT level: ${data.jlptLevel}');
print('Kunyomi: ${jsonEncode(result.kunyomi)}'); print('Newspaper frequency rank: ${data.newspaperFrequencyRank}');
print('Kunyomi example: ${jsonEncode(result.kunyomiExamples[0])}'); print('Stroke count: ${data.strokeCount}');
print('Onyomi: ${jsonEncode(result.onyomi)}'); print('Meaning: ${data.meaning}');
print('Onyomi example: ${jsonEncode(result.onyomiExamples[0])}'); print('Kunyomi: ${jsonEncode(data.kunyomi)}');
print('Radical: ${jsonEncode(result.radical)}'); print('Kunyomi example: ${jsonEncode(data.kunyomiExamples[0])}');
print('Parts: ${jsonEncode(result.parts)}'); print('Onyomi: ${jsonEncode(data.onyomi)}');
print('Stroke order diagram: ${result.strokeOrderDiagramUri}'); print('Onyomi example: ${jsonEncode(data.onyomiExamples[0])}');
print('Stroke order SVG: ${result.strokeOrderSvgUri}'); print('Radical: ${jsonEncode(data.radical)}');
print('Stroke order GIF: ${result.strokeOrderGifUri}'); print('Parts: ${jsonEncode(data.parts)}');
print('Jisho Uri: ${result.uri}'); print('Stroke order diagram: ${data.strokeOrderDiagramUri}');
print('Stroke order SVG: ${data.strokeOrderSvgUri}');
print('Stroke order GIF: ${data.strokeOrderGifUri}');
print('Jisho Uri: ${data.uri}');
}
}); });
} }
``` ```
@ -143,6 +147,7 @@ This outputs the following:
{ {
"found": true, "found": true,
"query": "谷", "query": "谷",
"data": {
"uri": "https://jisho.org/word/%E8%B0%B7", "uri": "https://jisho.org/word/%E8%B0%B7",
"tags": [ "tags": [
"Common word", "Common word",
@ -156,9 +161,7 @@ This outputs the following:
"definition": "valley", "definition": "valley",
"supplemental": [], "supplemental": [],
"definitionAbstract": null, "definitionAbstract": null,
"tags": [ "tags": []
"noun"
]
}, },
{ {
"seeAlsoTerms": [], "seeAlsoTerms": [],
@ -166,9 +169,7 @@ This outputs the following:
"definition": "Valley", "definition": "Valley",
"supplemental": [], "supplemental": [],
"definitionAbstract": "In geology, a valley or dale is a depression with predominant extent in one direction. A very deep river valley may be called a canyon or gorge. The terms U-shaped and V-shaped are descriptive terms of geography to characterize the form of valleys. Most valleys belong to one of these two main types or a mixture of them, (at least) with respect of the cross section of the slopes or hillsides.", "definitionAbstract": "In geology, a valley or dale is a depression with predominant extent in one direction. A very deep river valley may be called a canyon or gorge. The terms U-shaped and V-shaped are descriptive terms of geography to characterize the form of valleys. Most valleys belong to one of these two main types or a mixture of them, (at least) with respect of the cross section of the slopes or hillsides.",
"tags": [ "tags": []
"wikipedia definition"
]
} }
], ],
"otherForms": [ "otherForms": [
@ -181,7 +182,18 @@ This outputs the following:
"kana": "たに" "kana": "たに"
} }
], ],
"audio": [
{
"uri": "https://d1vjc5dkcd3yh2.cloudfront.net/audio/b9ff4f25c7a20f0f39131b3e3db0cd19.mp3",
"mimetype": "audio/mpeg"
},
{
"uri": "https://d1vjc5dkcd3yh2.cloudfront.net/audio_ogg/b9ff4f25c7a20f0f39131b3e3db0cd19.ogg",
"mimetype": "audio/ogg"
}
],
"notes": [] "notes": []
}
} }
``` ```
@ -204,9 +216,12 @@ final String searchURI = jisho_parser.uriForKanjiSearch(searchKanji);
void main() async { void main() async {
await http.get(searchURI).then((result) { await http.get(searchURI).then((result) {
final parsedResult = jisho_parser.parseKanjiPageData(result.body, searchKanji); final parsedResult = jisho_parser.parseKanjiPageData(result.body, searchKanji);
print('JLPT level: ${parsedResult.jlptLevel}'); final data = parsedResult.data;
print('Stroke count: ${parsedResult.strokeCount}'); if (data != null) {
print('Meaning: ${parsedResult.meaning}'); print('JLPT level: ${data.jlptLevel}');
print('Stroke count: ${data.strokeCount}');
print('Meaning: ${data.meaning}');
}
}); });
} }
``` ```
@ -257,3 +272,9 @@ void main() async {
## 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
## Notes
The null-safety of dart 2.12 makes the parsing and interpreting of the native search API a little unreliable. Please be cautious when using `jisho.searchForPhrase()`, and if you do, please read the [API docs][api-docs] about the different result values.
[api-docs]: https://pub.dev/documentation/unofficial_jisho_api/latest/

View File

@ -1,5 +1,5 @@
name: unofficial_jisho_api name: unofficial_jisho_api
version: 2.0.0 version: 2.0.1
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/