diff --git a/README.md b/README.md index da30c56..7882093 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Warning: not functional yet +# unofficial_jisho_api A rewrite of the [unofficial-jisho-api](https://www.npmjs.com/package/unofficial-jisho-api) @@ -9,19 +9,18 @@ Below are some basic examples. ### Word/phrase search (provided by official Jisho API) -This returns the same results as the official [Jisho.org](https://jisho.org/) API. See the discussion of that [here](http://jisho.org/forum/54fefc1f6e73340b1f160000-is-there-any-kind-of-search-api). +This returns the same results as the official [Jisho.org](https://jisho.org/) API. See the discussion of that [here](https://jisho.org/forum/54fefc1f6e73340b1f160000-is-there-any-kind-of-search-api). ```dart import 'package:unofficial_jisho_api/unofficial_jisho_api.dart'; final jisho = JishoApi(); -main() async { +void main() async { jisho.searchForPhrase('日').then((result) { - ... - ... - ... -}); - + ... + ... + ... + }); } ``` @@ -32,13 +31,13 @@ import 'dart:convert' show jsonEncode; import 'package:unofficial_jisho_api/unofficial_jisho_api.dart'; final jisho = JishoApi(); -main() async { - jisho.searchForKanji('語').then((result) { - print('Found: ' + result.found); +void main() async { + await jisho.searchForKanji('語').then((result) { + print('Found: ' + result.found.toString()); print('Taught in: ' + result.taughtIn); print('JLPT level: ' + result.jlptLevel); - print('Newspaper frequency rank: ' + result.newspaperFrequencyRank); - print('Stroke count: ' + result.strokeCount); + print('Newspaper frequency rank: ' + result.newspaperFrequencyRank.toString()); + print('Stroke count: ' + result.strokeCount.toString()); print('Meaning: ' + result.meaning); print('Kunyomi: ' + jsonEncode(result.kunyomi)); print('Kunyomi example: ' + jsonEncode(result.kunyomiExamples[0])); @@ -50,7 +49,7 @@ main() async { print('Stroke order SVG: ' + result.strokeOrderSvgUri); print('Stroke order GIF: ' + result.strokeOrderGifUri); print('Jisho Uri: ' + result.uri); - } + }); } ``` @@ -68,11 +67,11 @@ Kunyomi example: {"example":"語る","reading":"かたる","meaning":"to talk ab Onyomi: ["ゴ"] Onyomi example: {"example":"語","reading":"ゴ","meaning":"language, word"} Radical: {"symbol":"言","forms":["訁"],"meaning":"speech"} -Parts: ["口","五","言"] -Stroke order diagram: http://classic.jisho.org/static/images/stroke_diagrams/35486_frames.png -Stroke order SVG: http://d1w6u4xc3l95km.cloudfront.net/kanji-2015-03/08a9e.svg -Stroke order GIF: https://raw.githubusercontent.com/mistval/kotoba/master/resources/images/kanjianimations/08a9e_anim.gif -Jisho Uri: http://jisho.org/search/%E8%AA%9E%23kanji +Parts: ["五","口","言"] +Stroke order diagram: https://classic.jisho.org/static/images/stroke_diagrams/35486_frames.png +Stroke order SVG: https://d1w6u4xc3l95km.cloudfront.net/kanji-2015-03/08a9e.svg +Stroke order GIF: https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/8a9e.gif +Jisho Uri: https://jisho.org/search/%E8%AA%9E%23kanji ``` ### Example search @@ -82,18 +81,18 @@ import 'dart:convert' show jsonEncode; import 'package:unofficial_jisho_api/unofficial_jisho_api.dart'; final jisho = JishoApi(); -main() async { - jisho.searchForExamples('日').then((result) { +void main() async { + await jisho.searchForExamples('日').then((result) { print('Jisho Uri: ' + result.uri); - print(); + print(''); - for (int i = 0; i < 3; ++i) { + for (int i = 0; i < 3; i++) { var example = result.results[i]; print(example.kanji); print(example.kana); print(example.english); print(jsonEncode(example.pieces)); - print(); + print(''); } }); } @@ -102,24 +101,23 @@ main() async { This outputs the following: ``` -Jisho Uri: http://jisho.org/search/%E6%97%A5%23sentences +Jisho Uri: https://jisho.org/search/%E6%97%A5%23sentences 日本人ならそんなことはけっしてしないでしょう。 にほんじんならそんなことはけっしてしないでしょう。 A Japanese person would never do such a thing. -[{"lifted":"にほんじん","unlifted":"日本人"},{"lifted":"","unlifted":"なら"},{"lifted":"","unlifted":"そんな"},{"lifted":"","unlifted":"こと"},{"lifted":"","unlifted":"は"},{"lifted":"","unlifted":"けっして"},{"lifted":"","unlifted":"しない"},{"lifted":""," -unlifted":"でしょう"}] +[{"lifted":"にほんじん","unlifted":"日本人"},{"lifted":null,"unlifted":"なら"},{"lifted":null,"unlifted":"そんな"},{"lifted":null,"unlifted":"こと"},{"lifted":null,"unlifted":"は"},{"lifted":null,"unlifted":"けっして"},{"lifted":null,"unlifted":"しない"},{"lifted":null,"unlifted":"でしょう"}] 今日はとても暑い。 きょうはとてもあつい。 It is very hot today. -[{"lifted":"きょう","unlifted":"今日"},{"lifted":"","unlifted":"は"},{"lifted":"","unlifted":"とても"},{"lifted":"あつ","unlifted":"暑い"}] +[{"lifted":"きょう","unlifted":"今日"},{"lifted":null,"unlifted":"は"},{"lifted":null,"unlifted":"とても"},{"lifted":"あつ","unlifted":"暑い"}] 日本には美しい都市が多い。例えば京都、奈良だ。 にほんにはうつくしいとしがおおい。たとえばきょうと、奈良だ。 Japan is full of beautiful cities. Kyoto and Nara, for instance. -[{"lifted":"にほん","unlifted":"日本"},{"lifted":"","unlifted":"には"},{"lifted":"うつく","unlifted":"美しい"},{"lifted":"とし","unlifted":"都市"},{"lifted":"","unlifted":"が"},{"lifted":"おお","unlifted":"多い"},{"lifted":"たと","unlifted":"例えば"},{"lift -ed":"きょうと","unlifted":"京都"},{"lifted":"","unlifted":"だ"}] +[{"lifted":"にほん","unlifted":"日本"},{"lifted":null,"unlifted":"には"},{"lifted":"うつく","unlifted":"美しい"},{"lifted":"とし","unlifted":"都市"},{"lifted":null,"unlifted":"が"},{"lifted":"おお","unlifted":"多い"},{"lifted":"たと","unlifted":"例えば"},{"lifted":"きょうと","unlifted":"京都"},{"lifted":null,"unlifted":"だ"}] + ``` ### Word/phrase scraping @@ -127,13 +125,14 @@ ed":"きょうと","unlifted":"京都"},{"lifted":"","unlifted":"だ"}] This scrapes the word/phrase page on Jisho.org. This can get you some data that the official API doesn't have, such as JLPT level and part-of-speech. The official API (`searchForPhrase`) should be preferred if it has the data you need. ```dart -import 'dart:convert' show jsonEncode; +import 'dart:convert'; import 'package:unofficial_jisho_api/unofficial_jisho_api.dart'; final jisho = JishoApi(); +final encoder = JsonEncoder.withIndent(' '); -main() async { - jisho.scrapeForPhrase('谷').then((data) { - print(jsonEncode(data); +void main() async { + await jisho.scrapeForPhrase('谷').then((data) { + print(encoder.convert(data)); }); } ``` @@ -156,7 +155,7 @@ This outputs the following: "sentences": [], "definition": "valley", "supplemental": [], - "definitionAbstract": "", + "definitionAbstract": null, "tags": [ "noun" ] @@ -186,69 +185,6 @@ This outputs the following: } ``` -## Parsing HTML strings - -You can provide the HTML responses from Jisho yourself. This can be useful if you need to use a CORS proxy or something. You can do whatever you need to do to get the HTML and then provide it to this module's parsing functions. For example: - -### Parse kanji page HTML - -```dart -import 'package:http/http.dart' as http; -import 'package:unofficial_jisho_api/unofficial_jisho_api.dart'; -final jisho = JishoApi(); - -main() async { - const SEARCH_KANJI = '車'; - final SEARCH_URI = jisho.getUriForKanjiSearch(SEARCH_KANJI); - - final response = await http.get(SEARCH_URI); - final json = jisho.parseKanjiPageHtml(response.body, SEARCH_KANJI); - - print('JLPT level: ${json.jlptLevel}'); - print('Stroke count: ${json.strokeCount}'); - print('Meaning: ${json.meaning}'); -} -``` - -### Parse example page HTML - -```dart -import 'package:http/http.dart' as http; -import 'package:unofficial_jisho_api/unofficial_jisho_api.dart'; -final jisho = JishoApi(); - -main() async { - const SEARCH_EXAMPLE = '保護者'; - final SEARCH_URI = jisho.getUriForExampleSearch(SEARCH_EXAMPLE); - - final response = await http.get(SEARCH_URI); - final json = jisho.parseExamplePageHtml(response.body, SEARCH_EXAMPLE); - - print('English: ${json.results[0].english}'); - print('Kanji ${json.results[0].kanji}'); - print('Kana: ${json.results[0].kana}'); -} -``` - -### Parse phrase page HTML - -```dart -import 'dart:convert' show jsonEncode; -import 'package:http/http.dart' as http; -import 'package:unofficial_jisho_api/unofficial_jisho_api.dart'; -final jisho = JishoApi(); - -main() async { - const SEARCH_EXAMPLE = '保護者'; - final SEARCH_URI = jisho.getUriForPhraseScrape(SEARCH_EXAMPLE); - - final response = await http.get(SEARCH_URI); - const json = jisho.parsePhraseScrapeHtml(response.body, SEARCH_EXAMPLE); - - print(jsonEncode(json, null, 2)); -} -``` - ## About -Permission to scrape granted by Jisho's admin Kimtaro: http://jisho.org/forum/54fefc1f6e73340b1f160000-is-there-any-kind-of-search-api \ No newline at end of file +Permission to scrape granted by Jisho's admin Kimtaro: https://jisho.org/forum/54fefc1f6e73340b1f160000-is-there-any-kind-of-search-api \ No newline at end of file diff --git a/example/example_search_example.dart b/example/example_search_example.dart new file mode 100644 index 0000000..d60f0ad --- /dev/null +++ b/example/example_search_example.dart @@ -0,0 +1,19 @@ +import 'dart:convert' show jsonEncode; +import 'package:unofficial_jisho_api/unofficial_jisho_api.dart'; +final jisho = JishoApi(); + +void main() async { + await jisho.searchForExamples('日').then((result) { + print('Jisho Uri: ' + result.uri); + print(''); + + for (int i = 0; i < 3; i++) { + var example = result.results[i]; + print(example.kanji); + print(example.kana); + print(example.english); + print(jsonEncode(example.pieces)); + print(''); + } + }); +} \ No newline at end of file diff --git a/example/kanji_search_example.dart b/example/kanji_search_example.dart new file mode 100644 index 0000000..78bf3ef --- /dev/null +++ b/example/kanji_search_example.dart @@ -0,0 +1,24 @@ +import 'dart:convert' show jsonEncode; +import 'package:unofficial_jisho_api/unofficial_jisho_api.dart'; +final jisho = JishoApi(); + +void main() async { + await jisho.searchForKanji('語').then((result) { + print('Found: ' + result.found.toString()); + print('Taught in: ' + result.taughtIn); + print('JLPT level: ' + result.jlptLevel); + print('Newspaper frequency rank: ' + result.newspaperFrequencyRank.toString()); + print('Stroke count: ' + result.strokeCount.toString()); + print('Meaning: ' + result.meaning); + print('Kunyomi: ' + jsonEncode(result.kunyomi)); + print('Kunyomi example: ' + jsonEncode(result.kunyomiExamples[0])); + print('Onyomi: ' + jsonEncode(result.onyomi)); + print('Onyomi example: ' + jsonEncode(result.onyomiExamples[0])); + print('Radical: ' + jsonEncode(result.radical)); + print('Parts: ' + jsonEncode(result.parts)); + print('Stroke order diagram: ' + result.strokeOrderDiagramUri); + print('Stroke order SVG: ' + result.strokeOrderSvgUri); + print('Stroke order GIF: ' + result.strokeOrderGifUri); + print('Jisho Uri: ' + result.uri); + }); +} \ No newline at end of file diff --git a/example/phrase_scrape_example.dart b/example/phrase_scrape_example.dart new file mode 100644 index 0000000..fcb3cbc --- /dev/null +++ b/example/phrase_scrape_example.dart @@ -0,0 +1,10 @@ +import 'dart:convert'; +import 'package:unofficial_jisho_api/unofficial_jisho_api.dart'; +final jisho = JishoApi(); +final encoder = JsonEncoder.withIndent(' '); + +void main() async { + await jisho.scrapeForPhrase('谷').then((data) { + print(encoder.convert(data)); + }); +} \ No newline at end of file diff --git a/example/phrase_search_example.dart b/example/phrase_search_example.dart new file mode 100644 index 0000000..1470950 --- /dev/null +++ b/example/phrase_search_example.dart @@ -0,0 +1,10 @@ +import 'dart:convert'; +import 'package:unofficial_jisho_api/unofficial_jisho_api.dart'; +final jisho = JishoApi(); +final encoder = JsonEncoder.withIndent(' '); + +void main() async { + await jisho.searchForPhrase('反対').then((result) { + print(encoder.convert(result)); + }); +} \ No newline at end of file diff --git a/example/unofficial_jisho_api_example.dart b/example/unofficial_jisho_api_example.dart deleted file mode 100644 index d068193..0000000 --- a/example/unofficial_jisho_api_example.dart +++ /dev/null @@ -1,4 +0,0 @@ -import 'package:unofficial_jisho_api/unofficial_jisho_api.dart'; - -void main() { -} diff --git a/lib/src/baseURI.dart b/lib/src/baseURI.dart new file mode 100644 index 0000000..c63a529 --- /dev/null +++ b/lib/src/baseURI.dart @@ -0,0 +1,3 @@ +const String JISHO_API = 'https://jisho.org/api/v1/search/words'; +const String SCRAPE_BASE_URI = 'https://jisho.org/search/'; +const String STROKE_ORDER_DIAGRAM_BASE_URI = 'https://classic.jisho.org/static/images/stroke_diagrams/'; \ No newline at end of file diff --git a/lib/src/exampleSearch.dart b/lib/src/exampleSearch.dart new file mode 100644 index 0000000..f8eba01 --- /dev/null +++ b/lib/src/exampleSearch.dart @@ -0,0 +1,123 @@ +import './baseURI.dart'; +import './objects.dart'; + +import 'package:html/parser.dart'; +import 'package:html/dom.dart'; + +final RegExp kanjiRegex = RegExp(r'[\u4e00-\u9faf\u3400-\u4dbf]'); + +String uriForExampleSearch(String phrase) { + return '${SCRAPE_BASE_URI}${Uri.encodeComponent(phrase)}%23sentences'; +} + +List getChildrenAndSymbols(Element ul) { + final ulText = ul.text; + final ulCharArray = ulText.split(''); + final ulChildren = ul.children; + var offsetPointer = 0; + List result = []; + + for (var element in ulChildren) { + if (element.text != ulText.substring(offsetPointer, offsetPointer + element.text.length)){ + var symbols = ''; + while (element.text.substring(0,1) != ulCharArray[offsetPointer]) { + symbols += ulCharArray[offsetPointer]; + offsetPointer++; + } + final symbolElement = Element.html('${symbols}'); + result.add(symbolElement); + } + offsetPointer += element.text.length; + result.add(element); + } + if (offsetPointer + 1 != ulText.length){ + final symbols = ulText.substring(offsetPointer, ulText.length-1); + final symbolElement = Element.html('${symbols}'); + result.add(symbolElement); + } + return result; +} + +ExampleResultData getKanjiAndKana(Element div) { + final ul = div.querySelector('ul'); + final contents = getChildrenAndSymbols(ul); + + var kanji = ''; + var kana = ''; + for (var i = 0; i < contents.length; i += 1) { + final content = contents[i]; + if (content.localName == 'li') { + final li = content; + final furigana = li.querySelector('.furigana')?.text; + final unlifted = li.querySelector('.unlinked')?.text; + + if (furigana != null) { + kanji += unlifted; + kana += furigana; + + final kanaEnding = []; + for (var j = unlifted.length - 1; j > 0; j -= 1) { + final char = unlifted[j]; + if (!kanjiRegex.hasMatch(char)) { + kanaEnding.add(char); + } else { + break; + } + } + + kana += kanaEnding.reversed.join(''); + } else { + kanji += unlifted; + kana += unlifted; + } + } else { + final text = content.text.trim(); + if (text != null) { + kanji += text; + kana += text; + } + } + } + + return ExampleResultData( + kanji: kanji, + kana: kana, + ); +} + +List getPieces(Element sentenceElement) { + final pieceElements = sentenceElement.querySelectorAll('li.clearfix'); + final List pieces = []; + for (var pieceIndex = 0; pieceIndex < pieceElements.length; pieceIndex += 1) { + final pieceElement = pieceElements[pieceIndex]; + pieces.add(ExampleSentencePiece( + lifted: pieceElement.querySelector('.furigana')?.text, + unlifted: pieceElement.querySelector('.unlinked')?.text, + )); + } + + return pieces; +} + +ExampleResultData parseExampleDiv(Element div) { + final result = getKanjiAndKana(div); + result.english = div.querySelector('.english').text; + result.pieces = getPieces(div) ?? []; + + return result; +} + +ExampleResults parseExamplePageData(String pageHtml, String phrase) { + final document = parse(pageHtml); + final divs = document.querySelectorAll('.sentence_content'); + + final results = divs.map((div) => parseExampleDiv(div)).toList(); + + return ExampleResults( + query: phrase, + found: results.isNotEmpty, + results: results ?? [], + uri: uriForExampleSearch(phrase), + phrase: phrase, + ); +} \ No newline at end of file diff --git a/lib/src/kanjiSearch.dart b/lib/src/kanjiSearch.dart new file mode 100644 index 0000000..53adcee --- /dev/null +++ b/lib/src/kanjiSearch.dart @@ -0,0 +1,214 @@ +import './baseURI.dart'; +import './objects.dart'; + + +import 'package:html_unescape/html_unescape.dart' as html_entities; +final htmlUnescape = html_entities.HtmlUnescape(); + +const String ONYOMI_LOCATOR_SYMBOL = 'On'; +const String KUNYOMI_LOCATOR_SYMBOL = 'Kun'; + +String removeNewlines(String str) { + return str.replaceAll(RegExp(r'(?:\r|\n)') , '').trim(); +} + +String uriForKanjiSearch(String kanji) { + return '${SCRAPE_BASE_URI}${Uri.encodeComponent(kanji)}%23kanji'; +} + +String getUriForStrokeOrderDiagram(String kanji) { + return '${STROKE_ORDER_DIAGRAM_BASE_URI}${kanji.codeUnitAt(0)}_frames.png'; +} + +bool containsKanjiGlyph(String pageHtml, String kanji) { + final kanjiGlyphToken = '

${kanji}

'; + return pageHtml.contains(kanjiGlyphToken); +} + +String getStringBetweenIndicies(String data, int startIndex, int endIndex) { + final result = data.substring(startIndex, endIndex); + return removeNewlines(result).trim(); +} + +String getStringBetweenStrings(String data, String startString, String endString) { + final regex = RegExp('${RegExp.escape(startString)}(.*?)${RegExp.escape(endString)}', dotAll: true); + final match = regex.allMatches(data).toList(); + + return match.isNotEmpty ? match[0].group(1).toString() : null; +} + +int getIntBetweenStrings(String pageHtml, String startString, String endString) { + final stringBetweenStrings = getStringBetweenStrings(pageHtml, startString, endString); + return int.parse(stringBetweenStrings); +} + +List getAllGlobalGroupMatches(String str, RegExp regex) { + var regexResults = regex.allMatches(str).toList(); + List results = []; + for (var match in regexResults) { + results.add(match.group(1)); + } + + return results; +} + +List parseAnchorsToArray(String str) { + final regex = RegExp(r'(.*?)<\/a>'); + return getAllGlobalGroupMatches(str, regex); +} + +List getYomi(String pageHtml, String yomiLocatorSymbol) { + final yomiSection = getStringBetweenStrings(pageHtml, '
${yomiLocatorSymbol}:
', ''); + return parseAnchorsToArray(yomiSection ?? ''); +} + +List getKunyomi(String pageHtml) { + return getYomi(pageHtml, KUNYOMI_LOCATOR_SYMBOL); +} + +List getOnyomi(String pageHtml) { + return getYomi(pageHtml, ONYOMI_LOCATOR_SYMBOL); +} + +List getYomiExamples(String pageHtml, String yomiLocatorSymbol) { + final locatorString = '

${yomiLocatorSymbol} reading compounds

'; + final exampleSection = getStringBetweenStrings(pageHtml, locatorString, ''); + if (exampleSection==null) { + return null; + } + + final regex = RegExp(r'
  • (.*?)<\/li>', dotAll: true); + final regexResults = getAllGlobalGroupMatches(exampleSection, regex).map((s) => s.trim()); + + final examples = regexResults.map((regexResult) { + final examplesLines = regexResult.split('\n').map((s) => s.trim()).toList(); + return YomiExample( + example: examplesLines[0], + reading: examplesLines[1].replaceAll('【', '').replaceAll('】', ''), + meaning: htmlUnescape.convert(examplesLines[2]), + ); + }); + + return examples.toList(); +} + +List getOnyomiExamples(String pageHtml) { + return getYomiExamples(pageHtml, ONYOMI_LOCATOR_SYMBOL); +} + +List getKunyomiExamples(String pageHtml) { + return getYomiExamples(pageHtml, KUNYOMI_LOCATOR_SYMBOL); +} + +Radical getRadical(String pageHtml) { + const radicalMeaningStartString = ''; + const radicalMeaningEndString = ''; + + var radicalMeaning = getStringBetweenStrings( + pageHtml, + radicalMeaningStartString, + radicalMeaningEndString, + ).trim(); + + if (radicalMeaning!=null) { + final radicalMeaningStartIndex = pageHtml.indexOf(radicalMeaningStartString); + + final radicalMeaningEndIndex = pageHtml.indexOf( + radicalMeaningEndString, + radicalMeaningStartIndex, + ); + + final radicalSymbolStartIndex = radicalMeaningEndIndex + radicalMeaningEndString.length; + const radicalSymbolEndString = ''; + final radicalSymbolEndIndex = pageHtml.indexOf(radicalSymbolEndString, radicalSymbolStartIndex); + + final radicalSymbolsString = getStringBetweenIndicies( + pageHtml, + radicalSymbolStartIndex, + radicalSymbolEndIndex, + ); + + if (radicalSymbolsString.length > 1) { + final radicalForms = radicalSymbolsString + .substring(1) + .replaceAll('(', '') + .replaceAll(')', '') + .trim() + .split(', '); + + return Radical( + symbol: radicalSymbolsString[0], + forms: radicalForms ?? [], + meaning: radicalMeaning + ); + } + + return Radical ( + symbol: radicalSymbolsString, + meaning: radicalMeaning + ); + } + + return null; +} + +List getParts(String pageHtml) { + const partsSectionStartString = '
    Parts:
    '; + const partsSectionEndString = ''; + + final partsSection = getStringBetweenStrings( + pageHtml, + partsSectionStartString, + partsSectionEndString, + ); + + var result = parseAnchorsToArray(partsSection); + result.sort(); + + return (result); +} + +String getSvgUri(String pageHtml) { + var svgRegex = RegExp('\/\/.*?.cloudfront.net\/.*?.svg'); + final regexResult = svgRegex.firstMatch(pageHtml).group(0).toString(); + return regexResult.isNotEmpty ? 'https:${regexResult}' : null; +} + +String getGifUri(String kanji) { + final unicodeString = kanji.codeUnitAt(0).toRadixString(16); + final fileName = '${unicodeString}.gif'; + final animationUri = 'https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/${fileName}'; + + return animationUri; +} + +int getNewspaperFrequencyRank(String pageHtml) { + final frequencySection = getStringBetweenStrings(pageHtml, '
    ', '
    '); + return (frequencySection != null) ? int.parse(getStringBetweenStrings(frequencySection, '', '')) : null; +} + +KanjiResult parseKanjiPageData(String pageHtml, String kanji) { + final result = KanjiResult(); + result.query = kanji; + result.found = containsKanjiGlyph(pageHtml, kanji); + if (result.found==false) { + return result; + } + + result.taughtIn = getStringBetweenStrings(pageHtml, 'taught in ', ''); + result.jlptLevel = getStringBetweenStrings(pageHtml, 'JLPT level ', ''); + result.newspaperFrequencyRank = getNewspaperFrequencyRank(pageHtml); + result.strokeCount = getIntBetweenStrings(pageHtml, '', ' strokes'); + result.meaning = htmlUnescape.convert(removeNewlines(getStringBetweenStrings(pageHtml, '
    ', '
    ')).trim()); + result.kunyomi = getKunyomi(pageHtml) ?? []; + result.onyomi = getOnyomi(pageHtml) ?? []; + result.onyomiExamples = getOnyomiExamples(pageHtml) ?? []; + result.kunyomiExamples = getKunyomiExamples(pageHtml) ?? []; + result.radical = getRadical(pageHtml); + result.parts = getParts(pageHtml) ?? []; + result.strokeOrderDiagramUri = getUriForStrokeOrderDiagram(kanji); + result.strokeOrderSvgUri = getSvgUri(pageHtml); + result.strokeOrderGifUri = getGifUri(kanji); + result.uri = uriForKanjiSearch(kanji); + return result; +} \ No newline at end of file diff --git a/lib/src/objects.dart b/lib/src/objects.dart index ccce5ac..adb9625 100644 --- a/lib/src/objects.dart +++ b/lib/src/objects.dart @@ -1,80 +1,17 @@ -class PhraseScrapeSentence { - String english; - String japanese; - List pieces; - - PhraseScrapeSentence ({String english, String japanese, List pieces}){ - this.english = english; - this.japanese = japanese; - this.pieces = pieces; - } -} - -class PhraseScrapeMeaning { - List seeAlsoTerms; - List sentences; - String definition; - List supplemental; - String definitionAbstract; - List tags; - - PhraseScrapeMeaning({ - List seeAlsoTerms, - List sentences, - String definition, - List supplemental, - String definitionAbstract, - List tags, - }){ - this.seeAlsoTerms = seeAlsoTerms; - this.sentences = sentences; - this.definition = definition; - this.supplemental = supplemental; - this.definitionAbstract = definitionAbstract; - this.tags = tags; - - } -} - -class PhrasePageScrapeResult { - bool found; - String query; - String uri; - List otherForms; - List meanings; - List tags; - List notes; - - PhrasePageScrapeResult({ - bool found, - String query, - String uri, - List otherForms, - List meanings, - List tags, - List notes, - }){ - this.found = found; - this.query = query; - this.uri = uri; - this.otherForms = otherForms; - this.meanings = meanings; - this.tags = tags; - this.notes = notes; - } -} +/* -------------------------------------------------------------------------- */ +/* searchForKanji related classes */ +/* -------------------------------------------------------------------------- */ class YomiExample { String example; String reading; String meaning; - YomiExample({String example, String reading, String meaning}) - { - this.example = example; - this.reading = reading; - this.meaning = meaning; - } + YomiExample({ + this.example, + this.reading, + this.meaning + }); Map toJson() => { @@ -90,17 +27,17 @@ class Radical { List forms; String meaning; - Radical({String symbol, List forms, String meaning}){ - this.symbol = symbol; - this.forms = forms; - this.meaning = meaning; - } + Radical({ + this.symbol, + this.forms, + this.meaning + }); Map toJson() => { - if (symbol != null) 'symbol': symbol, - if (forms != null) 'forms': forms, - if (meaning != null) 'meaning': meaning + 'symbol': symbol, + 'forms': forms, + 'meaning': meaning }; } @@ -125,26 +62,40 @@ class KanjiResult { String strokeOrderGifUri; String uri; + KanjiResult({ + this.query, + this.found, + this.taughtIn, + this.jlptLevel, + this.newspaperFrequencyRank, + this.strokeCount, + this.meaning, + this.kunyomi, + this.onyomi, + this.kunyomiExamples, + this.onyomiExamples, + this.radical, + this.parts, + this.strokeOrderDiagramUri, + this.strokeOrderSvgUri, + this.strokeOrderGifUri, + this.uri + }); + Map toJson() { - - if (found == false) return { - 'query': query, - 'found': found - }; - return { 'query': query, 'found': found, 'taughtIn': taughtIn, 'jlptLevel': jlptLevel, - 'newspaperFrequencyRank': newspaperFrequencyRank.toString(), + 'newspaperFrequencyRank': newspaperFrequencyRank, 'strokeCount': strokeCount, 'meaning': meaning, 'kunyomi': kunyomi, 'onyomi': onyomi, - 'onyomiExamples': onyomiExamples.map((onyomiExample) => onyomiExample.toJson()).toList(), - 'kunyomiExamples': kunyomiExamples.map((kunyomiExample) => kunyomiExample.toJson()).toList(), - 'radical': radical.toJson(), + 'onyomiExamples': onyomiExamples, + 'kunyomiExamples': kunyomiExamples, + 'radical': (radical != null) ? radical.toJson() : null, 'parts': parts, 'strokeOrderDiagramUri': strokeOrderDiagramUri, 'strokeOrderSvgUri': strokeOrderSvgUri, @@ -154,13 +105,24 @@ class KanjiResult { } } -class ExampleSentencePiece { - String unlifted; - String lifted; +/* -------------------------------------------------------------------------- */ +/* searchForExamples related classes */ +/* -------------------------------------------------------------------------- */ - ExampleSentencePiece({String unlifted, String lifted}){ - this.unlifted = unlifted; - this.lifted = lifted; +class ExampleSentencePiece { + String lifted; + String unlifted; + + ExampleSentencePiece({ + this.lifted, + this.unlifted + }); + + Map toJson() { + return { + 'lifted': lifted, + 'unlifted': unlifted + }; } } @@ -170,11 +132,20 @@ class ExampleResultData { String english; List pieces; - ExampleResultData({String kanji, String kana, String english, List pieces}){ - this.kanji = kanji; - this.kana = kana; - this.english = english; - this.pieces = pieces; + ExampleResultData({ + this.english, + this.kanji, + this.kana, + this.pieces + }); + + Map toJson() { + return { + 'english': english, + 'kanji': kanji, + 'kana': kana, + 'pieces': pieces + }; } } @@ -185,15 +156,310 @@ class ExampleResults { List results; String phrase; - ExampleResults({String query, bool found, String uri, List results, String phrase}){ - this.query = query; - this.found = found; - this.uri = uri; - this.results = results; - this.phrase = phrase; + ExampleResults({ + this.query, + this.found, + this.results, + this.uri, + this.phrase + }); + + Map toJson() { + return { + 'query': query, + 'found': found, + 'results': results, + 'uri': uri, + 'phrase': phrase + }; } } +/* -------------------------------------------------------------------------- */ +/* scrapeForPhrase related classes */ +/* -------------------------------------------------------------------------- */ +class PhraseScrapeSentence { + String english; + String japanese; + List pieces; + PhraseScrapeSentence ({ + this.english, + this.japanese, + this.pieces + }); + Map toJson() => { + 'english': english, + 'japanese': japanese, + 'pieces': pieces + }; +} + +class PhraseScrapeMeaning { + List seeAlsoTerms; + List sentences; + String definition; + List supplemental; + String definitionAbstract; + List tags; + + PhraseScrapeMeaning({ + this.seeAlsoTerms, + this.sentences, + this.definition, + this.supplemental, + this.definitionAbstract, + this.tags + }); + + Map toJson() => { + 'seeAlsoTerms': seeAlsoTerms, + 'sentences': sentences, + 'definition': definition, + 'supplemental': supplemental, + 'definitionAbstract': definitionAbstract, + 'tags': tags + }; +} + +class KanjiKanaPair { + String kanji; + String kana; + + KanjiKanaPair({ + this.kanji, + this.kana + }); + + Map toJson() => { + 'kanji': kanji, + 'kana': kana + }; +} + +class PhrasePageScrapeResult { + bool found; + String query; + String uri; + List tags; + List meanings; + List otherForms; + List notes; + + PhrasePageScrapeResult({ + this.found, + this.query, + this.uri, + this.tags, + this.meanings, + this.otherForms, + this.notes + }); + + Map toJson() => { + 'found': found, + 'query': query, + 'uri': uri, + 'tags': tags, + 'meanings': meanings, + 'otherForms': otherForms, + 'notes': notes + }; +} + +/* -------------------------------------------------------------------------- */ +/* searchForPhrase related classes */ +/* -------------------------------------------------------------------------- */ + +class JishoJapaneseWord { + String word; + String reading; + + JishoJapaneseWord({this.word, this.reading}); + + factory JishoJapaneseWord.fromJson(Map json){ + return JishoJapaneseWord( + word: json['word'] as String, + reading: json['reading'] as String + ); + } + + Map toJson() => { + 'word': word, + 'reading': reading + }; +} + +class JishoSenseLink { + String text; + String url; + + JishoSenseLink({this.text, this.url}); + + factory JishoSenseLink.fromJson(Map json){ + return JishoSenseLink( + text: json['text'] as String, + url: json['url'] as String + ); + } + + Map toJson() => { + 'text': text, + 'url': url + }; +} + +class JishoWordSense { + List english_definitions; + List parts_of_speech; + List links; + List tags; + List see_also; + List antonyms; + List source; + List info; + List restrictions; + + JishoWordSense({ + this.english_definitions, + this.parts_of_speech, + this.links, + this.tags, + this.see_also, + this.antonyms, + this.source, + this.info, + this.restrictions + }); + + factory JishoWordSense.fromJson(Map json){ + return JishoWordSense( + english_definitions: (json['english_definitions'] as List).map((result) => result as String).toList(), + parts_of_speech: (json['parts_of_speech'] as List).map((result) => result as String).toList(), + links: (json['links'] as List).map((result) => JishoSenseLink.fromJson(result)).toList(), + tags: (json['tags'] as List).map((result) => result as String).toList(), + see_also: (json['see_also'] as List).map((result) => result as String).toList(), + antonyms: (json['antonyms'] as List).map((result) => result as String).toList(), + source: json['source'] as List, + info: (json['info'] as List).map((result) => result as String).toList(), + restrictions: json['restrictions'] as List + ); + } + + Map toJson() => { + 'english_definitions': english_definitions, + 'parts_of_speech': parts_of_speech, + 'links': links, + 'tags': tags, + 'see_also': see_also, + 'antonyms': antonyms, + 'source': source, + 'info': info, + 'restrictions': restrictions + }; +} + +class JishoAttribution { + bool jmdict; + bool jmnedict; + String dbpedia; + + JishoAttribution({ + this.jmdict, + this.jmnedict, + this.dbpedia + }); + + factory JishoAttribution.fromJson(Map json){ + return JishoAttribution( + jmdict: (json['jmdict'].toString() == 'true'), + jmnedict: (json['jmnedict'].toString() == 'true'), + dbpedia: (json['dbpedia'].toString() != 'false') ? json['dbpedia'].toString() : null + ); + } + + Map toJson() => { + 'jmdict': jmdict, + 'jmnedict': jmnedict, + 'dbpedia': dbpedia + }; +} + +class JishoResult { + String slug; + bool is_common; + List tags; + List jlpt; + List japanese; + List senses; + JishoAttribution attribution; + + JishoResult({ + this.slug, + this.is_common, + this.tags, + this.jlpt, + this.japanese, + this.senses, + this.attribution + }); + + factory JishoResult.fromJson(Map json){ + return JishoResult( + slug: json['slug'] as String, + is_common: json['is_common'] as bool, + tags: (json['tags'] as List).map((result) => result as String).toList(), + jlpt: (json['jlpt'] as List).map((result) => result as String).toList(), + japanese: (json['japanese'] as List).map((result) => JishoJapaneseWord.fromJson(result)).toList(), + senses: (json['senses'] as List).map((result) => JishoWordSense.fromJson(result)).toList(), + attribution: JishoAttribution.fromJson(json['attribution']) + ); + } + + Map toJson() => { + 'slug': slug, + 'is_common': is_common, + 'tags': tags, + 'jlpt': jlpt, + 'japanese': japanese, + 'senses': senses, + 'attribution': attribution + }; +} + +class JishoResultMeta { + int status; + + JishoResultMeta({this.status}); + + factory JishoResultMeta.fromJson(Map json){ + return JishoResultMeta( + status: json['status'] as int + ); + } + + Map toJson() => { + 'status': status + }; +} + +class JishoAPIResult { + JishoResultMeta meta; + List data; + + JishoAPIResult({this.meta, this.data}); + + factory JishoAPIResult.fromJson(Map json){ + return JishoAPIResult( + meta: JishoResultMeta.fromJson(json['meta']), + data: (json['data'] as List).map((result) => JishoResult.fromJson(result)).toList() + ); + } + + Map toJson() => { + 'meta': meta.toJson(), + 'data': data + }; +} \ No newline at end of file diff --git a/lib/src/phraseScrape.dart b/lib/src/phraseScrape.dart new file mode 100644 index 0000000..3324cf9 --- /dev/null +++ b/lib/src/phraseScrape.dart @@ -0,0 +1,154 @@ +import './objects.dart'; +import './exampleSearch.dart'; + +import 'package:html/parser.dart'; +import 'package:html/dom.dart'; + +List getTags(Document document) { + final List tags = []; + final tagElements = document.querySelectorAll('.concept_light-tag'); + + for (var i = 0; i < tagElements.length; i += 1) { + final tagText = tagElements[i].text; + tags.add(tagText); + } + + return tags; +} + +List getMostRecentWordTypes(Element child) { + return child.text.split(',').map((s) => s.trim().toLowerCase()).toList(); +} + +List getOtherForms(Element child) { + return child.text.split('、') + .map((s) => s.replaceAll('【', '').replaceAll('】', '').split(' ')) + .map((a) => (KanjiKanaPair( kanji: a[0], kana: (a.length == 2) ? a[1] : null ))).toList(); +} + +List getNotes(Element child) => child.text.split('\n'); + +String getMeaning(Element child) => child.querySelector('.meaning-meaning').text; + +String getMeaningAbstract(Element child) { + final meaningAbstract = child.querySelector('.meaning-abstract'); + if (meaningAbstract == null) return null; + + for (var element in meaningAbstract.querySelectorAll('a')) { + element.remove(); + } + + return child.querySelector('.meaning-abstract')?.text; +} + +List getSupplemental(Element child) { + final supplemental = child.querySelector('.supplemental_info'); + if (supplemental == null) return []; + return supplemental.text.split(',').map((s) => s.trim()).toList(); +} + +List getSeeAlsoTerms(List supplemental) { + if (supplemental == null) return []; + + final List seeAlsoTerms = []; + for (var i = supplemental.length - 1; i >= 0; i -= 1) { + final supplementalEntry = supplemental[i]; + if (supplementalEntry.startsWith('See also')) { + seeAlsoTerms.add(supplementalEntry.replaceAll('See also ', '')); + supplemental.removeAt(i); + } + } + return seeAlsoTerms; +} + +List getSentences(Element child) { + final sentenceElements = child.querySelector('.sentences')?.querySelectorAll('.sentence'); + if (sentenceElements == null) return []; + + final List sentences = []; + for (var sentenceIndex = 0; sentenceIndex < (sentenceElements?.length ?? 0); sentenceIndex += 1) { + final sentenceElement = sentenceElements[sentenceIndex]; + + final english = sentenceElement.querySelector('.english').text; + final pieces = getPieces(sentenceElement); + + sentenceElement.querySelector('.english').remove(); + for (var element in sentenceElement.children[0].children) { + element.querySelector('.furigana')?.remove(); + } + + final japanese = sentenceElement.text; + + sentences.add( + PhraseScrapeSentence( + english: english, + japanese: japanese, + pieces: pieces ?? [] + ) + ); + } + + return sentences; +} + +PhrasePageScrapeResult getMeaningsOtherFormsAndNotes(Document document) { + final returnValues = PhrasePageScrapeResult( otherForms: [], notes: [] ); + + final meaningsWrapper = document.querySelector('.meanings-wrapper'); + if (meaningsWrapper == null) return PhrasePageScrapeResult(found: false); + returnValues.found = true; + + final meaningsChildren = meaningsWrapper.children; + + final List meanings = []; + var mostRecentWordTypes = []; + for (var meaningIndex = 0; meaningIndex < meaningsChildren.length; meaningIndex += 1) { + final child = meaningsChildren[meaningIndex]; + + if (child.className.contains('meaning-tags')) { + mostRecentWordTypes = getMostRecentWordTypes(child); + + } else if (mostRecentWordTypes[0] == 'other forms') { + returnValues.otherForms = getOtherForms(child); + + } else if (mostRecentWordTypes[0] == 'notes') { + returnValues.notes = getNotes(child); + + } else { + final meaning = getMeaning(child); + final meaningAbstract = getMeaningAbstract(child); + final supplemental = getSupplemental(child); + final seeAlsoTerms = getSeeAlsoTerms(supplemental); + final sentences = getSentences(child); + + meanings.add(PhraseScrapeMeaning( + seeAlsoTerms: seeAlsoTerms ?? [], + sentences: sentences ?? [], + definition: meaning, + supplemental: supplemental ?? [], + definitionAbstract: meaningAbstract, + tags: mostRecentWordTypes ?? [], + )); + } + } + + returnValues.meanings = meanings; + + return returnValues; +} + +String uriForPhraseScrape(String searchTerm) { + return 'https://jisho.org/word/${Uri.encodeComponent(searchTerm)}'; +} + +PhrasePageScrapeResult parsePhrasePageData(String pageHtml, String query) { + final document = parse(pageHtml); + final result = getMeaningsOtherFormsAndNotes(document); + + result.query = query; + if (!result.found) return result; + result.uri = uriForPhraseScrape(query); + result.tags = getTags(document); + + return result; +} \ No newline at end of file diff --git a/lib/src/phraseSearch.dart b/lib/src/phraseSearch.dart new file mode 100644 index 0000000..211ceb3 --- /dev/null +++ b/lib/src/phraseSearch.dart @@ -0,0 +1,5 @@ +import './baseURI.dart'; + +String uriForPhraseSearch(String phrase) { + return '${JISHO_API}?keyword=${Uri.encodeComponent(phrase)}'; +} \ No newline at end of file diff --git a/lib/src/unofficial_jisho_api_base.dart b/lib/src/unofficial_jisho_api_base.dart index 0485df2..635d983 100644 --- a/lib/src/unofficial_jisho_api_base.dart +++ b/lib/src/unofficial_jisho_api_base.dart @@ -1,437 +1,12 @@ -import 'package:unofficial_jisho_api/src/objects.dart'; +import './objects.dart'; import 'package:http/http.dart' as http; -import 'package:xml/xml.dart' as xml; -import 'package:html_unescape/html_unescape.dart' as html_entities; import 'dart:convert'; -final htmlUnescape = html_entities.HtmlUnescape(); +import './phraseSearch.dart'; +import './kanjiSearch.dart'; +import './exampleSearch.dart'; +import './phraseScrape.dart'; -// TODO: Put public facing types in this file. - -const String JISHO_API = 'http://jisho.org/api/v1/search/words'; -const String SCRAPE_BASE_URI = 'http://jisho.org/search/'; -const String STROKE_ORDER_DIAGRAM_BASE_URI = 'http://classic.jisho.org/static/images/stroke_diagrams/'; - -/* KANJI SEARCH FUNCTIONS START */ - -const String ONYOMI_LOCATOR_SYMBOL = 'On'; -const KUNYOMI_LOCATOR_SYMBOL = 'Kun'; - -String removeNewlines(String str) { - return str.replaceAll(RegExp(r'(?:\r|\n)') , '').trim(); -} - -String uriForKanjiSearch(String kanji) { - return '${SCRAPE_BASE_URI}${Uri.encodeComponent(kanji)}%23kanji'; -} - -String getUriForStrokeOrderDiagram(String kanji) { - return '${STROKE_ORDER_DIAGRAM_BASE_URI}${kanji.codeUnitAt(0)}_frames.png'; -} - -String uriForPhraseSearch(String phrase) { - return '${JISHO_API}?keyword=${Uri.encodeComponent(phrase)}'; -} - -bool containsKanjiGlyph(String pageHtml, String kanji) { - final kanjiGlyphToken = '

    ${kanji}

    '; - return pageHtml.contains(kanjiGlyphToken); -} - -String getStringBetweenIndicies(String data, int startIndex, int endIndex) { - final result = data.substring(startIndex, endIndex); - return removeNewlines(result).trim(); -} - -String getStringBetweenStrings(String data, String startString, String endString) { - final regex = RegExp('${RegExp.escape(startString)}(.*?)${RegExp.escape(endString)}', dotAll: true); - final match = regex.allMatches(data).toList(); //TODO: Something wrong here - - return match.isNotEmpty ? match[0].group(1).toString() : null; -} - -int getIntBetweenStrings(String pageHtml, String startString, String endString) { - final stringBetweenStrings = getStringBetweenStrings(pageHtml, startString, endString); - return int.parse(stringBetweenStrings); -} - -List getAllGlobalGroupMatches(String str, RegExp regex) { - var regexResults = regex.allMatches(str).toList(); - List results = []; - for (var match in regexResults) { - results.add(match.group(1)); - } - - return results; -} - -List parseAnchorsToArray(String str) { - final regex = RegExp(r'
    (.*?)<\/a>'); - return getAllGlobalGroupMatches(str, regex); -} - -List getYomi(String pageHtml, String yomiLocatorSymbol) { - final yomiSection = getStringBetweenStrings(pageHtml, '
    ${yomiLocatorSymbol}:
    ', ''); - return parseAnchorsToArray(yomiSection ?? ''); -} - -List getKunyomi(String pageHtml) { - return getYomi(pageHtml, KUNYOMI_LOCATOR_SYMBOL); -} - -List getOnyomi(String pageHtml) { - return getYomi(pageHtml, ONYOMI_LOCATOR_SYMBOL); -} - -List getYomiExamples(String pageHtml, String yomiLocatorSymbol) { - final locatorString = '

    ${yomiLocatorSymbol} reading compounds

    '; - final exampleSection = getStringBetweenStrings(pageHtml, locatorString, ''); - if (exampleSection==null) { - return null; - } - - final regex = RegExp(r'
  • (.*?)<\/li>', dotAll: true); - final regexResults = getAllGlobalGroupMatches(exampleSection, regex).map((s) => s.trim()); - - final examples = regexResults.map((regexResult) { - final examplesLines = regexResult.split('\n').map((s) => s.trim()).toList(); - return YomiExample( - example: examplesLines[0], - reading: examplesLines[1].replaceAll('【', '').replaceAll('】', ''), - meaning: htmlUnescape.convert(examplesLines[2]), - ); - }); - - return examples.toList(); -} - -List getOnyomiExamples(String pageHtml) { - return getYomiExamples(pageHtml, ONYOMI_LOCATOR_SYMBOL); -} - -List getKunyomiExamples(String pageHtml) { - return getYomiExamples(pageHtml, KUNYOMI_LOCATOR_SYMBOL); -} - -Radical getRadical(String pageHtml) { - const radicalMeaningStartString = ''; - const radicalMeaningEndString = ''; - - var radicalMeaning = getStringBetweenStrings( - pageHtml, - radicalMeaningStartString, - radicalMeaningEndString, - ).trim(); - - if (radicalMeaning!=null) { - final radicalMeaningStartIndex = pageHtml.indexOf(radicalMeaningStartString); - - final radicalMeaningEndIndex = pageHtml.indexOf( - radicalMeaningEndString, - radicalMeaningStartIndex, - ); - - final radicalSymbolStartIndex = radicalMeaningEndIndex + radicalMeaningEndString.length; - const radicalSymbolEndString = ''; - final radicalSymbolEndIndex = pageHtml.indexOf(radicalSymbolEndString, radicalSymbolStartIndex); - - final radicalSymbolsString = getStringBetweenIndicies( - pageHtml, - radicalSymbolStartIndex, - radicalSymbolEndIndex, - ); - - if (radicalSymbolsString.length > 1) { - final radicalForms = radicalSymbolsString - .substring(1) - .replaceAll('(', '') - .replaceAll(')', '') - .trim() - .split(', '); - - return Radical( - symbol: radicalSymbolsString[0], - forms: radicalForms, - meaning: radicalMeaning - ); - } - - return Radical ( - symbol: radicalSymbolsString, - meaning: radicalMeaning - ); - } - - return null; -} - -List getParts(String pageHtml) { - const partsSectionStartString = '
    Parts:
    '; - const partsSectionEndString = ''; - - final partsSection = getStringBetweenStrings( - pageHtml, - partsSectionStartString, - partsSectionEndString, - ); - - var result = parseAnchorsToArray(partsSection); - result.sort(); - - return (result); -} - -String getSvgUri(String pageHtml) { - var svgRegex = RegExp('\/\/.*?.cloudfront.net\/.*?.svg'); - final regexResult = svgRegex.firstMatch(pageHtml).group(0).toString(); - return regexResult.isNotEmpty ? 'http:${regexResult}' : null; -} - -String getGifUri(String kanji) { - final unicodeString = kanji.codeUnitAt(0).toRadixString(16); - final fileName = '${unicodeString}.gif'; - final animationUri = 'https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/${fileName}'; - - return animationUri; -} - -int getNewspaperFrequencyRank(String pageHtml) { - final frequencySection = getStringBetweenStrings(pageHtml, '
    ', '
    '); - return frequencySection.isNotEmpty ? int.parse(getStringBetweenStrings(frequencySection, '', '')) : null; -} - -KanjiResult parseKanjiPageData(String pageHtml, String kanji) { - final result = KanjiResult(); - result.query = kanji; - result.found = containsKanjiGlyph(pageHtml, kanji); - if (result.found==false) { - return result; - } - - result.taughtIn = getStringBetweenStrings(pageHtml, 'taught in ', ''); - result.jlptLevel = getStringBetweenStrings(pageHtml, 'JLPT level ', ''); - result.newspaperFrequencyRank = getNewspaperFrequencyRank(pageHtml); - result.strokeCount = getIntBetweenStrings(pageHtml, '', ' strokes'); - result.meaning = htmlUnescape.convert(removeNewlines(getStringBetweenStrings(pageHtml, '
    ', '
    ')).trim()); - result.kunyomi = getKunyomi(pageHtml); - result.onyomi = getOnyomi(pageHtml); - result.onyomiExamples = getOnyomiExamples(pageHtml); - result.kunyomiExamples = getKunyomiExamples(pageHtml); - result.radical = getRadical(pageHtml); - result.parts = getParts(pageHtml); - result.strokeOrderDiagramUri = getUriForStrokeOrderDiagram(kanji); - result.strokeOrderSvgUri = getSvgUri(pageHtml); - result.strokeOrderGifUri = getGifUri(kanji); - result.uri = uriForKanjiSearch(kanji); - return result; -} - -/* KANJI SEARCH FUNCTIONS END */ - -/* EXAMPLE SEARCH FUNCTIONS START */ - -RegExp kanjiRegex = RegExp(r'[\u4e00-\u9faf\u3400-\u4dbf]'); - -String uriForExampleSearch(String phrase) { - return '${SCRAPE_BASE_URI}${Uri.encodeComponent(phrase)}%23sentences'; -} - -ExampleResultData getKanjiAndKana(div) { - final ul = div.find('ul').eq(0); - final contents = ul.contents(); - - var kanji = ''; - var kana = ''; - for (var i = 0; i < contents.length; i += 1) { - final content = contents.eq(i); - if (content[0].name == 'li') { - final li = content; - final furigana = li.find('.furigana').text(); - final unlifted = li.find('.unlinked').text(); - - if (furigana) { - kanji += unlifted; - kana += furigana; - - final kanaEnding = []; - for (var j = unlifted.length - 1; j > 0; j -= 1) { - if (!unlifted[j].match(kanjiRegex)) { - kanaEnding.add(unlifted[j]); - } else { - break; - } - } - - kana += kanaEnding.reversed.join(''); - } else { - kanji += unlifted; - kana += unlifted; - } - } else { - final text = content.text().trim(); - if (text) { - kanji += text; - kana += text; - } - } - } - - return ExampleResultData( - kanji: kanji, - kana: kana, - ); -} - -List getPieces(sentenceElement) { - final pieceElements = sentenceElement.find('li.clearfix'); - final pieces = []; - for (var pieceIndex = 0; pieceIndex < pieceElements.length; pieceIndex += 1) { - final pieceElement = pieceElements.eq(pieceIndex); - pieces.add(ExampleSentencePiece( - lifted: pieceElement.children('.furigana').text(), - unlifted: pieceElement.children('.unlinked').text(), - )); - } - - return pieces; -} - -ExampleResultData parseExampleDiv(div) { - final result = getKanjiAndKana(div); - result.english = div.find('.english').text(); - result.pieces = getPieces(div); - - return result; -} - -ExampleResults parseExamplePageData(String pageHtml, String phrase) { - final document = xml.parse(pageHtml); - final divs = document.descendants.where((node) => node.attributes[0].value == 'sentence_content').toList(); - - final results = divs.map((div) => parseExampleDiv(div)); - - return ExampleResults( - query: phrase, - found: results.isNotEmpty, - results: results, - uri: uriForExampleSearch(phrase), - phrase: phrase, - ); -} - -/* EXAMPLE SEARCH FUNCTIONS END */ - -/* PHRASE SCRAPE FUNCTIONS START */ - -List getTags(document) { - final tags = []; - final tagElements = document.descendants.where((node) => node.attributes[0].value == 'concept_light-tag').toList(); - - for (var i = 0; i < tagElements.length; i += 1) { - final tagText = tagElements.eq(i).text(); - tags.add(tagText); - } - - return tags; -} - -PhrasePageScrapeResult getMeaningsOtherFormsAndNotes(document) { - final returnValues = PhrasePageScrapeResult( otherForms: [], notes: [] ); - - //TODO: Fix - // const meaningsWrapper = $('#page_container > div > div > article > div > div.concept_light-meanings.medium-9.columns > div'); - final meaningsWrapper = document.descendants.where((node) => node.attributes[0].value == 'page_container').toList(); - - - - final meaningsChildren = meaningsWrapper.children(); - final meanings = []; - - var mostRecentWordTypes = []; - for (var meaningIndex = 0; meaningIndex < meaningsChildren.length; meaningIndex += 1) { - final child = meaningsChildren.eq(meaningIndex); - if (child.hasClass('meaning-tags')) { - mostRecentWordTypes = child.text().split(',').map((s) => s.trim().toLowerCase()); - } else if (mostRecentWordTypes[0] == 'other forms') { - returnValues.otherForms = child.text().split('、') - .map((s) => s.replaceAll('【', '').replaceAll('】', '').split(' ')) - .map((a) => (ExampleResultData( kanji: a[0], kana: a[1] ))); - } else if (mostRecentWordTypes[0] == 'notes') { - returnValues.notes = child.text().split('\n'); - } else { - final meaning = child.find('.meaning-meaning').text(); - final meaningAbstract = child.find('.meaning-abstract') - .find('a') - .remove() - .end() - .text(); - - final supplemental = child.find('.supplemental_info').text().split(',') - .map((s) => s.trim()) - .filter((s) => s); - - final seeAlsoTerms = []; - for (var i = supplemental.length - 1; i >= 0; i -= 1) { - final supplementalEntry = supplemental[i]; - if (supplementalEntry.startsWith('See also')) { - seeAlsoTerms.add(supplementalEntry.replaceAll('See also ', '')); - supplemental.splice(i, 1); - } - } - - final sentences = []; - final sentenceElements = child.find('.sentences').children('.sentence'); - - for (var sentenceIndex = 0; sentenceIndex < sentenceElements.length; sentenceIndex += 1) { - final sentenceElement = sentenceElements.eq(sentenceIndex); - - final english = sentenceElement.find('.english').text(); - final pieces = getPieces(sentenceElement); - - final japanese = sentenceElement - .find('.english').remove().end() - .find('.furigana') - .remove() - .end() - .text(); - - sentences.add(PhraseScrapeSentence(english: english, japanese: japanese, pieces: pieces)); - } - - meanings.add(PhraseScrapeMeaning( - seeAlsoTerms: seeAlsoTerms, - sentences: sentences, - definition: meaning, - supplemental: supplemental, - definitionAbstract: meaningAbstract, - tags: mostRecentWordTypes, - )); - } - } - - returnValues.meanings = meanings; - - return returnValues; -} - -String uriForPhraseScrape(searchTerm) { - return 'https://jisho.org/word/${Uri.encodeComponent(searchTerm)}'; -} - -PhrasePageScrapeResult parsePhrasePageData(pageHtml, query) { - final document = xml.parse(pageHtml); - final result = getMeaningsOtherFormsAndNotes(document); - - result.found = true; - result.query = query; - result.uri = uriForPhraseScrape(query); - result.tags = getTags(document); - // result.meanings = meanings; - // result.otherForms = forms; - // result.notes = notes; - - return result; -} class JishoApi { @@ -443,9 +18,27 @@ class JishoApi { /// @returns {Object} The response data from the official Jisho.org API. Its format is somewhat /// complex and is not documented, so put on your trial-and-error hat. /// @async - searchForPhrase(String phrase) { + Future searchForPhrase(String phrase) async { final uri = uriForPhraseSearch(phrase); - return http.get(uri).then((response) => jsonDecode(response.body).data); + return await http.get(uri).then((response) => JishoAPIResult.fromJson(jsonDecode(response.body))); + } + + /// Scrape Jisho.org for information about a kanji character. + /// @param {string} kanji The kanji to search for. + /// @returns {KanjiResult} Information about the searched kanji. + /// @async + Future searchForKanji(String kanji) async { + final uri = uriForKanjiSearch(kanji); + return http.get(uri).then((response) => parseKanjiPageData(response.body, kanji)); + } + + /// Scrape Jisho.org for examples. + /// @param {string} phrase The word or phrase to search for. + /// @returns {ExampleResults} + /// @async + Future searchForExamples(String phrase) async { + final uri = uriForExampleSearch(phrase); + return http.get(uri).then((response) => parseExamplePageData(response.body, phrase)); } /// Scrape the word page for a word/phrase. @@ -464,32 +57,14 @@ class JishoApi { final response = await http.get(uri); return parsePhrasePageData(response.body, phrase); } catch (err) { - if (err.response.status == 404) { - return PhrasePageScrapeResult( - query: phrase, - found: false, - ); - } + // if (response.statusCode == 404) { + // return PhrasePageScrapeResult( + // query: phrase, + // found: false, + // ); + // } throw err; } } - - /// Scrape Jisho.org for information about a kanji character. - /// @param {string} kanji The kanji to search for. - /// @returns {KanjiResult} Information about the searched kanji. - /// @async - Future searchForKanji(String kanji) { - final uri = uriForKanjiSearch(kanji); - return http.get(uri).then((response) => parseKanjiPageData(response.body, kanji)); - } - - /// Scrape Jisho.org for examples. - /// @param {string} phrase The word or phrase to search for. - /// @returns {ExampleResults} - /// @async - Future searchForExamples(String phrase) { - final uri = uriForExampleSearch(phrase); - return http.get(uri).then((response) => parseExamplePageData(response.body, phrase)); - } } \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index b0b25d2..26ff4c1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,6 +10,7 @@ dependencies: # path: ^1.6.0 xml: ^3.7.0 html_unescape: ^1.0.1+3 + html: ^0.14.0+3 dev_dependencies: pedantic: ^1.8.0 diff --git a/test/create_test_cases.dart b/test/create_test_cases.dart index e69de29..6931ede 100644 --- a/test/create_test_cases.dart +++ b/test/create_test_cases.dart @@ -0,0 +1,31 @@ +import 'dart:io'; +import 'package:path/path.dart' as path; +import 'dart:convert'; + +import 'package:unofficial_jisho_api/unofficial_jisho_api.dart'; + +final jisho = JishoApi(); +final encoder = JsonEncoder.withIndent(' '); +final currentdir = Directory.current.path; + +void writeCases(Function apiFunction, String folderName, List queries) async { + final dir = path.join(currentdir, 'test', folderName); + + for (var testCount = 0; testCount < queries.length; testCount++) { + final result = await apiFunction(queries[testCount]); + final content = encoder.convert(result); + final filePath = path.join(dir, '${testCount}.json'); + + await File(filePath).writeAsString(content); + } +} + +const kanjiQueries = ['車', '家', '楽', '極上', '贄', 'ネガティブ', 'wegmwrlgkrgmg', '水']; +const exampleQueries = ['車', '日本人', '彼*叩く', '皆', 'ネガティブ', 'grlgmregmneriireg']; +const phraseQueries = ['車', '日本人', '皆', 'ネガティブ', 'grlgmregmneriireg']; + +void main() async { + await writeCases(jisho.searchForKanji, 'kanji_test_cases', kanjiQueries); + await writeCases(jisho.searchForExamples, 'example_test_cases', exampleQueries); + await writeCases(jisho.scrapeForPhrase, 'phrase_scrape_test_cases', phraseQueries); +} diff --git a/test/example_test_cases/0.json b/test/example_test_cases/0.json index 3babdd2..fe79c0f 100644 --- a/test/example_test_cases/0.json +++ b/test/example_test_cases/0.json @@ -1,1071 +1,1068 @@ { "query": "車", - "expectedResult": { - "query": "車", - "found": true, - "results": [ - { - "english": "The colour and make of the president's car are?", - "kanji": "社長さんの車種と色は?", - "kana": "しゃちょうさんのしゃしゅといろは?", - "pieces": [ - { - "lifted": "しゃちょう", - "unlifted": "社長" - }, - { - "lifted": "", - "unlifted": "さん" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "しゃしゅ", - "unlifted": "車種" - }, - { - "lifted": "", - "unlifted": "と" - }, - { - "lifted": "いろ", - "unlifted": "色" - }, - { - "lifted": "", - "unlifted": "は" - } - ] - }, - { - "english": "The car wouldn't start.", - "kanji": "その車は動こうとしなかった。", - "kana": "そのくるまはうごこうとしなかった。", - "pieces": [ - { - "lifted": "", - "unlifted": "その" - }, - { - "lifted": "くるま", - "unlifted": "車" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "うご", - "unlifted": "動こう" - }, - { - "lifted": "", - "unlifted": "としなかった" - } - ] - }, - { - "english": "Now that I think of it, I've been asked to look at a haiku he'd written by the tipsy bloke sitting next to me on the train.", - "kanji": "そういえば、電車の中で隣に座ったほろ酔いのおっさんに、自分の俳句を見て欲しいと言われたことがある。", - "kana": "そういえば、でんしゃのなかでとなりにすわったほろよいのおっさんに、じぶんのはいくをみてほしいといわれたことがある。", - "pieces": [ - { - "lifted": "", - "unlifted": "そういえば" - }, - { - "lifted": "でんしゃ", - "unlifted": "電車" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "なか", - "unlifted": "中" - }, - { - "lifted": "", - "unlifted": "で" - }, - { - "lifted": "となり", - "unlifted": "隣" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "すわ", - "unlifted": "座った" - }, - { - "lifted": "ほろよ", - "unlifted": "ほろ酔い" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "", - "unlifted": "おっさん" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "じぶん", - "unlifted": "自分" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "はいく", - "unlifted": "俳句" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "み", - "unlifted": "見て" - }, - { - "lifted": "ほ", - "unlifted": "欲しい" - }, - { - "lifted": "", - "unlifted": "と" - }, - { - "lifted": "い", - "unlifted": "言われた" - }, - { - "lifted": "", - "unlifted": "ことがある" - } - ] - }, - { - "english": "If you frequently spit-up blood you should call an ambulance or have a nearby physician make a house call.", - "kanji": "ひんぱんに吐血する場合は、救急車を呼ぶか、近くの内科医に往診してもらう。", - "kana": "ひんぱんにとけつするばあいは、きゅうきゅうしゃをよぶか、ちかくのないかいにおうしんしてもらう。", - "pieces": [ - { - "lifted": "", - "unlifted": "ひんぱんに" - }, - { - "lifted": "とけつ", - "unlifted": "吐血" - }, - { - "lifted": "", - "unlifted": "する" - }, - { - "lifted": "ばあい", - "unlifted": "場合" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "きゅうきゅうしゃ", - "unlifted": "救急車" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "よ", - "unlifted": "呼ぶ" - }, - { - "lifted": "", - "unlifted": "か" - }, - { - "lifted": "ちか", - "unlifted": "近く" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "ないかい", - "unlifted": "内科医" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "おうしん", - "unlifted": "往診" - }, - { - "lifted": "", - "unlifted": "して" - }, - { - "lifted": "", - "unlifted": "もらう" - } - ] - }, - { - "english": "The front wheel plays an important role in two-wheeled vehicles moving without falling over.", - "kanji": "二輪車が倒れずに走行するのには前輪が大きな役割を演じています。", - "kana": "にりんしゃがたおれずにそうこうするのにはぜんりんがおおきなやくわりをえんじています。", - "pieces": [ - { - "lifted": "にりんしゃ", - "unlifted": "二輪車" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "たお", - "unlifted": "倒れず" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "そうこう", - "unlifted": "走行" - }, - { - "lifted": "", - "unlifted": "する" - }, - { - "lifted": "", - "unlifted": "のに" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "ぜんりん", - "unlifted": "前輪" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "おお", - "unlifted": "大きな" - }, - { - "lifted": "やくわりをえん", - "unlifted": "役割を演じています" - } - ] - }, - { - "english": "Did you catch the train?!", - "kanji": "列車に間に合ったのか?!", - "kana": "れっしゃにまにあったのか?!", - "pieces": [ - { - "lifted": "れっしゃ", - "unlifted": "列車" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "まにあ", - "unlifted": "間に合った" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "", - "unlifted": "か" - } - ] - }, - { - "english": "If you have any opinions concerning traffic calming devices (humps, curb extensions, etc.) please write them.", - "kanji": "車の速度を落とす装置(ハンプや狭さく)について、意見があったら書いてください。", - "kana": "くるまのそくどをおとすそうち(ハンプやきょうさく)について、いけんがあったらかいてください。", - "pieces": [ - { - "lifted": "くるま", - "unlifted": "車" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "そくど", - "unlifted": "速度" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "お", - "unlifted": "落とす" - }, - { - "lifted": "そうち", - "unlifted": "装置" - }, - { - "lifted": "", - "unlifted": "ハンプ" - }, - { - "lifted": "", - "unlifted": "や" - }, - { - "lifted": "きょう", - "unlifted": "狭さく" - }, - { - "lifted": "", - "unlifted": "について" - }, - { - "lifted": "いけん", - "unlifted": "意見" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "", - "unlifted": "あったら" - }, - { - "lifted": "か", - "unlifted": "書いて" - }, - { - "lifted": "", - "unlifted": "ください" - } - ] - }, - { - "english": "The Mexican government announced the banning of all imports of second-hand cars, except for 1998 models.", - "kanji": "メキシコ政府は1998年型の中古車以外の中古車の輸入を禁止すると発表した。", - "kana": "メキシコせいふは1998ねんがたのちゅうこしゃいがいのちゅうこしゃのゆにゅうをきんしするとはっぴょうした。", - "pieces": [ - { - "lifted": "", - "unlifted": "メキシコ" - }, - { - "lifted": "せいふ", - "unlifted": "政府" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "ねんがた", - "unlifted": "年型" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "ちゅうこしゃ", - "unlifted": "中古車" - }, - { - "lifted": "いがい", - "unlifted": "以外" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "ちゅうこしゃ", - "unlifted": "中古車" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "ゆにゅう", - "unlifted": "輸入" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "きんし", - "unlifted": "禁止" - }, - { - "lifted": "", - "unlifted": "する" - }, - { - "lifted": "", - "unlifted": "と" - }, - { - "lifted": "はっぴょう", - "unlifted": "発表" - }, - { - "lifted": "", - "unlifted": "した" - } - ] - }, - { - "english": "The car dove into the field and, after bumping along for a time, came to a halt.", - "kanji": "車は草地に飛び込み、しばらくガクンガクンと走って止まったのです。", - "kana": "くるまはくさちにとびこみ、しばらくガクンガクンとはしってとまったのです。", - "pieces": [ - { - "lifted": "くるま", - "unlifted": "車" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "くさち", - "unlifted": "草地" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "とびこ", - "unlifted": "飛び込み" - }, - { - "lifted": "", - "unlifted": "しばらく" - }, - { - "lifted": "", - "unlifted": "ガクンガクンと" - }, - { - "lifted": "はし", - "unlifted": "走って" - }, - { - "lifted": "と", - "unlifted": "止まった" - }, - { - "lifted": "", - "unlifted": "のです" - } - ] - }, - { - "english": "I'm living on welfare, without a car or anything.", - "kanji": "車も何もなく、生活保護で生きてます。", - "kana": "くるまもなにもなく、せいかつほごでいきてます。", - "pieces": [ - { - "lifted": "くるま", - "unlifted": "車" - }, - { - "lifted": "", - "unlifted": "も" - }, - { - "lifted": "なに", - "unlifted": "何も" - }, - { - "lifted": "", - "unlifted": "なく" - }, - { - "lifted": "せいかつほご", - "unlifted": "生活保護" - }, - { - "lifted": "", - "unlifted": "で" - }, - { - "lifted": "い", - "unlifted": "生きてます" - } - ] - }, - { - "english": "Cars that, when new, cost 3,000,000 yen are apparently now worth 300,000, so I think I'll use mine a little longer.", - "kanji": "新車時300万円した車も今では30万円位だそうですから、もう少し乗ろうと思います。", - "kana": "しんしゃどき300まんえんしたくるまもいまでは30まんえん位だそうですから、もうすこしのろうとおもいます。", - "pieces": [ - { - "lifted": "しんしゃ", - "unlifted": "新車" - }, - { - "lifted": "どき", - "unlifted": "時" - }, - { - "lifted": "まん", - "unlifted": "万" - }, - { - "lifted": "えん", - "unlifted": "円" - }, - { - "lifted": "", - "unlifted": "した" - }, - { - "lifted": "くるま", - "unlifted": "車" - }, - { - "lifted": "", - "unlifted": "も" - }, - { - "lifted": "いま", - "unlifted": "今では" - }, - { - "lifted": "まん", - "unlifted": "万" - }, - { - "lifted": "えん", - "unlifted": "円" - }, - { - "lifted": "", - "unlifted": "位" - }, - { - "lifted": "", - "unlifted": "だ" - }, - { - "lifted": "", - "unlifted": "そうです" - }, - { - "lifted": "", - "unlifted": "から" - }, - { - "lifted": "もうすこ", - "unlifted": "もう少し" - }, - { - "lifted": "の", - "unlifted": "乗ろう" - }, - { - "lifted": "", - "unlifted": "と" - }, - { - "lifted": "おも", - "unlifted": "思います" - } - ] - }, - { - "english": "At that time the snow plow was certainly our hero.", - "kanji": "このとき除雪車は確かに私たちの英雄でした。", - "kana": "このときじょせつしゃはたしかにわたしたちのえいゆうでした。", - "pieces": [ - { - "lifted": "", - "unlifted": "この" - }, - { - "lifted": "", - "unlifted": "とき" - }, - { - "lifted": "じょせつしゃ", - "unlifted": "除雪車" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "たし", - "unlifted": "確かに" - }, - { - "lifted": "わたし", - "unlifted": "私たち" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "えいゆう", - "unlifted": "英雄" - }, - { - "lifted": "", - "unlifted": "でした" - } - ] - }, - { - "english": "He didn't intend to let her drive but she pestered him so much that he finally gave in.", - "kanji": "彼は彼女に車を運転させるつもりはなかったのだが、彼女があまりにせがむものだから、彼の方がとうとう折れた。", - "kana": "かれはかのじょにくるまをうんてんさせるつもりはなかったのだが、かのじょがあまりにせがむものだから、かれのほうがとうとうおれた。", - "pieces": [ - { - "lifted": "かれ", - "unlifted": "彼" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "かのじょ", - "unlifted": "彼女" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "くるま", - "unlifted": "車" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "うんてん", - "unlifted": "運転させる" - }, - { - "lifted": "", - "unlifted": "つもり" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "", - "unlifted": "なかった" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "", - "unlifted": "だ" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "かのじょ", - "unlifted": "彼女" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "", - "unlifted": "あまり" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "", - "unlifted": "せがむ" - }, - { - "lifted": "", - "unlifted": "ものだから" - }, - { - "lifted": "かれ", - "unlifted": "彼の" - }, - { - "lifted": "ほう", - "unlifted": "方" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "", - "unlifted": "とうとう" - }, - { - "lifted": "お", - "unlifted": "折れた" - } - ] - }, - { - "english": "We are now going to move to the crematorium so if Mr. Ogawa and you would enter the car ...", - "kanji": "これから火葬場へ移動しますので、小川様と君は車へ。", - "kana": "これからかそうばへいどうしますので、小川さまときみはくるまへ。", - "pieces": [ - { - "lifted": "", - "unlifted": "これから" - }, - { - "lifted": "かそうば", - "unlifted": "火葬場" - }, - { - "lifted": "", - "unlifted": "へ" - }, - { - "lifted": "いどう", - "unlifted": "移動" - }, - { - "lifted": "", - "unlifted": "します" - }, - { - "lifted": "", - "unlifted": "ので" - }, - { - "lifted": "さま", - "unlifted": "様" - }, - { - "lifted": "", - "unlifted": "と" - }, - { - "lifted": "きみ", - "unlifted": "君" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "くるま", - "unlifted": "車" - }, - { - "lifted": "", - "unlifted": "へ" - } - ] - }, - { - "english": "Japanese cars are right hand drive.", - "kanji": "日本車は右ハンドルです。", - "kana": "にほんしゃはみぎハンドルです。", - "pieces": [ - { - "lifted": "にほんしゃ", - "unlifted": "日本車" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "みぎ", - "unlifted": "右ハンドル" - }, - { - "lifted": "", - "unlifted": "です" - } - ] - }, - { - "english": "The coalition force fired at her car at the checkpoint in Bagdad.", - "kanji": "同盟軍はバグダッドの検問所で彼女の車を襲撃した。", - "kana": "どうめいぐんはバグダッドのけんもんじょでかのじょのくるまをしゅうげきした。", - "pieces": [ - { - "lifted": "どうめいぐん", - "unlifted": "同盟軍" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "", - "unlifted": "バグダッド" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "けんもんじょ", - "unlifted": "検問所" - }, - { - "lifted": "", - "unlifted": "で" - }, - { - "lifted": "かのじょ", - "unlifted": "彼女の" - }, - { - "lifted": "くるま", - "unlifted": "車" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "しゅうげき", - "unlifted": "襲撃" - }, - { - "lifted": "", - "unlifted": "した" - } - ] - }, - { - "english": "When it sets off the bell rings, \"ding-ding\". Thus 'ding-ding-train'.", - "kanji": "動き出すとき、ベルが「ちんちん」と鳴る。だから、ちんちん電車。", - "kana": "うごきだすとき、ベルが「ちんちん」となる。だから、ちんちんでんしゃ。", - "pieces": [ - { - "lifted": "うごきだ", - "unlifted": "動き出す" - }, - { - "lifted": "", - "unlifted": "とき" - }, - { - "lifted": "", - "unlifted": "ベル" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "", - "unlifted": "ちんちん" - }, - { - "lifted": "", - "unlifted": "と" - }, - { - "lifted": "な", - "unlifted": "鳴る" - }, - { - "lifted": "", - "unlifted": "だから" - }, - { - "lifted": "", - "unlifted": "ちんちん" - }, - { - "lifted": "でんしゃ", - "unlifted": "電車" - } - ] - }, - { - "english": "The car was stuck in the mud.", - "kanji": "車がぬかるみに填まり込んだ。", - "kana": "くるまがぬかるみにはまりこんだ。", - "pieces": [ - { - "lifted": "くるま", - "unlifted": "車" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "", - "unlifted": "ぬかるみ" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "はまりこ", - "unlifted": "填まり込んだ" - } - ] - }, - { - "english": "We reached our destination just as I thought the car was going to give up the ghost.", - "kanji": "車がいかれるかと思ったころ終点に着きました。", - "kana": "くるまがいかれるかとおもったころしゅうてんにつきました。", - "pieces": [ - { - "lifted": "くるま", - "unlifted": "車" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "", - "unlifted": "いかれる" - }, - { - "lifted": "", - "unlifted": "か" - }, - { - "lifted": "", - "unlifted": "と" - }, - { - "lifted": "おも", - "unlifted": "思った" - }, - { - "lifted": "", - "unlifted": "ころ" - }, - { - "lifted": "しゅうてん", - "unlifted": "終点" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "つ", - "unlifted": "着きました" - } - ] - }, - { - "english": "Car? Ah, if you mean that limousine, - I chartered it.", - "kanji": "車?ああ・・・あのリムジンでしたら、私がチャーターした物ですわ。", - "kana": "くるま?ああ・・・あのリムジンでしたら、わたしがチャーターしたものですわ。", - "pieces": [ - { - "lifted": "くるま", - "unlifted": "車" - }, - { - "lifted": "", - "unlifted": "ああ" - }, - { - "lifted": "", - "unlifted": "あの" - }, - { - "lifted": "", - "unlifted": "リムジン" - }, - { - "lifted": "", - "unlifted": "でしたら" - }, - { - "lifted": "わたし", - "unlifted": "私" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "", - "unlifted": "チャーター" - }, - { - "lifted": "", - "unlifted": "した" - }, - { - "lifted": "もの", - "unlifted": "物" - }, - { - "lifted": "", - "unlifted": "です" - }, - { - "lifted": "", - "unlifted": "わ" - } - ] - } - ], - "uri": "http://jisho.org/search/%E8%BB%8A%23sentences", - "phrase": "車" - } + "found": true, + "results": [ + { + "english": "The colour and make of the president's car are?", + "kanji": "社長さんの車種と色は?", + "kana": "しゃちょうさんのしゃしゅといろは?", + "pieces": [ + { + "lifted": "しゃちょう", + "unlifted": "社長" + }, + { + "lifted": null, + "unlifted": "さん" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "しゃしゅ", + "unlifted": "車種" + }, + { + "lifted": null, + "unlifted": "と" + }, + { + "lifted": "いろ", + "unlifted": "色" + }, + { + "lifted": null, + "unlifted": "は" + } + ] + }, + { + "english": "The car wouldn't start.", + "kanji": "その車は動こうとしなかった。", + "kana": "そのくるまはうごこうとしなかった。", + "pieces": [ + { + "lifted": null, + "unlifted": "その" + }, + { + "lifted": "くるま", + "unlifted": "車" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "うご", + "unlifted": "動こう" + }, + { + "lifted": null, + "unlifted": "としなかった" + } + ] + }, + { + "english": "Now that I think of it, I've been asked to look at a haiku he'd written by the tipsy bloke sitting next to me on the train.", + "kanji": "そういえば、電車の中で隣に座ったほろ酔いのおっさんに、自分の俳句を見て欲しいと言われたことがある。", + "kana": "そういえば、でんしゃのなかでとなりにすわったほろよいのおっさんに、じぶんのはいくをみてほしいといわれたことがある。", + "pieces": [ + { + "lifted": null, + "unlifted": "そういえば" + }, + { + "lifted": "でんしゃ", + "unlifted": "電車" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "なか", + "unlifted": "中" + }, + { + "lifted": null, + "unlifted": "で" + }, + { + "lifted": "となり", + "unlifted": "隣" + }, + { + "lifted": null, + "unlifted": "に" + }, + { + "lifted": "すわ", + "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": "ほ", + "unlifted": "欲しい" + }, + { + "lifted": null, + "unlifted": "と" + }, + { + "lifted": "い", + "unlifted": "言われた" + }, + { + "lifted": null, + "unlifted": "ことがある" + } + ] + }, + { + "english": "If you frequently spit-up blood you should call an ambulance or have a nearby physician make a house call.", + "kanji": "ひんぱんに吐血する場合は、救急車を呼ぶか、近くの内科医に往診してもらう。", + "kana": "ひんぱんにとけつするばあいは、きゅうきゅうしゃをよぶか、ちかくのないかいにおうしんしてもらう。", + "pieces": [ + { + "lifted": null, + "unlifted": "ひんぱんに" + }, + { + "lifted": "とけつ", + "unlifted": "吐血" + }, + { + "lifted": null, + "unlifted": "する" + }, + { + "lifted": "ばあい", + "unlifted": "場合" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "きゅうきゅうしゃ", + "unlifted": "救急車" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": "よ", + "unlifted": "呼ぶ" + }, + { + "lifted": null, + "unlifted": "か" + }, + { + "lifted": "ちか", + "unlifted": "近く" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "ないかい", + "unlifted": "内科医" + }, + { + "lifted": null, + "unlifted": "に" + }, + { + "lifted": "おうしん", + "unlifted": "往診" + }, + { + "lifted": null, + "unlifted": "して" + }, + { + "lifted": null, + "unlifted": "もらう" + } + ] + }, + { + "english": "The front wheel plays an important role in two-wheeled vehicles moving without falling over.", + "kanji": "二輪車が倒れずに走行するのには前輪が大きな役割を演じています。", + "kana": "にりんしゃがたおれずにそうこうするのにはぜんりんがおおきなやくわりをえんじています。", + "pieces": [ + { + "lifted": "にりんしゃ", + "unlifted": "二輪車" + }, + { + "lifted": null, + "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": "やくわりをえん", + "unlifted": "役割を演じています" + } + ] + }, + { + "english": "Did you catch the train?!", + "kanji": "列車に間に合ったのか?!", + "kana": "れっしゃにまにあったのか?!", + "pieces": [ + { + "lifted": "れっしゃ", + "unlifted": "列車" + }, + { + "lifted": null, + "unlifted": "に" + }, + { + "lifted": "まにあ", + "unlifted": "間に合った" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": null, + "unlifted": "か" + } + ] + }, + { + "english": "If you have any opinions concerning traffic calming devices (humps, curb extensions, etc.) please write them.", + "kanji": "車の速度を落とす装置(ハンプや狭さく)について、意見があったら書いてください。", + "kana": "くるまのそくどをおとすそうち(ハンプやきょうさく)について、いけんがあったらかいてください。", + "pieces": [ + { + "lifted": "くるま", + "unlifted": "車" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "そくど", + "unlifted": "速度" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": "お", + "unlifted": "落とす" + }, + { + "lifted": "そうち", + "unlifted": "装置" + }, + { + "lifted": null, + "unlifted": "ハンプ" + }, + { + "lifted": null, + "unlifted": "や" + }, + { + "lifted": "きょう", + "unlifted": "狭さく" + }, + { + "lifted": null, + "unlifted": "について" + }, + { + "lifted": "いけん", + "unlifted": "意見" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": null, + "unlifted": "あったら" + }, + { + "lifted": "か", + "unlifted": "書いて" + }, + { + "lifted": null, + "unlifted": "ください" + } + ] + }, + { + "english": "The Mexican government announced the banning of all imports of second-hand cars, except for 1998 models.", + "kanji": "メキシコ政府は1998年型の中古車以外の中古車の輸入を禁止すると発表した。", + "kana": "メキシコせいふは1998ねんがたのちゅうこしゃいがいのちゅうこしゃのゆにゅうをきんしするとはっぴょうした。", + "pieces": [ + { + "lifted": null, + "unlifted": "メキシコ" + }, + { + "lifted": "せいふ", + "unlifted": "政府" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "ねんがた", + "unlifted": "年型" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "ちゅうこしゃ", + "unlifted": "中古車" + }, + { + "lifted": "いがい", + "unlifted": "以外" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "ちゅうこしゃ", + "unlifted": "中古車" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "ゆにゅう", + "unlifted": "輸入" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": "きんし", + "unlifted": "禁止" + }, + { + "lifted": null, + "unlifted": "する" + }, + { + "lifted": null, + "unlifted": "と" + }, + { + "lifted": "はっぴょう", + "unlifted": "発表" + }, + { + "lifted": null, + "unlifted": "した" + } + ] + }, + { + "english": "The car dove into the field and, after bumping along for a time, came to a halt.", + "kanji": "車は草地に飛び込み、しばらくガクンガクンと走って止まったのです。", + "kana": "くるまはくさちにとびこみ、しばらくガクンガクンとはしってとまったのです。", + "pieces": [ + { + "lifted": "くるま", + "unlifted": "車" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "くさち", + "unlifted": "草地" + }, + { + "lifted": null, + "unlifted": "に" + }, + { + "lifted": "とびこ", + "unlifted": "飛び込み" + }, + { + "lifted": null, + "unlifted": "しばらく" + }, + { + "lifted": null, + "unlifted": "ガクンガクンと" + }, + { + "lifted": "はし", + "unlifted": "走って" + }, + { + "lifted": "と", + "unlifted": "止まった" + }, + { + "lifted": null, + "unlifted": "のです" + } + ] + }, + { + "english": "I'm living on welfare, without a car or anything.", + "kanji": "車も何もなく、生活保護で生きてます。", + "kana": "くるまもなにもなく、せいかつほごでいきてます。", + "pieces": [ + { + "lifted": "くるま", + "unlifted": "車" + }, + { + "lifted": null, + "unlifted": "も" + }, + { + "lifted": "なに", + "unlifted": "何も" + }, + { + "lifted": null, + "unlifted": "なく" + }, + { + "lifted": "せいかつほご", + "unlifted": "生活保護" + }, + { + "lifted": null, + "unlifted": "で" + }, + { + "lifted": "い", + "unlifted": "生きてます" + } + ] + }, + { + "english": "Cars that, when new, cost 3,000,000 yen are apparently now worth 300,000, so I think I'll use mine a little longer.", + "kanji": "新車時300万円した車も今では30万円位だそうですから、もう少し乗ろうと思います。", + "kana": "しんしゃどき300まんえんしたくるまもいまでは30まんえん位だそうですから、もうすこしのろうとおもいます。", + "pieces": [ + { + "lifted": "しんしゃ", + "unlifted": "新車" + }, + { + "lifted": "どき", + "unlifted": "時" + }, + { + "lifted": "まん", + "unlifted": "万" + }, + { + "lifted": "えん", + "unlifted": "円" + }, + { + "lifted": null, + "unlifted": "した" + }, + { + "lifted": "くるま", + "unlifted": "車" + }, + { + "lifted": null, + "unlifted": "も" + }, + { + "lifted": "いま", + "unlifted": "今では" + }, + { + "lifted": "まん", + "unlifted": "万" + }, + { + "lifted": "えん", + "unlifted": "円" + }, + { + "lifted": null, + "unlifted": "位" + }, + { + "lifted": null, + "unlifted": "だ" + }, + { + "lifted": null, + "unlifted": "そうです" + }, + { + "lifted": null, + "unlifted": "から" + }, + { + "lifted": "もうすこ", + "unlifted": "もう少し" + }, + { + "lifted": "の", + "unlifted": "乗ろう" + }, + { + "lifted": null, + "unlifted": "と" + }, + { + "lifted": "おも", + "unlifted": "思います" + } + ] + }, + { + "english": "At that time the snow plow was certainly our hero.", + "kanji": "このとき除雪車は確かに私たちの英雄でした。", + "kana": "このときじょせつしゃはたしかにわたしたちのえいゆうでした。", + "pieces": [ + { + "lifted": null, + "unlifted": "この" + }, + { + "lifted": null, + "unlifted": "とき" + }, + { + "lifted": "じょせつしゃ", + "unlifted": "除雪車" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "たし", + "unlifted": "確かに" + }, + { + "lifted": "わたし", + "unlifted": "私たち" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "えいゆう", + "unlifted": "英雄" + }, + { + "lifted": null, + "unlifted": "でした" + } + ] + }, + { + "english": "He didn't intend to let her drive but she pestered him so much that he finally gave in.", + "kanji": "彼は彼女に車を運転させるつもりはなかったのだが、彼女があまりにせがむものだから、彼の方がとうとう折れた。", + "kana": "かれはかのじょにくるまをうんてんさせるつもりはなかったのだが、かのじょがあまりにせがむものだから、かれのほうがとうとうおれた。", + "pieces": [ + { + "lifted": "かれ", + "unlifted": "彼" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "かのじょ", + "unlifted": "彼女" + }, + { + "lifted": null, + "unlifted": "に" + }, + { + "lifted": "くるま", + "unlifted": "車" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": "うんてん", + "unlifted": "運転させる" + }, + { + "lifted": null, + "unlifted": "つもり" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": null, + "unlifted": "なかった" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": null, + "unlifted": "だ" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": "かのじょ", + "unlifted": "彼女" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": null, + "unlifted": "あまり" + }, + { + "lifted": null, + "unlifted": "に" + }, + { + "lifted": null, + "unlifted": "せがむ" + }, + { + "lifted": null, + "unlifted": "ものだから" + }, + { + "lifted": "かれ", + "unlifted": "彼の" + }, + { + "lifted": "ほう", + "unlifted": "方" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": null, + "unlifted": "とうとう" + }, + { + "lifted": "お", + "unlifted": "折れた" + } + ] + }, + { + "english": "We are now going to move to the crematorium so if Mr. Ogawa and you would enter the car ...", + "kanji": "これから火葬場へ移動しますので、小川様と君は車へ。", + "kana": "これからかそうばへいどうしますので、小川さまときみはくるまへ。", + "pieces": [ + { + "lifted": null, + "unlifted": "これから" + }, + { + "lifted": "かそうば", + "unlifted": "火葬場" + }, + { + "lifted": null, + "unlifted": "へ" + }, + { + "lifted": "いどう", + "unlifted": "移動" + }, + { + "lifted": null, + "unlifted": "します" + }, + { + "lifted": null, + "unlifted": "ので" + }, + { + "lifted": "さま", + "unlifted": "様" + }, + { + "lifted": null, + "unlifted": "と" + }, + { + "lifted": "きみ", + "unlifted": "君" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "くるま", + "unlifted": "車" + }, + { + "lifted": null, + "unlifted": "へ" + } + ] + }, + { + "english": "Japanese cars are right hand drive.", + "kanji": "日本車は右ハンドルです。", + "kana": "にほんしゃはみぎハンドルです。", + "pieces": [ + { + "lifted": "にほんしゃ", + "unlifted": "日本車" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "みぎ", + "unlifted": "右ハンドル" + }, + { + "lifted": null, + "unlifted": "です" + } + ] + }, + { + "english": "The coalition force fired at her car at the checkpoint in Bagdad.", + "kanji": "同盟軍はバグダッドの検問所で彼女の車を襲撃した。", + "kana": "どうめいぐんはバグダッドのけんもんじょでかのじょのくるまをしゅうげきした。", + "pieces": [ + { + "lifted": "どうめいぐん", + "unlifted": "同盟軍" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": null, + "unlifted": "バグダッド" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "けんもんじょ", + "unlifted": "検問所" + }, + { + "lifted": null, + "unlifted": "で" + }, + { + "lifted": "かのじょ", + "unlifted": "彼女の" + }, + { + "lifted": "くるま", + "unlifted": "車" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": "しゅうげき", + "unlifted": "襲撃" + }, + { + "lifted": null, + "unlifted": "した" + } + ] + }, + { + "english": "When it sets off the bell rings, \"ding-ding\". Thus 'ding-ding-train'.", + "kanji": "動き出すとき、ベルが「ちんちん」と鳴る。だから、ちんちん電車。", + "kana": "うごきだすとき、ベルが「ちんちん」となる。だから、ちんちんでんしゃ。", + "pieces": [ + { + "lifted": "うごきだ", + "unlifted": "動き出す" + }, + { + "lifted": null, + "unlifted": "とき" + }, + { + "lifted": null, + "unlifted": "ベル" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": null, + "unlifted": "ちんちん" + }, + { + "lifted": null, + "unlifted": "と" + }, + { + "lifted": "な", + "unlifted": "鳴る" + }, + { + "lifted": null, + "unlifted": "だから" + }, + { + "lifted": null, + "unlifted": "ちんちん" + }, + { + "lifted": "でんしゃ", + "unlifted": "電車" + } + ] + }, + { + "english": "The car was stuck in the mud.", + "kanji": "車がぬかるみに填まり込んだ。", + "kana": "くるまがぬかるみにはまりこんだ。", + "pieces": [ + { + "lifted": "くるま", + "unlifted": "車" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": null, + "unlifted": "ぬかるみ" + }, + { + "lifted": null, + "unlifted": "に" + }, + { + "lifted": "はまりこ", + "unlifted": "填まり込んだ" + } + ] + }, + { + "english": "We reached our destination just as I thought the car was going to give up the ghost.", + "kanji": "車がいかれるかと思ったころ終点に着きました。", + "kana": "くるまがいかれるかとおもったころしゅうてんにつきました。", + "pieces": [ + { + "lifted": "くるま", + "unlifted": "車" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": null, + "unlifted": "いかれる" + }, + { + "lifted": null, + "unlifted": "か" + }, + { + "lifted": null, + "unlifted": "と" + }, + { + "lifted": "おも", + "unlifted": "思った" + }, + { + "lifted": null, + "unlifted": "ころ" + }, + { + "lifted": "しゅうてん", + "unlifted": "終点" + }, + { + "lifted": null, + "unlifted": "に" + }, + { + "lifted": "つ", + "unlifted": "着きました" + } + ] + }, + { + "english": "Car? Ah, if you mean that limousine, - I chartered it.", + "kanji": "車?ああ・・・あのリムジンでしたら、私がチャーターした物ですわ。", + "kana": "くるま?ああ・・・あのリムジンでしたら、わたしがチャーターしたものですわ。", + "pieces": [ + { + "lifted": "くるま", + "unlifted": "車" + }, + { + "lifted": null, + "unlifted": "ああ" + }, + { + "lifted": null, + "unlifted": "あの" + }, + { + "lifted": null, + "unlifted": "リムジン" + }, + { + "lifted": null, + "unlifted": "でしたら" + }, + { + "lifted": "わたし", + "unlifted": "私" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": null, + "unlifted": "チャーター" + }, + { + "lifted": null, + "unlifted": "した" + }, + { + "lifted": "もの", + "unlifted": "物" + }, + { + "lifted": null, + "unlifted": "です" + }, + { + "lifted": null, + "unlifted": "わ" + } + ] + } + ], + "uri": "https://jisho.org/search/%E8%BB%8A%23sentences", + "phrase": "車" } \ No newline at end of file diff --git a/test/example_test_cases/1.json b/test/example_test_cases/1.json index 2fc5c7f..6cef354 100644 --- a/test/example_test_cases/1.json +++ b/test/example_test_cases/1.json @@ -1,891 +1,888 @@ { "query": "日本人", - "expectedResult": { - "query": "日本人", - "found": true, - "results": [ - { - "english": "A Japanese person would never do such a thing.", - "kanji": "日本人ならそんなことはけっしてしないでしょう。", - "kana": "にほんじんならそんなことはけっしてしないでしょう。", - "pieces": [ - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "なら" - }, - { - "lifted": "", - "unlifted": "そんな" - }, - { - "lifted": "", - "unlifted": "こと" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "", - "unlifted": "けっして" - }, - { - "lifted": "", - "unlifted": "しない" - }, - { - "lifted": "", - "unlifted": "でしょう" - } - ] - }, - { - "english": "When did the Japanese start eating polished rice?", - "kanji": "いつから日本人は精白米を食べるようになったのですか?", - "kana": "いつからにほんじんはせいはくまいをたべるようになったのですか?", - "pieces": [ - { - "lifted": "", - "unlifted": "いつから" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "せいはくまい", - "unlifted": "精白米" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "た", - "unlifted": "食べる" - }, - { - "lifted": "", - "unlifted": "ようになった" - }, - { - "lifted": "", - "unlifted": "のです" - }, - { - "lifted": "", - "unlifted": "か" - } - ] - }, - { - "english": "I think there are probably few Japanese who know this side of the Emperor Meiji, the side that left a song like this.", - "kanji": "こんな歌を残している明治天皇の一面を知っている日本人は少ないのではないだろうか。", - "kana": "こんなうたをのこしているめいじてんのうのいちめんをしっているにほんじんはすくないのではないだろうか。", - "pieces": [ - { - "lifted": "", - "unlifted": "こんな" - }, - { - "lifted": "うた", - "unlifted": "歌" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "のこ", - "unlifted": "残している" - }, - { - "lifted": "めいじてんのう", - "unlifted": "明治天皇" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "いちめん", - "unlifted": "一面" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "し", - "unlifted": "知っている" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "すく", - "unlifted": "少ない" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "", - "unlifted": "ではない" - }, - { - "lifted": "", - "unlifted": "だろうか" - } - ] - }, - { - "english": "I'm Japanese, but I don't live in Japan.", - "kanji": "私は日本人ですが、日本に住んでいません。", - "kana": "わたしはにほんじんですが、にほんにすんでいません。", - "pieces": [ - { - "lifted": "わたし", - "unlifted": "私" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "です" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "にほん", - "unlifted": "日本" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "す", - "unlifted": "住んでいません" - } - ] - }, - { - "english": "They don't use 'celeb' to mean 'rich man' over there. By which I determine that you are Japanese.", - "kanji": "向こうではセレブという言葉を「金持ち」の意味では使わない。という事で日本人と判明しました。", - "kana": "むこうではセレブということばを「かねもち」のいみではつかわない。ということでにほんじんとはんめいしました。", - "pieces": [ - { - "lifted": "む", - "unlifted": "向こう" - }, - { - "lifted": "", - "unlifted": "で" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "", - "unlifted": "セレブ" - }, - { - "lifted": "", - "unlifted": "という" - }, - { - "lifted": "ことば", - "unlifted": "言葉" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "かねも", - "unlifted": "金持ち" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "いみ", - "unlifted": "意味" - }, - { - "lifted": "", - "unlifted": "で" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "つか", - "unlifted": "使わない" - }, - { - "lifted": "", - "unlifted": "と" - }, - { - "lifted": "", - "unlifted": "いう" - }, - { - "lifted": "こと", - "unlifted": "事" - }, - { - "lifted": "", - "unlifted": "で" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "と" - }, - { - "lifted": "はんめい", - "unlifted": "判明" - }, - { - "lifted": "", - "unlifted": "しました" - } - ] - }, - { - "english": "As you can also tell from these beautiful, far from Japanese, looks, Yuna is not pure-blood Japanese. She's a quarter-blood with a westerner as grandmother.", - "kanji": "日本人離れしたこの美しい相貌からもわかるように、優奈は実は生粋の日本人じゃない。西洋人をおばあちゃんに持つ、クォーターだったりする。", - "kana": "にほんじんはなれしたこのうつくしいそうぼうからもわかるように、優奈はじつはきっすいのにほんじんじゃない。せいようじんをおばあちゃんにもつ、クォーターだったりする。", - "pieces": [ - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "はな", - "unlifted": "離れ" - }, - { - "lifted": "", - "unlifted": "した" - }, - { - "lifted": "", - "unlifted": "この" - }, - { - "lifted": "うつく", - "unlifted": "美しい" - }, - { - "lifted": "そうぼう", - "unlifted": "相貌" - }, - { - "lifted": "", - "unlifted": "から" - }, - { - "lifted": "", - "unlifted": "も" - }, - { - "lifted": "", - "unlifted": "わかる" - }, - { - "lifted": "", - "unlifted": "ように" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "じつ", - "unlifted": "実は" - }, - { - "lifted": "きっすい", - "unlifted": "生粋の" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "じゃない" - }, - { - "lifted": "せいようじん", - "unlifted": "西洋人" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "", - "unlifted": "おばあちゃん" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "も", - "unlifted": "持つ" - }, - { - "lifted": "", - "unlifted": "クォーター" - }, - { - "lifted": "", - "unlifted": "だったり" - }, - { - "lifted": "", - "unlifted": "する" - } - ] - }, - { - "english": "Today's topic is \"the problem of Japanese people abducted by North Korea\".", - "kanji": "今日のトピックは「北朝鮮による日本人拉致問題」です。", - "kana": "きょうのトピックは「きたちょうせんによるにほんじんらちもんだい」です。", - "pieces": [ - { - "lifted": "きょう", - "unlifted": "今日" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "", - "unlifted": "トピック" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "きたちょうせん", - "unlifted": "北朝鮮" - }, - { - "lifted": "", - "unlifted": "による" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "らち", - "unlifted": "拉致" - }, - { - "lifted": "もんだい", - "unlifted": "問題" - }, - { - "lifted": "", - "unlifted": "です" - } - ] - }, - { - "english": "Foreign rice is hard and tasteless, and doesn't appeal to the Japanese palate.", - "kanji": "外米はぼそぼそしていて、日本人の口には合わない。", - "kana": "がいまいはぼそぼそしていて、にほんじんのくちにはあわない。", - "pieces": [ - { - "lifted": "がいまい", - "unlifted": "外米" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "", - "unlifted": "ぼそぼそ" - }, - { - "lifted": "", - "unlifted": "していて" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "くち", - "unlifted": "口" - }, - { - "lifted": "", - "unlifted": "には" - }, - { - "lifted": "あ", - "unlifted": "合わない" - } - ] - }, - { - "english": "A number of Japanese people travel abroad every summer.", - "kanji": "毎年、多くの日本人が海外へ旅行する。", - "kana": "まいとし、おおくのにほんじんがかいがいへりょこうする。", - "pieces": [ - { - "lifted": "まいとし", - "unlifted": "毎年" - }, - { - "lifted": "おお", - "unlifted": "多く" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "かいがい", - "unlifted": "海外" - }, - { - "lifted": "", - "unlifted": "へ" - }, - { - "lifted": "りょこう", - "unlifted": "旅行" - }, - { - "lifted": "", - "unlifted": "する" - } - ] - }, - { - "english": "Her father is Japanese.", - "kanji": "彼女の父親は日本人だ。", - "kana": "かのじょのちちおやはにほんじんだ。", - "pieces": [ - { - "lifted": "かのじょ", - "unlifted": "彼女の" - }, - { - "lifted": "ちちおや", - "unlifted": "父親" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "だ" - } - ] - }, - { - "english": "They employ foreigners because Japanese workers are in short supply.", - "kanji": "彼らは日本人労働者が不足しているから外国人を雇う。", - "kana": "かれらはにほんじんろうどうしゃがふそくしているからがいこくじんをやとう。", - "pieces": [ - { - "lifted": "かれ", - "unlifted": "彼ら" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "ろうどうしゃ", - "unlifted": "労働者" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "ふそく", - "unlifted": "不足" - }, - { - "lifted": "", - "unlifted": "している" - }, - { - "lifted": "", - "unlifted": "から" - }, - { - "lifted": "がいこくじん", - "unlifted": "外国人" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "やと", - "unlifted": "雇う" - } - ] - }, - { - "english": "Are they Japanese?", - "kanji": "彼らは日本人ですか。", - "kana": "かれらはにほんじんですか。", - "pieces": [ - { - "lifted": "かれ", - "unlifted": "彼ら" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "ですか" - } - ] - }, - { - "english": "Are they Japanese or Chinese?", - "kanji": "彼らは日本人ですか、それとも中国人ですか。", - "kana": "かれらはにほんじんですか、それともちゅうごくじんですか。", - "pieces": [ - { - "lifted": "かれ", - "unlifted": "彼ら" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "ですか" - }, - { - "lifted": "", - "unlifted": "それとも" - }, - { - "lifted": "ちゅうごくじん", - "unlifted": "中国人" - }, - { - "lifted": "", - "unlifted": "ですか" - } - ] - }, - { - "english": "He is not Japanese.", - "kanji": "彼は日本人ではありません。", - "kana": "かれはにほんじんではありません。", - "pieces": [ - { - "lifted": "かれ", - "unlifted": "彼" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "ではありません" - } - ] - }, - { - "english": "He speaks Japanese as if he were Japanese.", - "kanji": "彼は日本語をまるで日本人であるかのように話す。", - "kana": "かれはにほんごをまるでにほんじんであるかのようにはなす。", - "pieces": [ - { - "lifted": "かれ", - "unlifted": "彼" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "にほんご", - "unlifted": "日本語" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "", - "unlifted": "まるで" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "である" - }, - { - "lifted": "", - "unlifted": "かのように" - }, - { - "lifted": "はな", - "unlifted": "話す" - } - ] - }, - { - "english": "He is a typical Japanese.", - "kanji": "彼は典型的な日本人だ。", - "kana": "かれはてんけいてきなにほんじんだ。", - "pieces": [ - { - "lifted": "かれ", - "unlifted": "彼" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "てんけいてき", - "unlifted": "典型的な" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "だ" - } - ] - }, - { - "english": "He is Japanese by birth.", - "kanji": "彼は生まれは日本人です。", - "kana": "かれはうまれはにほんじんです。", - "pieces": [ - { - "lifted": "かれ", - "unlifted": "彼" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "う", - "unlifted": "生まれ" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "です" - } - ] - }, - { - "english": "He is the first Japanese that traveled in space.", - "kanji": "彼は最初に宇宙旅行をした日本人です。", - "kana": "かれはさいしょにうちゅうりょこうをしたにほんじんです。", - "pieces": [ - { - "lifted": "かれ", - "unlifted": "彼" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "さいしょ", - "unlifted": "最初" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "うちゅうりょこう", - "unlifted": "宇宙旅行" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "", - "unlifted": "した" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "です" - } - ] - }, - { - "english": "He is Japanese to the bone.", - "kanji": "彼は骨の髄まで日本人だ。", - "kana": "かれはほねのずいまでにほんじんだ。", - "pieces": [ - { - "lifted": "かれ", - "unlifted": "彼" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "ほねのずい", - "unlifted": "骨の髄まで" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "だ" - } - ] - }, - { - "english": "He speaks Japanese as if he were Japanese.", - "kanji": "彼は、日本語をまるで日本人かのように話す。", - "kana": "かれは、にほんごをまるでにほんじんかのようにはなす。", - "pieces": [ - { - "lifted": "かれ", - "unlifted": "彼" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "にほんご", - "unlifted": "日本語" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "", - "unlifted": "まるで" - }, - { - "lifted": "にほんじん", - "unlifted": "日本人" - }, - { - "lifted": "", - "unlifted": "かのように" - }, - { - "lifted": "はな", - "unlifted": "話す" - } - ] - } - ], - "uri": "http://jisho.org/search/%E6%97%A5%E6%9C%AC%E4%BA%BA%23sentences", - "phrase": "日本人" - } + "found": true, + "results": [ + { + "english": "A Japanese person would never do such a thing.", + "kanji": "日本人ならそんなことはけっしてしないでしょう。", + "kana": "にほんじんならそんなことはけっしてしないでしょう。", + "pieces": [ + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "なら" + }, + { + "lifted": null, + "unlifted": "そんな" + }, + { + "lifted": null, + "unlifted": "こと" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": null, + "unlifted": "けっして" + }, + { + "lifted": null, + "unlifted": "しない" + }, + { + "lifted": null, + "unlifted": "でしょう" + } + ] + }, + { + "english": "When did the Japanese start eating polished rice?", + "kanji": "いつから日本人は精白米を食べるようになったのですか?", + "kana": "いつからにほんじんはせいはくまいをたべるようになったのですか?", + "pieces": [ + { + "lifted": null, + "unlifted": "いつから" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "せいはくまい", + "unlifted": "精白米" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": "た", + "unlifted": "食べる" + }, + { + "lifted": null, + "unlifted": "ようになった" + }, + { + "lifted": null, + "unlifted": "のです" + }, + { + "lifted": null, + "unlifted": "か" + } + ] + }, + { + "english": "I think there are probably few Japanese who know this side of the Emperor Meiji, the side that left a song like this.", + "kanji": "こんな歌を残している明治天皇の一面を知っている日本人は少ないのではないだろうか。", + "kana": "こんなうたをのこしているめいじてんのうのいちめんをしっているにほんじんはすくないのではないだろうか。", + "pieces": [ + { + "lifted": null, + "unlifted": "こんな" + }, + { + "lifted": "うた", + "unlifted": "歌" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": "のこ", + "unlifted": "残している" + }, + { + "lifted": "めいじてんのう", + "unlifted": "明治天皇" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "いちめん", + "unlifted": "一面" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": "し", + "unlifted": "知っている" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "すく", + "unlifted": "少ない" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": null, + "unlifted": "ではない" + }, + { + "lifted": null, + "unlifted": "だろうか" + } + ] + }, + { + "english": "I'm Japanese, but I don't live in Japan.", + "kanji": "私は日本人ですが、日本に住んでいません。", + "kana": "わたしはにほんじんですが、にほんにすんでいません。", + "pieces": [ + { + "lifted": "わたし", + "unlifted": "私" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "です" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": "にほん", + "unlifted": "日本" + }, + { + "lifted": null, + "unlifted": "に" + }, + { + "lifted": "す", + "unlifted": "住んでいません" + } + ] + }, + { + "english": "They don't use 'celeb' to mean 'rich man' over there. By which I determine that you are Japanese.", + "kanji": "向こうではセレブという言葉を「金持ち」の意味では使わない。という事で日本人と判明しました。", + "kana": "むこうではセレブということばを「かねもち」のいみではつかわない。ということでにほんじんとはんめいしました。", + "pieces": [ + { + "lifted": "む", + "unlifted": "向こう" + }, + { + "lifted": null, + "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": "で" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "つか", + "unlifted": "使わない" + }, + { + "lifted": null, + "unlifted": "と" + }, + { + "lifted": null, + "unlifted": "いう" + }, + { + "lifted": "こと", + "unlifted": "事" + }, + { + "lifted": null, + "unlifted": "で" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "と" + }, + { + "lifted": "はんめい", + "unlifted": "判明" + }, + { + "lifted": null, + "unlifted": "しました" + } + ] + }, + { + "english": "As you can also tell from these beautiful, far from Japanese, looks, Yuna is not pure-blood Japanese. She's a quarter-blood with a westerner as grandmother.", + "kanji": "日本人離れしたこの美しい相貌からもわかるように、優奈は実は生粋の日本人じゃない。西洋人をおばあちゃんに持つ、クォーターだったりする。", + "kana": "にほんじんはなれしたこのうつくしいそうぼうからもわかるように、優奈はじつはきっすいのにほんじんじゃない。せいようじんをおばあちゃんにもつ、クォーターだったりする。", + "pieces": [ + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": "はな", + "unlifted": "離れ" + }, + { + "lifted": null, + "unlifted": "した" + }, + { + "lifted": null, + "unlifted": "この" + }, + { + "lifted": "うつく", + "unlifted": "美しい" + }, + { + "lifted": "そうぼう", + "unlifted": "相貌" + }, + { + "lifted": null, + "unlifted": "から" + }, + { + "lifted": null, + "unlifted": "も" + }, + { + "lifted": null, + "unlifted": "わかる" + }, + { + "lifted": null, + "unlifted": "ように" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "じつ", + "unlifted": "実は" + }, + { + "lifted": "きっすい", + "unlifted": "生粋の" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "じゃない" + }, + { + "lifted": "せいようじん", + "unlifted": "西洋人" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": null, + "unlifted": "おばあちゃん" + }, + { + "lifted": null, + "unlifted": "に" + }, + { + "lifted": "も", + "unlifted": "持つ" + }, + { + "lifted": null, + "unlifted": "クォーター" + }, + { + "lifted": null, + "unlifted": "だったり" + }, + { + "lifted": null, + "unlifted": "する" + } + ] + }, + { + "english": "Today's topic is \"the problem of Japanese people abducted by North Korea\".", + "kanji": "今日のトピックは「北朝鮮による日本人拉致問題」です。", + "kana": "きょうのトピックは「きたちょうせんによるにほんじんらちもんだい」です。", + "pieces": [ + { + "lifted": "きょう", + "unlifted": "今日" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": null, + "unlifted": "トピック" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "きたちょうせん", + "unlifted": "北朝鮮" + }, + { + "lifted": null, + "unlifted": "による" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": "らち", + "unlifted": "拉致" + }, + { + "lifted": "もんだい", + "unlifted": "問題" + }, + { + "lifted": null, + "unlifted": "です" + } + ] + }, + { + "english": "Foreign rice is hard and tasteless, and doesn't appeal to the Japanese palate.", + "kanji": "外米はぼそぼそしていて、日本人の口には合わない。", + "kana": "がいまいはぼそぼそしていて、にほんじんのくちにはあわない。", + "pieces": [ + { + "lifted": "がいまい", + "unlifted": "外米" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": null, + "unlifted": "ぼそぼそ" + }, + { + "lifted": null, + "unlifted": "していて" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "くち", + "unlifted": "口" + }, + { + "lifted": null, + "unlifted": "には" + }, + { + "lifted": "あ", + "unlifted": "合わない" + } + ] + }, + { + "english": "A number of Japanese people travel abroad every summer.", + "kanji": "毎年、多くの日本人が海外へ旅行する。", + "kana": "まいとし、おおくのにほんじんがかいがいへりょこうする。", + "pieces": [ + { + "lifted": "まいとし", + "unlifted": "毎年" + }, + { + "lifted": "おお", + "unlifted": "多く" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": "かいがい", + "unlifted": "海外" + }, + { + "lifted": null, + "unlifted": "へ" + }, + { + "lifted": "りょこう", + "unlifted": "旅行" + }, + { + "lifted": null, + "unlifted": "する" + } + ] + }, + { + "english": "Her father is Japanese.", + "kanji": "彼女の父親は日本人だ。", + "kana": "かのじょのちちおやはにほんじんだ。", + "pieces": [ + { + "lifted": "かのじょ", + "unlifted": "彼女の" + }, + { + "lifted": "ちちおや", + "unlifted": "父親" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "だ" + } + ] + }, + { + "english": "They employ foreigners because Japanese workers are in short supply.", + "kanji": "彼らは日本人労働者が不足しているから外国人を雇う。", + "kana": "かれらはにほんじんろうどうしゃがふそくしているからがいこくじんをやとう。", + "pieces": [ + { + "lifted": "かれ", + "unlifted": "彼ら" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": "ろうどうしゃ", + "unlifted": "労働者" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": "ふそく", + "unlifted": "不足" + }, + { + "lifted": null, + "unlifted": "している" + }, + { + "lifted": null, + "unlifted": "から" + }, + { + "lifted": "がいこくじん", + "unlifted": "外国人" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": "やと", + "unlifted": "雇う" + } + ] + }, + { + "english": "Are they Japanese?", + "kanji": "彼らは日本人ですか。", + "kana": "かれらはにほんじんですか。", + "pieces": [ + { + "lifted": "かれ", + "unlifted": "彼ら" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "ですか" + } + ] + }, + { + "english": "Are they Japanese or Chinese?", + "kanji": "彼らは日本人ですか、それとも中国人ですか。", + "kana": "かれらはにほんじんですか、それともちゅうごくじんですか。", + "pieces": [ + { + "lifted": "かれ", + "unlifted": "彼ら" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "ですか" + }, + { + "lifted": null, + "unlifted": "それとも" + }, + { + "lifted": "ちゅうごくじん", + "unlifted": "中国人" + }, + { + "lifted": null, + "unlifted": "ですか" + } + ] + }, + { + "english": "He is not Japanese.", + "kanji": "彼は日本人ではありません。", + "kana": "かれはにほんじんではありません。", + "pieces": [ + { + "lifted": "かれ", + "unlifted": "彼" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "ではありません" + } + ] + }, + { + "english": "He speaks Japanese as if he were Japanese.", + "kanji": "彼は日本語をまるで日本人であるかのように話す。", + "kana": "かれはにほんごをまるでにほんじんであるかのようにはなす。", + "pieces": [ + { + "lifted": "かれ", + "unlifted": "彼" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "にほんご", + "unlifted": "日本語" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": null, + "unlifted": "まるで" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "である" + }, + { + "lifted": null, + "unlifted": "かのように" + }, + { + "lifted": "はな", + "unlifted": "話す" + } + ] + }, + { + "english": "He is a typical Japanese.", + "kanji": "彼は典型的な日本人だ。", + "kana": "かれはてんけいてきなにほんじんだ。", + "pieces": [ + { + "lifted": "かれ", + "unlifted": "彼" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "てんけいてき", + "unlifted": "典型的な" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "だ" + } + ] + }, + { + "english": "He is Japanese by birth.", + "kanji": "彼は生まれは日本人です。", + "kana": "かれはうまれはにほんじんです。", + "pieces": [ + { + "lifted": "かれ", + "unlifted": "彼" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "う", + "unlifted": "生まれ" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "です" + } + ] + }, + { + "english": "He is the first Japanese that traveled in space.", + "kanji": "彼は最初に宇宙旅行をした日本人です。", + "kana": "かれはさいしょにうちゅうりょこうをしたにほんじんです。", + "pieces": [ + { + "lifted": "かれ", + "unlifted": "彼" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "さいしょ", + "unlifted": "最初" + }, + { + "lifted": null, + "unlifted": "に" + }, + { + "lifted": "うちゅうりょこう", + "unlifted": "宇宙旅行" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": null, + "unlifted": "した" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "です" + } + ] + }, + { + "english": "He is Japanese to the bone.", + "kanji": "彼は骨の髄まで日本人だ。", + "kana": "かれはほねのずいまでにほんじんだ。", + "pieces": [ + { + "lifted": "かれ", + "unlifted": "彼" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "ほねのずい", + "unlifted": "骨の髄まで" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "だ" + } + ] + }, + { + "english": "He speaks Japanese as if he were Japanese.", + "kanji": "彼は、日本語をまるで日本人かのように話す。", + "kana": "かれは、にほんごをまるでにほんじんかのようにはなす。", + "pieces": [ + { + "lifted": "かれ", + "unlifted": "彼" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "にほんご", + "unlifted": "日本語" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": null, + "unlifted": "まるで" + }, + { + "lifted": "にほんじん", + "unlifted": "日本人" + }, + { + "lifted": null, + "unlifted": "かのように" + }, + { + "lifted": "はな", + "unlifted": "話す" + } + ] + } + ], + "uri": "https://jisho.org/search/%E6%97%A5%E6%9C%AC%E4%BA%BA%23sentences", + "phrase": "日本人" } \ No newline at end of file diff --git a/test/example_test_cases/2.json b/test/example_test_cases/2.json index a4ca9dd..71d6556 100644 --- a/test/example_test_cases/2.json +++ b/test/example_test_cases/2.json @@ -1,10 +1,7 @@ { "query": "彼*叩く", - "expectedResult": { - "query": "彼*叩く", - "found": false, - "results": [], - "uri": "http://jisho.org/search/%E5%BD%BC%EF%BC%8A%E5%8F%A9%E3%81%8F%23sentences", - "phrase": "彼*叩く" - } + "found": false, + "results": [], + "uri": "https://jisho.org/search/%E5%BD%BC%EF%BC%8A%E5%8F%A9%E3%81%8F%23sentences", + "phrase": "彼*叩く" } \ No newline at end of file diff --git a/test/example_test_cases/3.json b/test/example_test_cases/3.json index 1064459..68b4b8a 100644 --- a/test/example_test_cases/3.json +++ b/test/example_test_cases/3.json @@ -1,1215 +1,1212 @@ { "query": "皆", - "expectedResult": { - "query": "皆", - "found": true, - "results": [ - { - "english": "The total solar eclipse can be observed next year on June 22nd.", - "kanji": "来年6月22日に観測される皆既日食。", - "kana": "らいねん6月22にちにかんそくされるかいきにっしょく。", - "pieces": [ - { - "lifted": "らいねん", - "unlifted": "来年" - }, - { - "lifted": "", - "unlifted": "6月" - }, - { - "lifted": "にち", - "unlifted": "日" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "かんそく", - "unlifted": "観測" - }, - { - "lifted": "", - "unlifted": "される" - }, - { - "lifted": "かいきにっしょく", - "unlifted": "皆既日食" - } - ] - }, - { - "english": "Do you all place great importance on morals?", - "kanji": "皆さんは、モラルを大切にしていますか。", - "kana": "みなさんは、モラルをたいせつにしていますか。", - "pieces": [ - { - "lifted": "みな", - "unlifted": "皆さん" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "", - "unlifted": "モラル" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "たいせつ", - "unlifted": "大切に" - }, - { - "lifted": "", - "unlifted": "しています" - }, - { - "lifted": "", - "unlifted": "か" - } - ] - }, - { - "english": "Will everyone please stick with it to the last moment.", - "kanji": "どうぞ、皆様も最後の一瞬まで粘り抜いてください。", - "kana": "どうぞ、みなさまもさいごのいっしゅんまでねばりぬいてください。", - "pieces": [ - { - "lifted": "", - "unlifted": "どうぞ" - }, - { - "lifted": "みなさま", - "unlifted": "皆様" - }, - { - "lifted": "", - "unlifted": "も" - }, - { - "lifted": "さいご", - "unlifted": "最後" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "いっしゅん", - "unlifted": "一瞬" - }, - { - "lifted": "", - "unlifted": "まで" - }, - { - "lifted": "ねばりぬ", - "unlifted": "粘り抜いて" - }, - { - "lifted": "", - "unlifted": "ください" - } - ] - }, - { - "english": "We were all pleased to be so cheaply quit of him.", - "kanji": "これだけで厄介払いできたら安いもので、みな大喜びした。", - "kana": "これだけでやっかいばらいできたらやすいもので、みなおおよろこびした。", - "pieces": [ - { - "lifted": "", - "unlifted": "これだけ" - }, - { - "lifted": "", - "unlifted": "で" - }, - { - "lifted": "やっかいばら", - "unlifted": "厄介払い" - }, - { - "lifted": "", - "unlifted": "できたら" - }, - { - "lifted": "やす", - "unlifted": "安い" - }, - { - "lifted": "", - "unlifted": "もの" - }, - { - "lifted": "", - "unlifted": "で" - }, - { - "lifted": "", - "unlifted": "みな" - }, - { - "lifted": "おおよろこ", - "unlifted": "大喜び" - }, - { - "lifted": "", - "unlifted": "した" - } - ] - }, - { - "english": "For my part, having you lot with me is more reassuring than the police or anything!", - "kanji": "僕には警察よりも何よりもみんながいてくれることの方が心強いのですよ。", - "kana": "ぼくにはけいさつよりもなによりもみんながいてくれることのほうがこころづよいのですよ。", - "pieces": [ - { - "lifted": "ぼく", - "unlifted": "僕" - }, - { - "lifted": "", - "unlifted": "には" - }, - { - "lifted": "けいさつ", - "unlifted": "警察" - }, - { - "lifted": "", - "unlifted": "よりも" - }, - { - "lifted": "なに", - "unlifted": "何" - }, - { - "lifted": "", - "unlifted": "よりも" - }, - { - "lifted": "", - "unlifted": "みんな" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "", - "unlifted": "いて" - }, - { - "lifted": "", - "unlifted": "くれる" - }, - { - "lifted": "", - "unlifted": "こと" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "ほう", - "unlifted": "方" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "こころづよ", - "unlifted": "心強い" - }, - { - "lifted": "", - "unlifted": "のです" - }, - { - "lifted": "", - "unlifted": "よ" - } - ] - }, - { - "english": "With your ability it should be a doddle, but please don't be prideful of that but first apply yourself dilligently with everyone in your class.", - "kanji": "君の実力なら楽勝だとは思うが、それに驕らず、まずはクラスのみんなと切磋琢磨していって欲しい。", - "kana": "きみのじつりょくなららくしょうだとはおもうが、それにおごらず、まずはクラスのみんなとせっさたくましていってほしい。", - "pieces": [ - { - "lifted": "きみ", - "unlifted": "君の" - }, - { - "lifted": "じつりょく", - "unlifted": "実力" - }, - { - "lifted": "", - "unlifted": "なら" - }, - { - "lifted": "らくしょう", - "unlifted": "楽勝" - }, - { - "lifted": "", - "unlifted": "だ" - }, - { - "lifted": "", - "unlifted": "と" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "おも", - "unlifted": "思う" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "", - "unlifted": "それ" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "おご", - "unlifted": "驕らず" - }, - { - "lifted": "", - "unlifted": "まず" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "", - "unlifted": "クラス" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "", - "unlifted": "みんな" - }, - { - "lifted": "", - "unlifted": "と" - }, - { - "lifted": "せっさたくま", - "unlifted": "切磋琢磨" - }, - { - "lifted": "", - "unlifted": "して" - }, - { - "lifted": "", - "unlifted": "いって" - }, - { - "lifted": "ほ", - "unlifted": "欲しい" - } - ] - }, - { - "english": "What programming language does everybody like?", - "kanji": "皆さんはどんなプログラミング言語が好きですか?", - "kana": "みなさんはどんなプログラミングげんごがすきですか?", - "pieces": [ - { - "lifted": "みな", - "unlifted": "皆さん" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "", - "unlifted": "どんな" - }, - { - "lifted": "プログラミングげんご", - "unlifted": "プログラミング言語" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "す", - "unlifted": "好き" - }, - { - "lifted": "", - "unlifted": "ですか" - } - ] - }, - { - "english": "I'm teaching basic participial constructions now, but, with regard to those below, what different ways of translating them would everybody use?", - "kanji": "今、基本的な分詞構文を教えているのですが、皆さんは以下の分詞構文の訳については、どのように異なる訳し方をされますか?", - "kana": "いま、きほんてきなぶんしこうぶんをおしええているのですが、みなさんはいかのぶんしこうぶんのやくについては、どのようにことなるやくしかたをされますか?", - "pieces": [ - { - "lifted": "いま", - "unlifted": "今" - }, - { - "lifted": "きほんてき", - "unlifted": "基本的な" - }, - { - "lifted": "ぶんしこうぶん", - "unlifted": "分詞構文" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "おしえ", - "unlifted": "教えている" - }, - { - "lifted": "", - "unlifted": "のです" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "みな", - "unlifted": "皆さん" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "いか", - "unlifted": "以下" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "ぶんしこうぶん", - "unlifted": "分詞構文" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "やく", - "unlifted": "訳" - }, - { - "lifted": "", - "unlifted": "について" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "", - "unlifted": "どのように" - }, - { - "lifted": "こと", - "unlifted": "異なる" - }, - { - "lifted": "やく", - "unlifted": "訳し" - }, - { - "lifted": "かた", - "unlifted": "方" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "", - "unlifted": "されます" - }, - { - "lifted": "", - "unlifted": "か" - } - ] - }, - { - "english": "What's different from Japan is that the doctors of Singapore generally all know each other.", - "kanji": "シンガポールの医師は殆どの場合皆お互いを知っている、というのが日本と異なります。", - "kana": "シンガポールのいしはほとんどのばあいみんなおたがいをしっている、というのがにほんとことなります。", - "pieces": [ - { - "lifted": "", - "unlifted": "シンガポール" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "いし", - "unlifted": "医師" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "ほとん", - "unlifted": "殆ど" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "ばあい", - "unlifted": "場合" - }, - { - "lifted": "みんな", - "unlifted": "皆" - }, - { - "lifted": "おたが", - "unlifted": "お互い" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "し", - "unlifted": "知っている" - }, - { - "lifted": "", - "unlifted": "と" - }, - { - "lifted": "", - "unlifted": "いう" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "にほん", - "unlifted": "日本" - }, - { - "lifted": "", - "unlifted": "と" - }, - { - "lifted": "こと", - "unlifted": "異なります" - } - ] - }, - { - "english": "Everyone, please keep to netiquette.", - "kanji": "皆さんネチケットはしっかり。", - "kana": "みなさんネチケットはしっかり。", - "pieces": [ - { - "lifted": "みな", - "unlifted": "皆さん" - }, - { - "lifted": "", - "unlifted": "ネチケット" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "", - "unlifted": "しっかり" - } - ] - }, - { - "english": "The example is a past progressive tense sentence. How was everybody taught when they were learning about progressive tense?", - "kanji": "例文は過去進行形の文です。皆さんは進行形を学習するとき、どのように教わりましたか?", - "kana": "れいぶんはかこしんこうけいのぶんです。みなさんはしんこうけいをがくしゅうするとき、どのようにおそわりましたか?", - "pieces": [ - { - "lifted": "れいぶん", - "unlifted": "例文" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "かこしんこうけい", - "unlifted": "過去進行形" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "ぶん", - "unlifted": "文" - }, - { - "lifted": "", - "unlifted": "です" - }, - { - "lifted": "みな", - "unlifted": "皆さん" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "しんこうけい", - "unlifted": "進行形" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "がくしゅう", - "unlifted": "学習" - }, - { - "lifted": "", - "unlifted": "する" - }, - { - "lifted": "", - "unlifted": "とき" - }, - { - "lifted": "", - "unlifted": "どのように" - }, - { - "lifted": "おそ", - "unlifted": "教わりました" - }, - { - "lifted": "", - "unlifted": "か" - } - ] - }, - { - "english": "Oh, that's a secret, OK? Because slipping out of the dorm in the night is severely punished.", - "kanji": "あ、みんなには内緒だよ?寮を夜中に抜け出すのは厳罰だからね?", - "kana": "あ、みんなにはないしょだよ?りょうをよなかにぬけだすのはげんばつだからね?", - "pieces": [ - { - "lifted": "", - "unlifted": "あ" - }, - { - "lifted": "", - "unlifted": "みんな" - }, - { - "lifted": "", - "unlifted": "には" - }, - { - "lifted": "ないしょ", - "unlifted": "内緒" - }, - { - "lifted": "", - "unlifted": "だ" - }, - { - "lifted": "", - "unlifted": "よ" - }, - { - "lifted": "りょう", - "unlifted": "寮" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "よなか", - "unlifted": "夜中" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "ぬけだ", - "unlifted": "抜け出す" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "げんばつ", - "unlifted": "厳罰" - }, - { - "lifted": "", - "unlifted": "だ" - }, - { - "lifted": "", - "unlifted": "から" - }, - { - "lifted": "", - "unlifted": "ね" - } - ] - }, - { - "english": "\"I've heard about it, Koichi\" \"You don't need to say anything more, I know. It's the summer festival incident at the shrine, right?\"", - "kanji": "「聞いたよ、光一」「まあ皆までいうなって。分かってる。神社の夏祭りの一件でしょ?」", - "kana": "「きいたよ、光一」「まあみなまでいうなって。わかかってる。じんじゃの夏祭りのいっけんでしょ?」", - "pieces": [ - { - "lifted": "き", - "unlifted": "聞いた" - }, - { - "lifted": "", - "unlifted": "よ" - }, - { - "lifted": "", - "unlifted": "まあ" - }, - { - "lifted": "みな", - "unlifted": "皆までいうな" - }, - { - "lifted": "", - "unlifted": "って" - }, - { - "lifted": "わか", - "unlifted": "分かってる" - }, - { - "lifted": "じんじゃ", - "unlifted": "神社" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "", - "unlifted": "夏祭り" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "いっけん", - "unlifted": "一件" - }, - { - "lifted": "", - "unlifted": "でしょ" - } - ] - }, - { - "english": "We plan to elicit opinions from the public.", - "kanji": "市民の皆様の御意見をちょうだいする予定です。", - "kana": "しみんのみなさまのごいけんをちょうだいするよていです。", - "pieces": [ - { - "lifted": "しみん", - "unlifted": "市民" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "みなさま", - "unlifted": "皆様" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "ご", - "unlifted": "御" - }, - { - "lifted": "いけん", - "unlifted": "意見" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "", - "unlifted": "ちょうだい" - }, - { - "lifted": "", - "unlifted": "する" - }, - { - "lifted": "よてい", - "unlifted": "予定" - }, - { - "lifted": "", - "unlifted": "です" - } - ] - }, - { - "english": "Having scattered the enemy before me and triumphantly returned, this is how they would herald me.", - "kanji": "敵を蹴散らし、凱旋した俺はみなにこう呼ばれるんだ!", - "kana": "てきをけちらし、がいせんしたおれはみなにこうよばれるんだ!", - "pieces": [ - { - "lifted": "てき", - "unlifted": "敵" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "けち", - "unlifted": "蹴散らし" - }, - { - "lifted": "がいせん", - "unlifted": "凱旋" - }, - { - "lifted": "", - "unlifted": "した" - }, - { - "lifted": "おれ", - "unlifted": "俺" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "", - "unlifted": "みな" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "", - "unlifted": "こう" - }, - { - "lifted": "よ", - "unlifted": "呼ばれる" - }, - { - "lifted": "", - "unlifted": "んだ" - } - ] - }, - { - "english": "Quiet! Everybody stay where they are, there will now be a possessions check.", - "kanji": "静かに!みんなその場を動かないで。これから持ち物検査をはじめます。", - "kana": "しずかに!みんなそのばをうごかないで。これからもちものけんさをはじめます。", - "pieces": [ - { - "lifted": "しず", - "unlifted": "静かに" - }, - { - "lifted": "", - "unlifted": "みんな" - }, - { - "lifted": "そのば", - "unlifted": "その場" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "うご", - "unlifted": "動かないで" - }, - { - "lifted": "", - "unlifted": "これ" - }, - { - "lifted": "", - "unlifted": "から" - }, - { - "lifted": "もちものけんさ", - "unlifted": "持ち物検査" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "", - "unlifted": "はじめます" - } - ] - }, - { - "english": "Even if that's alright with you nobody else will accept it. I'll get shouted at afterwards so...", - "kanji": "恵子さんが良くてもみんなが納得しないんです。後で俺がドヤされるんだから。", - "kana": "恵子さんがよくてもみんながなっとくしないんです。あとでおれがドヤされるんだから。", - "pieces": [ - { - "lifted": "", - "unlifted": "さん" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "よ", - "unlifted": "良くて" - }, - { - "lifted": "", - "unlifted": "も" - }, - { - "lifted": "", - "unlifted": "みんな" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "なっとく", - "unlifted": "納得" - }, - { - "lifted": "", - "unlifted": "しない" - }, - { - "lifted": "", - "unlifted": "んです" - }, - { - "lifted": "あと", - "unlifted": "後" - }, - { - "lifted": "", - "unlifted": "で" - }, - { - "lifted": "おれ", - "unlifted": "俺" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "", - "unlifted": "ドヤされる" - }, - { - "lifted": "", - "unlifted": "ん" - }, - { - "lifted": "", - "unlifted": "だから" - } - ] - }, - { - "english": "At home, because of his reddish hair and freckles, his mother scornfully named him \"carrot\" and had everybody else call him that.", - "kanji": "家では赤味がかった髪とそばかすのせいで、母が侮蔑を込めて「にんじん」と名付け、皆にもそう呼ばせています。", - "kana": "いえでは赤味がかったかみとそばかすのせいで、ははがぶべつをこめて「にんじん」となづけ、みんなにもそうよばせています。", - "pieces": [ - { - "lifted": "いえ", - "unlifted": "家" - }, - { - "lifted": "", - "unlifted": "で" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "", - "unlifted": "赤味がかった" - }, - { - "lifted": "かみ", - "unlifted": "髪" - }, - { - "lifted": "", - "unlifted": "と" - }, - { - "lifted": "", - "unlifted": "そばかす" - }, - { - "lifted": "", - "unlifted": "のせいで" - }, - { - "lifted": "はは", - "unlifted": "母" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "ぶべつ", - "unlifted": "侮蔑" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "こ", - "unlifted": "込めて" - }, - { - "lifted": "", - "unlifted": "にんじん" - }, - { - "lifted": "", - "unlifted": "と" - }, - { - "lifted": "なづ", - "unlifted": "名付け" - }, - { - "lifted": "みんな", - "unlifted": "皆" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "", - "unlifted": "も" - }, - { - "lifted": "", - "unlifted": "そう" - }, - { - "lifted": "よ", - "unlifted": "呼ばせています" - } - ] - }, - { - "english": "All for one, and one for all. That's team play.", - "kanji": "一人はみんなの為に、みんなは一人の為に。それがチームプレイだ。", - "kana": "ひとりはみんなのために、みんなはひとりのために。それがチームプレイだ。", - "pieces": [ - { - "lifted": "ひとり", - "unlifted": "一人" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "", - "unlifted": "みんな" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "ため", - "unlifted": "為に" - }, - { - "lifted": "", - "unlifted": "みんな" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "ひとり", - "unlifted": "一人" - }, - { - "lifted": "", - "unlifted": "の" - }, - { - "lifted": "ため", - "unlifted": "為に" - }, - { - "lifted": "", - "unlifted": "それ" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "", - "unlifted": "チームプレイ" - }, - { - "lifted": "", - "unlifted": "だ" - } - ] - }, - { - "english": "Guys, I'll do my utmost to back you up. We'll make this event a success no matter what!", - "kanji": "みんな、俺も全力でフォローする。このイベントかならず成功させるぞ。", - "kana": "みんな、おれもぜんりょくでフォローする。このイベントかならずせいこうさせるぞ。", - "pieces": [ - { - "lifted": "", - "unlifted": "みんな" - }, - { - "lifted": "おれ", - "unlifted": "俺" - }, - { - "lifted": "", - "unlifted": "も" - }, - { - "lifted": "ぜんりょく", - "unlifted": "全力" - }, - { - "lifted": "", - "unlifted": "で" - }, - { - "lifted": "", - "unlifted": "フォロー" - }, - { - "lifted": "", - "unlifted": "する" - }, - { - "lifted": "", - "unlifted": "この" - }, - { - "lifted": "", - "unlifted": "イベント" - }, - { - "lifted": "", - "unlifted": "かならず" - }, - { - "lifted": "せいこう", - "unlifted": "成功" - }, - { - "lifted": "", - "unlifted": "させる" - }, - { - "lifted": "", - "unlifted": "ぞ" - } - ] - } - ], - "uri": "http://jisho.org/search/%E7%9A%86%23sentences", - "phrase": "皆" - } + "found": true, + "results": [ + { + "english": "The total solar eclipse can be observed next year on June 22nd.", + "kanji": "来年6月22日に観測される皆既日食。", + "kana": "らいねん6月22にちにかんそくされるかいきにっしょく。", + "pieces": [ + { + "lifted": "らいねん", + "unlifted": "来年" + }, + { + "lifted": null, + "unlifted": "6月" + }, + { + "lifted": "にち", + "unlifted": "日" + }, + { + "lifted": null, + "unlifted": "に" + }, + { + "lifted": "かんそく", + "unlifted": "観測" + }, + { + "lifted": null, + "unlifted": "される" + }, + { + "lifted": "かいきにっしょく", + "unlifted": "皆既日食" + } + ] + }, + { + "english": "Do you all place great importance on morals?", + "kanji": "皆さんは、モラルを大切にしていますか。", + "kana": "みなさんは、モラルをたいせつにしていますか。", + "pieces": [ + { + "lifted": "みな", + "unlifted": "皆さん" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": null, + "unlifted": "モラル" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": "たいせつ", + "unlifted": "大切に" + }, + { + "lifted": null, + "unlifted": "しています" + }, + { + "lifted": null, + "unlifted": "か" + } + ] + }, + { + "english": "Will everyone please stick with it to the last moment.", + "kanji": "どうぞ、皆様も最後の一瞬まで粘り抜いてください。", + "kana": "どうぞ、みなさまもさいごのいっしゅんまでねばりぬいてください。", + "pieces": [ + { + "lifted": null, + "unlifted": "どうぞ" + }, + { + "lifted": "みなさま", + "unlifted": "皆様" + }, + { + "lifted": null, + "unlifted": "も" + }, + { + "lifted": "さいご", + "unlifted": "最後" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "いっしゅん", + "unlifted": "一瞬" + }, + { + "lifted": null, + "unlifted": "まで" + }, + { + "lifted": "ねばりぬ", + "unlifted": "粘り抜いて" + }, + { + "lifted": null, + "unlifted": "ください" + } + ] + }, + { + "english": "We were all pleased to be so cheaply quit of him.", + "kanji": "これだけで厄介払いできたら安いもので、みな大喜びした。", + "kana": "これだけでやっかいばらいできたらやすいもので、みなおおよろこびした。", + "pieces": [ + { + "lifted": null, + "unlifted": "これだけ" + }, + { + "lifted": null, + "unlifted": "で" + }, + { + "lifted": "やっかいばら", + "unlifted": "厄介払い" + }, + { + "lifted": null, + "unlifted": "できたら" + }, + { + "lifted": "やす", + "unlifted": "安い" + }, + { + "lifted": null, + "unlifted": "もの" + }, + { + "lifted": null, + "unlifted": "で" + }, + { + "lifted": null, + "unlifted": "みな" + }, + { + "lifted": "おおよろこ", + "unlifted": "大喜び" + }, + { + "lifted": null, + "unlifted": "した" + } + ] + }, + { + "english": "For my part, having you lot with me is more reassuring than the police or anything!", + "kanji": "僕には警察よりも何よりもみんながいてくれることの方が心強いのですよ。", + "kana": "ぼくにはけいさつよりもなによりもみんながいてくれることのほうがこころづよいのですよ。", + "pieces": [ + { + "lifted": "ぼく", + "unlifted": "僕" + }, + { + "lifted": null, + "unlifted": "には" + }, + { + "lifted": "けいさつ", + "unlifted": "警察" + }, + { + "lifted": null, + "unlifted": "よりも" + }, + { + "lifted": "なに", + "unlifted": "何" + }, + { + "lifted": null, + "unlifted": "よりも" + }, + { + "lifted": null, + "unlifted": "みんな" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": null, + "unlifted": "いて" + }, + { + "lifted": null, + "unlifted": "くれる" + }, + { + "lifted": null, + "unlifted": "こと" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "ほう", + "unlifted": "方" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": "こころづよ", + "unlifted": "心強い" + }, + { + "lifted": null, + "unlifted": "のです" + }, + { + "lifted": null, + "unlifted": "よ" + } + ] + }, + { + "english": "With your ability it should be a doddle, but please don't be prideful of that but first apply yourself dilligently with everyone in your class.", + "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": null, + "unlifted": "それ" + }, + { + "lifted": null, + "unlifted": "に" + }, + { + "lifted": "おご", + "unlifted": "驕らず" + }, + { + "lifted": null, + "unlifted": "まず" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": null, + "unlifted": "クラス" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": null, + "unlifted": "みんな" + }, + { + "lifted": null, + "unlifted": "と" + }, + { + "lifted": "せっさたくま", + "unlifted": "切磋琢磨" + }, + { + "lifted": null, + "unlifted": "して" + }, + { + "lifted": null, + "unlifted": "いって" + }, + { + "lifted": "ほ", + "unlifted": "欲しい" + } + ] + }, + { + "english": "What programming language does everybody like?", + "kanji": "皆さんはどんなプログラミング言語が好きですか?", + "kana": "みなさんはどんなプログラミングげんごがすきですか?", + "pieces": [ + { + "lifted": "みな", + "unlifted": "皆さん" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": null, + "unlifted": "どんな" + }, + { + "lifted": "プログラミングげんご", + "unlifted": "プログラミング言語" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": "す", + "unlifted": "好き" + }, + { + "lifted": null, + "unlifted": "ですか" + } + ] + }, + { + "english": "I'm teaching basic participial constructions now, but, with regard to those below, what different ways of translating them would everybody use?", + "kanji": "今、基本的な分詞構文を教えているのですが、皆さんは以下の分詞構文の訳については、どのように異なる訳し方をされますか?", + "kana": "いま、きほんてきなぶんしこうぶんをおしええているのですが、みなさんはいかのぶんしこうぶんのやくについては、どのようにことなるやくしかたをされますか?", + "pieces": [ + { + "lifted": "いま", + "unlifted": "今" + }, + { + "lifted": "きほんてき", + "unlifted": "基本的な" + }, + { + "lifted": "ぶんしこうぶん", + "unlifted": "分詞構文" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": "おしえ", + "unlifted": "教えている" + }, + { + "lifted": null, + "unlifted": "のです" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": "みな", + "unlifted": "皆さん" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "いか", + "unlifted": "以下" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "ぶんしこうぶん", + "unlifted": "分詞構文" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "やく", + "unlifted": "訳" + }, + { + "lifted": null, + "unlifted": "について" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": null, + "unlifted": "どのように" + }, + { + "lifted": "こと", + "unlifted": "異なる" + }, + { + "lifted": "やく", + "unlifted": "訳し" + }, + { + "lifted": "かた", + "unlifted": "方" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": null, + "unlifted": "されます" + }, + { + "lifted": null, + "unlifted": "か" + } + ] + }, + { + "english": "What's different from Japan is that the doctors of Singapore generally all know each other.", + "kanji": "シンガポールの医師は殆どの場合皆お互いを知っている、というのが日本と異なります。", + "kana": "シンガポールのいしはほとんどのばあいみんなおたがいをしっている、というのがにほんとことなります。", + "pieces": [ + { + "lifted": null, + "unlifted": "シンガポール" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "いし", + "unlifted": "医師" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "ほとん", + "unlifted": "殆ど" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "ばあい", + "unlifted": "場合" + }, + { + "lifted": "みんな", + "unlifted": "皆" + }, + { + "lifted": "おたが", + "unlifted": "お互い" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": "し", + "unlifted": "知っている" + }, + { + "lifted": null, + "unlifted": "と" + }, + { + "lifted": null, + "unlifted": "いう" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": "にほん", + "unlifted": "日本" + }, + { + "lifted": null, + "unlifted": "と" + }, + { + "lifted": "こと", + "unlifted": "異なります" + } + ] + }, + { + "english": "Everyone, please keep to netiquette.", + "kanji": "皆さんネチケットはしっかり。", + "kana": "みなさんネチケットはしっかり。", + "pieces": [ + { + "lifted": "みな", + "unlifted": "皆さん" + }, + { + "lifted": null, + "unlifted": "ネチケット" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": null, + "unlifted": "しっかり" + } + ] + }, + { + "english": "The example is a past progressive tense sentence. How was everybody taught when they were learning about progressive tense?", + "kanji": "例文は過去進行形の文です。皆さんは進行形を学習するとき、どのように教わりましたか?", + "kana": "れいぶんはかこしんこうけいのぶんです。みなさんはしんこうけいをがくしゅうするとき、どのようにおそわりましたか?", + "pieces": [ + { + "lifted": "れいぶん", + "unlifted": "例文" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "かこしんこうけい", + "unlifted": "過去進行形" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "ぶん", + "unlifted": "文" + }, + { + "lifted": null, + "unlifted": "です" + }, + { + "lifted": "みな", + "unlifted": "皆さん" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "しんこうけい", + "unlifted": "進行形" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": "がくしゅう", + "unlifted": "学習" + }, + { + "lifted": null, + "unlifted": "する" + }, + { + "lifted": null, + "unlifted": "とき" + }, + { + "lifted": null, + "unlifted": "どのように" + }, + { + "lifted": "おそ", + "unlifted": "教わりました" + }, + { + "lifted": null, + "unlifted": "か" + } + ] + }, + { + "english": "Oh, that's a secret, OK? Because slipping out of the dorm in the night is severely punished.", + "kanji": "あ、みんなには内緒だよ?寮を夜中に抜け出すのは厳罰だからね?", + "kana": "あ、みんなにはないしょだよ?りょうをよなかにぬけだすのはげんばつだからね?", + "pieces": [ + { + "lifted": null, + "unlifted": "あ" + }, + { + "lifted": null, + "unlifted": "みんな" + }, + { + "lifted": null, + "unlifted": "には" + }, + { + "lifted": "ないしょ", + "unlifted": "内緒" + }, + { + "lifted": null, + "unlifted": "だ" + }, + { + "lifted": null, + "unlifted": "よ" + }, + { + "lifted": "りょう", + "unlifted": "寮" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": "よなか", + "unlifted": "夜中" + }, + { + "lifted": null, + "unlifted": "に" + }, + { + "lifted": "ぬけだ", + "unlifted": "抜け出す" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "げんばつ", + "unlifted": "厳罰" + }, + { + "lifted": null, + "unlifted": "だ" + }, + { + "lifted": null, + "unlifted": "から" + }, + { + "lifted": null, + "unlifted": "ね" + } + ] + }, + { + "english": "\"I've heard about it, Koichi\" \"You don't need to say anything more, I know. It's the summer festival incident at the shrine, right?\"", + "kanji": "「聞いたよ、光一」「まあ皆までいうなって。分かってる。神社の夏祭りの一件でしょ?」", + "kana": "「きいたよ、光一」「まあ皆までいうなって。わかかってる。じんじゃの夏祭りのいっけんでしょ?」", + "pieces": [ + { + "lifted": "き", + "unlifted": "聞いた" + }, + { + "lifted": null, + "unlifted": "よ" + }, + { + "lifted": null, + "unlifted": "まあ" + }, + { + "lifted": null, + "unlifted": "皆までいうな" + }, + { + "lifted": null, + "unlifted": "って" + }, + { + "lifted": "わか", + "unlifted": "分かってる" + }, + { + "lifted": "じんじゃ", + "unlifted": "神社" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": null, + "unlifted": "夏祭り" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "いっけん", + "unlifted": "一件" + }, + { + "lifted": null, + "unlifted": "でしょ" + } + ] + }, + { + "english": "We plan to elicit opinions from the public.", + "kanji": "市民の皆様の御意見をちょうだいする予定です。", + "kana": "しみんのみなさまのごいけんをちょうだいするよていです。", + "pieces": [ + { + "lifted": "しみん", + "unlifted": "市民" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "みなさま", + "unlifted": "皆様" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "ご", + "unlifted": "御" + }, + { + "lifted": "いけん", + "unlifted": "意見" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": null, + "unlifted": "ちょうだい" + }, + { + "lifted": null, + "unlifted": "する" + }, + { + "lifted": "よてい", + "unlifted": "予定" + }, + { + "lifted": null, + "unlifted": "です" + } + ] + }, + { + "english": "Having scattered the enemy before me and triumphantly returned, this is how they would herald me.", + "kanji": "敵を蹴散らし、凱旋した俺はみなにこう呼ばれるんだ!", + "kana": "てきをけちらし、がいせんしたおれはみなにこうよばれるんだ!", + "pieces": [ + { + "lifted": "てき", + "unlifted": "敵" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": "けち", + "unlifted": "蹴散らし" + }, + { + "lifted": "がいせん", + "unlifted": "凱旋" + }, + { + "lifted": null, + "unlifted": "した" + }, + { + "lifted": "おれ", + "unlifted": "俺" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": null, + "unlifted": "みな" + }, + { + "lifted": null, + "unlifted": "に" + }, + { + "lifted": null, + "unlifted": "こう" + }, + { + "lifted": "よ", + "unlifted": "呼ばれる" + }, + { + "lifted": null, + "unlifted": "んだ" + } + ] + }, + { + "english": "Quiet! Everybody stay where they are, there will now be a possessions check.", + "kanji": "静かに!みんなその場を動かないで。これから持ち物検査をはじめます。", + "kana": "しずかに!みんなそのばをうごかないで。これからもちものけんさをはじめます。", + "pieces": [ + { + "lifted": "しず", + "unlifted": "静かに" + }, + { + "lifted": null, + "unlifted": "みんな" + }, + { + "lifted": "そのば", + "unlifted": "その場" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": "うご", + "unlifted": "動かないで" + }, + { + "lifted": null, + "unlifted": "これ" + }, + { + "lifted": null, + "unlifted": "から" + }, + { + "lifted": "もちものけんさ", + "unlifted": "持ち物検査" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": null, + "unlifted": "はじめます" + } + ] + }, + { + "english": "Even if that's alright with you nobody else will accept it. I'll get shouted at afterwards so...", + "kanji": "恵子さんが良くてもみんなが納得しないんです。後で俺がドヤされるんだから。", + "kana": "恵子さんがよくてもみんながなっとくしないんです。あとでおれがドヤされるんだから。", + "pieces": [ + { + "lifted": null, + "unlifted": "さん" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": "よ", + "unlifted": "良くて" + }, + { + "lifted": null, + "unlifted": "も" + }, + { + "lifted": null, + "unlifted": "みんな" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": "なっとく", + "unlifted": "納得" + }, + { + "lifted": null, + "unlifted": "しない" + }, + { + "lifted": null, + "unlifted": "んです" + }, + { + "lifted": "あと", + "unlifted": "後" + }, + { + "lifted": null, + "unlifted": "で" + }, + { + "lifted": "おれ", + "unlifted": "俺" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": null, + "unlifted": "ドヤされる" + }, + { + "lifted": null, + "unlifted": "ん" + }, + { + "lifted": null, + "unlifted": "だから" + } + ] + }, + { + "english": "At home, because of his reddish hair and freckles, his mother scornfully named him \"carrot\" and had everybody else call him that.", + "kanji": "家では赤味がかった髪とそばかすのせいで、母が侮蔑を込めて「にんじん」と名付け、皆にもそう呼ばせています。", + "kana": "いえでは赤味がかったかみとそばかすのせいで、ははがぶべつをこめて「にんじん」となづけ、みんなにもそうよばせています。", + "pieces": [ + { + "lifted": "いえ", + "unlifted": "家" + }, + { + "lifted": null, + "unlifted": "で" + }, + { + "lifted": null, + "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": "にんじん" + }, + { + "lifted": null, + "unlifted": "と" + }, + { + "lifted": "なづ", + "unlifted": "名付け" + }, + { + "lifted": "みんな", + "unlifted": "皆" + }, + { + "lifted": null, + "unlifted": "に" + }, + { + "lifted": null, + "unlifted": "も" + }, + { + "lifted": null, + "unlifted": "そう" + }, + { + "lifted": "よ", + "unlifted": "呼ばせています" + } + ] + }, + { + "english": "All for one, and one for all. That's team play.", + "kanji": "一人はみんなの為に、みんなは一人の為に。それがチームプレイだ。", + "kana": "ひとりはみんなのために、みんなはひとりのために。それがチームプレイだ。", + "pieces": [ + { + "lifted": "ひとり", + "unlifted": "一人" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": null, + "unlifted": "みんな" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "ため", + "unlifted": "為に" + }, + { + "lifted": null, + "unlifted": "みんな" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": "ひとり", + "unlifted": "一人" + }, + { + "lifted": null, + "unlifted": "の" + }, + { + "lifted": "ため", + "unlifted": "為に" + }, + { + "lifted": null, + "unlifted": "それ" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": null, + "unlifted": "チームプレイ" + }, + { + "lifted": null, + "unlifted": "だ" + } + ] + }, + { + "english": "Guys, I'll do my utmost to back you up. We'll make this event a success no matter what!", + "kanji": "みんな、俺も全力でフォローする。このイベントかならず成功させるぞ。", + "kana": "みんな、おれもぜんりょくでフォローする。このイベントかならずせいこうさせるぞ。", + "pieces": [ + { + "lifted": null, + "unlifted": "みんな" + }, + { + "lifted": "おれ", + "unlifted": "俺" + }, + { + "lifted": null, + "unlifted": "も" + }, + { + "lifted": "ぜんりょく", + "unlifted": "全力" + }, + { + "lifted": null, + "unlifted": "で" + }, + { + "lifted": null, + "unlifted": "フォロー" + }, + { + "lifted": null, + "unlifted": "する" + }, + { + "lifted": null, + "unlifted": "この" + }, + { + "lifted": null, + "unlifted": "イベント" + }, + { + "lifted": null, + "unlifted": "かならず" + }, + { + "lifted": "せいこう", + "unlifted": "成功" + }, + { + "lifted": null, + "unlifted": "させる" + }, + { + "lifted": null, + "unlifted": "ぞ" + } + ] + } + ], + "uri": "https://jisho.org/search/%E7%9A%86%23sentences", + "phrase": "皆" } \ No newline at end of file diff --git a/test/example_test_cases/4.json b/test/example_test_cases/4.json index f573034..9a37b84 100644 --- a/test/example_test_cases/4.json +++ b/test/example_test_cases/4.json @@ -1,10 +1,7 @@ { "query": "ネガティブ", - "expectedResult": { - "query": "ネガティブ", - "found": false, - "results": [], - "uri": "http://jisho.org/search/%E3%83%8D%E3%82%AC%E3%83%86%E3%82%A3%E3%83%96%23sentences", - "phrase": "ネガティブ" - } + "found": false, + "results": [], + "uri": "https://jisho.org/search/%E3%83%8D%E3%82%AC%E3%83%86%E3%82%A3%E3%83%96%23sentences", + "phrase": "ネガティブ" } \ No newline at end of file diff --git a/test/example_test_cases/5.json b/test/example_test_cases/5.json index 9cb94dc..afc70ea 100644 --- a/test/example_test_cases/5.json +++ b/test/example_test_cases/5.json @@ -1,10 +1,7 @@ { "query": "grlgmregmneriireg", - "expectedResult": { - "query": "grlgmregmneriireg", - "found": false, - "results": [], - "uri": "http://jisho.org/search/grlgmregmneriireg%23sentences", - "phrase": "grlgmregmneriireg" - } + "found": false, + "results": [], + "uri": "https://jisho.org/search/grlgmregmneriireg%23sentences", + "phrase": "grlgmregmneriireg" } \ No newline at end of file diff --git a/test/kanji_test_cases/0.json b/test/kanji_test_cases/0.json index bd5f1e5..ebc1c6a 100644 --- a/test/kanji_test_cases/0.json +++ b/test/kanji_test_cases/0.json @@ -1,68 +1,66 @@ { "query": "車", - "expectedResult": { - "query": "車", - "found": true, - "taughtIn": "grade 1", - "jlptLevel": "N5", - "newspaperFrequencyRank": "333", - "strokeCount": 7, - "meaning": "car", - "kunyomi": [ - "くるま" - ], - "onyomi": [ - "シャ" - ], - "onyomiExamples": [ - { - "example": "車", - "reading": "シャ", - "meaning": "car, vehicle" - }, - { - "example": "車検", - "reading": "シャケン", - "meaning": "vehicle inspection" - }, - { - "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": "light motor vehicle (up to 660cc and 64bhp), k-car, kei car" - } - ], - "kunyomiExamples": [ - { - "example": "車", - "reading": "くるま", - "meaning": "car, automobile, vehicle, wheel" - }, - { - "example": "車椅子", - "reading": "くるまいす", - "meaning": "wheelchair, folding push-chair" - }, - { - "example": "火の車", - "reading": "ひのくるま", - "meaning": "fiery chariot (which carries the souls of sinners into hell), desperate financial situation, dire straits" - } - ], - "radical": { - "symbol": "車", - "meaning": "cart, car" + "found": true, + "taughtIn": "grade 1", + "jlptLevel": "N5", + "newspaperFrequencyRank": 333, + "strokeCount": 7, + "meaning": "car", + "kunyomi": [ + "くるま" + ], + "onyomi": [ + "シャ" + ], + "onyomiExamples": [ + { + "example": "車", + "reading": "シャ", + "meaning": "car, vehicle" }, - "parts": [ - "車" - ], - "strokeOrderDiagramUri": "http://classic.jisho.org/static/images/stroke_diagrams/36554_frames.png", - "strokeOrderSvgUri": "http://d1w6u4xc3l95km.cloudfront.net/kanji-2015-03/08eca.svg", - "strokeOrderGifUri": "https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/8eca.gif", - "uri": "http://jisho.org/search/%E8%BB%8A%23kanji" - } + { + "example": "車検", + "reading": "シャケン", + "meaning": "vehicle inspection" + }, + { + "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": "light motor vehicle (up to 660cc and 64bhp), k-car, kei car" + } + ], + "kunyomiExamples": [ + { + "example": "車", + "reading": "くるま", + "meaning": "car, automobile, vehicle, wheel" + }, + { + "example": "車椅子", + "reading": "くるまいす", + "meaning": "wheelchair, folding push-chair" + }, + { + "example": "火の車", + "reading": "ひのくるま", + "meaning": "fiery chariot (which carries the souls of sinners into hell), desperate financial situation, dire straits" + } + ], + "radical": { + "symbol": "車", + "forms": null, + "meaning": "cart, car" + }, + "parts": [ + "車" + ], + "strokeOrderDiagramUri": "https://classic.jisho.org/static/images/stroke_diagrams/36554_frames.png", + "strokeOrderSvgUri": "https://d1w6u4xc3l95km.cloudfront.net/kanji-2015-03/08eca.svg", + "strokeOrderGifUri": "https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/8eca.gif", + "uri": "https://jisho.org/search/%E8%BB%8A%23kanji" } \ No newline at end of file diff --git a/test/kanji_test_cases/1.json b/test/kanji_test_cases/1.json index afe0914..b0a1c9e 100644 --- a/test/kanji_test_cases/1.json +++ b/test/kanji_test_cases/1.json @@ -1,127 +1,125 @@ { "query": "家", - "expectedResult": { - "query": "家", - "found": true, - "taughtIn": "grade 2", - "jlptLevel": "N4", - "newspaperFrequencyRank": "133", - "strokeCount": 10, - "meaning": "house, home, family, professional, expert, performer", - "kunyomi": [ - "いえ", - "や", - "うち" - ], - "onyomi": [ - "カ", - "ケ" - ], - "onyomiExamples": [ - { - "example": "家", - "reading": "カ", - "meaning": "-ist, -er" - }, - { - "example": "家屋", - "reading": "カオク", - "meaning": "house, building" - }, - { - "example": "研究家", - "reading": "ケンキュウカ", - "meaning": "researcher, student (of)" - }, - { - "example": "活動家", - "reading": "カツドウカ", - "meaning": "activist" - }, - { - "example": "家", - "reading": "ケ", - "meaning": "house (e.g. of Tokugawa), family" - }, - { - "example": "家来", - "reading": "ケライ", - "meaning": "retainer, retinue, servant" - }, - { - "example": "本家", - "reading": "ホンケ", - "meaning": "head house (family), birthplace, originator" - }, - { - "example": "公家", - "reading": "クゲ", - "meaning": "court noble, nobility, Imperial Court" - } - ], - "kunyomiExamples": [ - { - "example": "家", - "reading": "いえ", - "meaning": "house, residence, dwelling, family, household, lineage, family name" - }, - { - "example": "家主", - "reading": "やぬし", - "meaning": "landlord, landlady, house owner, home owner, head of the household" - }, - { - "example": "本家", - "reading": "ほんけ", - "meaning": "head house (family), birthplace, originator" - }, - { - "example": "小家", - "reading": "こいえ", - "meaning": "small and simple home" - }, - { - "example": "屋", - "reading": "や", - "meaning": "(something) shop, somebody who sells (something) or works as (something), somebody with a (certain) personality trait, house, roof" - }, - { - "example": "家内", - "reading": "かない", - "meaning": "(my) wife, inside the home, one's family" - }, - { - "example": "長屋", - "reading": "ながや", - "meaning": "tenement house, row house" - }, - { - "example": "本家", - "reading": "ほんけ", - "meaning": "head house (family), birthplace, originator" - }, - { - "example": "家", - "reading": "うち", - "meaning": "house, home (one's own), (one's) family, (one's) household" - }, - { - "example": "家中", - "reading": "うちじゅう", - "meaning": "whole family, all (members of) the family, all over the house, retainer of a daimyo, feudal domain, clan" - } - ], - "radical": { - "symbol": "宀", - "meaning": "roof" + "found": true, + "taughtIn": "grade 2", + "jlptLevel": "N4", + "newspaperFrequencyRank": 133, + "strokeCount": 10, + "meaning": "house, home, family, professional, expert, performer", + "kunyomi": [ + "いえ", + "や", + "うち" + ], + "onyomi": [ + "カ", + "ケ" + ], + "onyomiExamples": [ + { + "example": "家", + "reading": "カ", + "meaning": "-ist, -er" }, - "parts": [ - "宀", - "豕" - ], - "strokeOrderDiagramUri": "http://classic.jisho.org/static/images/stroke_diagrams/23478_frames.png", - "strokeOrderSvgUri": "http://d1w6u4xc3l95km.cloudfront.net/kanji-2015-03/05bb6.svg", - "strokeOrderGifUri": "https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/5bb6.gif", - "uri": "http://jisho.org/search/%E5%AE%B6%23kanji" - } + { + "example": "家屋", + "reading": "カオク", + "meaning": "house, building" + }, + { + "example": "研究家", + "reading": "ケンキュウカ", + "meaning": "researcher, student (of)" + }, + { + "example": "活動家", + "reading": "カツドウカ", + "meaning": "activist" + }, + { + "example": "家", + "reading": "ケ", + "meaning": "house (e.g. of Tokugawa), family" + }, + { + "example": "家来", + "reading": "ケライ", + "meaning": "retainer, retinue, servant" + }, + { + "example": "本家", + "reading": "ホンケ", + "meaning": "head house (family), birthplace, originator" + }, + { + "example": "公家", + "reading": "クゲ", + "meaning": "court noble, nobility, Imperial Court" + } + ], + "kunyomiExamples": [ + { + "example": "家", + "reading": "いえ", + "meaning": "house, residence, dwelling, family, household, lineage, family name" + }, + { + "example": "家主", + "reading": "やぬし", + "meaning": "landlord, landlady, house owner, home owner, head of the household" + }, + { + "example": "本家", + "reading": "ほんけ", + "meaning": "head house (family), birthplace, originator" + }, + { + "example": "小家", + "reading": "こいえ", + "meaning": "small and simple home" + }, + { + "example": "屋", + "reading": "や", + "meaning": "(something) shop, somebody who sells (something) or works as (something), somebody with a (certain) personality trait, house, roof" + }, + { + "example": "家内", + "reading": "かない", + "meaning": "(my) wife, inside the home, one's family" + }, + { + "example": "長屋", + "reading": "ながや", + "meaning": "tenement house, row house" + }, + { + "example": "本家", + "reading": "ほんけ", + "meaning": "head house (family), birthplace, originator" + }, + { + "example": "家", + "reading": "うち", + "meaning": "house, home (one's own), (one's) family, (one's) household" + }, + { + "example": "家中", + "reading": "うちじゅう", + "meaning": "whole family, all (members of) the family, all over the house, retainer of a daimyo, feudal domain, clan" + } + ], + "radical": { + "symbol": "宀", + "forms": null, + "meaning": "roof" + }, + "parts": [ + "宀", + "豕" + ], + "strokeOrderDiagramUri": "https://classic.jisho.org/static/images/stroke_diagrams/23478_frames.png", + "strokeOrderSvgUri": "https://d1w6u4xc3l95km.cloudfront.net/kanji-2015-03/05bb6.svg", + "strokeOrderGifUri": "https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/5bb6.gif", + "uri": "https://jisho.org/search/%E5%AE%B6%23kanji" } \ No newline at end of file diff --git a/test/kanji_test_cases/2.json b/test/kanji_test_cases/2.json index f883db4..6c4e8e2 100644 --- a/test/kanji_test_cases/2.json +++ b/test/kanji_test_cases/2.json @@ -1,99 +1,97 @@ { "query": "楽", - "expectedResult": { - "query": "楽", - "found": true, - "taughtIn": "grade 2", - "jlptLevel": "N4", - "newspaperFrequencyRank": "373", - "strokeCount": 13, - "meaning": "music, comfort, ease", - "kunyomi": [ - "たの.しい", - "たの.しむ", - "この.む" - ], - "onyomi": [ - "ガク", - "ラク", - "ゴウ" - ], - "onyomiExamples": [ - { - "example": "楽団", - "reading": "ガクダン", - "meaning": "orchestra, band" - }, - { - "example": "楽章", - "reading": "ガクショウ", - "meaning": "(musical) movement" - }, - { - "example": "邦楽", - "reading": "ホウガク", - "meaning": "Japanese music (esp. traditional Japanese music)" - }, - { - "example": "室内楽", - "reading": "シツナイガク", - "meaning": "chamber music" - }, - { - "example": "楽", - "reading": "ラク", - "meaning": "comfort, ease, relief, (at) peace, relaxation, easy, simple, without trouble, without hardships, (economically) comfortable, raku pottery" - }, - { - "example": "楽園", - "reading": "ラクエン", - "meaning": "pleasure garden, paradise" - }, - { - "example": "千秋楽", - "reading": "センシュウラク", - "meaning": "concluding festivities, concluding program, concluding programme, final day of a tournament" - }, - { - "example": "行楽", - "reading": "コウラク", - "meaning": "outing, excursion, pleasure trip, going on a picnic" - }, - { - "example": "猿楽", - "reading": "サルガク", - "meaning": "sarugaku (form of theatre popular in Japan during the 11th to 14th centuries), noh, fooling around" - } - ], - "kunyomiExamples": [ - { - "example": "楽しい", - "reading": "たのしい", - "meaning": "enjoyable, fun, pleasant, happy, delightful" - }, - { - "example": "楽しい思い出", - "reading": "たのしいおもいで", - "meaning": "happy memory, sweet memory" - }, - { - "example": "楽しむ", - "reading": "たのしむ", - "meaning": "to enjoy (oneself)" - } - ], - "radical": { - "symbol": "木", - "meaning": "tree" + "found": true, + "taughtIn": "grade 2", + "jlptLevel": "N4", + "newspaperFrequencyRank": 373, + "strokeCount": 13, + "meaning": "music, comfort, ease", + "kunyomi": [ + "たの.しい", + "たの.しむ", + "この.む" + ], + "onyomi": [ + "ガク", + "ラク", + "ゴウ" + ], + "onyomiExamples": [ + { + "example": "楽団", + "reading": "ガクダン", + "meaning": "orchestra, band" }, - "parts": [ - "冫", - "木", - "白" - ], - "strokeOrderDiagramUri": "http://classic.jisho.org/static/images/stroke_diagrams/27005_frames.png", - "strokeOrderSvgUri": "http://d1w6u4xc3l95km.cloudfront.net/kanji-2015-03/0697d.svg", - "strokeOrderGifUri": "https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/697d.gif", - "uri": "http://jisho.org/search/%E6%A5%BD%23kanji" - } + { + "example": "楽章", + "reading": "ガクショウ", + "meaning": "(musical) movement" + }, + { + "example": "邦楽", + "reading": "ホウガク", + "meaning": "Japanese music (esp. traditional Japanese music)" + }, + { + "example": "室内楽", + "reading": "シツナイガク", + "meaning": "chamber music" + }, + { + "example": "楽", + "reading": "ラク", + "meaning": "comfort, ease, relief, (at) peace, relaxation, easy, simple, without trouble, without hardships, (economically) comfortable, raku pottery" + }, + { + "example": "楽園", + "reading": "ラクエン", + "meaning": "pleasure garden, paradise" + }, + { + "example": "千秋楽", + "reading": "センシュウラク", + "meaning": "concluding festivities, concluding program, concluding programme, final day of a tournament" + }, + { + "example": "行楽", + "reading": "コウラク", + "meaning": "outing, excursion, pleasure trip, going on a picnic" + }, + { + "example": "猿楽", + "reading": "サルガク", + "meaning": "sarugaku (form of theatre popular in Japan during the 11th to 14th centuries), noh, fooling around" + } + ], + "kunyomiExamples": [ + { + "example": "楽しい", + "reading": "たのしい", + "meaning": "enjoyable, fun, pleasant, happy, delightful" + }, + { + "example": "楽しい思い出", + "reading": "たのしいおもいで", + "meaning": "happy memory, sweet memory" + }, + { + "example": "楽しむ", + "reading": "たのしむ", + "meaning": "to enjoy (oneself)" + } + ], + "radical": { + "symbol": "木", + "forms": null, + "meaning": "tree" + }, + "parts": [ + "冫", + "木", + "白" + ], + "strokeOrderDiagramUri": "https://classic.jisho.org/static/images/stroke_diagrams/27005_frames.png", + "strokeOrderSvgUri": "https://d1w6u4xc3l95km.cloudfront.net/kanji-2015-03/0697d.svg", + "strokeOrderGifUri": "https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/697d.gif", + "uri": "https://jisho.org/search/%E6%A5%BD%23kanji" } \ No newline at end of file diff --git a/test/kanji_test_cases/3.json b/test/kanji_test_cases/3.json index 8910cea..4c37adb 100644 --- a/test/kanji_test_cases/3.json +++ b/test/kanji_test_cases/3.json @@ -1,7 +1,19 @@ { "query": "極上", - "expectedResult": { - "query": "極上", - "found": false - } + "found": false, + "taughtIn": null, + "jlptLevel": null, + "newspaperFrequencyRank": null, + "strokeCount": null, + "meaning": null, + "kunyomi": null, + "onyomi": null, + "onyomiExamples": null, + "kunyomiExamples": null, + "radical": null, + "parts": null, + "strokeOrderDiagramUri": null, + "strokeOrderSvgUri": null, + "strokeOrderGifUri": null, + "uri": null } \ No newline at end of file diff --git a/test/kanji_test_cases/4.json b/test/kanji_test_cases/4.json index 900c53c..d841c96 100644 --- a/test/kanji_test_cases/4.json +++ b/test/kanji_test_cases/4.json @@ -1,52 +1,53 @@ { "query": "贄", - "expectedResult": { - "query": "贄", - "found": true, - "strokeCount": 18, - "meaning": "offering, sacrifice", - "kunyomi": [ - "にえ" - ], - "onyomi": [ - "シ" - ], - "onyomiExamples": [], - "kunyomiExamples": [ - { - "example": "贄", - "reading": "にえ", - "meaning": "offering (to the gods, emperor, etc.), gift, sacrifice" - }, - { - "example": "早贄", - "reading": "はやにえ", - "meaning": "butcher-bird prey impaled on twigs, thorns, etc. for later consumption, first offering of the season" - }, - { - "example": "百舌の早贄", - "reading": "もずのはやにえ", - "meaning": "butcher-bird prey impaled on twigs, thorns, etc. for later consumption" - } - ], - "radical": { - "symbol": "貝", - "meaning": "shell" + "found": true, + "taughtIn": null, + "jlptLevel": null, + "newspaperFrequencyRank": null, + "strokeCount": 18, + "meaning": "offering, sacrifice", + "kunyomi": [ + "にえ" + ], + "onyomi": [ + "シ" + ], + "onyomiExamples": [], + "kunyomiExamples": [ + { + "example": "贄", + "reading": "にえ", + "meaning": "offering (to the gods, emperor, etc.), gift, sacrifice" }, - "parts": [ - "ハ", - "丶", - "九", - "亠", - "十", - "目", - "立", - "貝", - "辛" - ], - "strokeOrderDiagramUri": "http://classic.jisho.org/static/images/stroke_diagrams/36100_frames.png", - "strokeOrderSvgUri": "http://d1w6u4xc3l95km.cloudfront.net/kanji-2015-03/08d04.svg", - "strokeOrderGifUri": "https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/8d04.gif", - "uri": "http://jisho.org/search/%E8%B4%84%23kanji" - } + { + "example": "早贄", + "reading": "はやにえ", + "meaning": "butcher-bird prey impaled on twigs, thorns, etc. for later consumption, first offering of the season" + }, + { + "example": "百舌の早贄", + "reading": "もずのはやにえ", + "meaning": "butcher-bird prey impaled on twigs, thorns, etc. for later consumption" + } + ], + "radical": { + "symbol": "貝", + "forms": null, + "meaning": "shell" + }, + "parts": [ + "ハ", + "丶", + "九", + "亠", + "十", + "目", + "立", + "貝", + "辛" + ], + "strokeOrderDiagramUri": "https://classic.jisho.org/static/images/stroke_diagrams/36100_frames.png", + "strokeOrderSvgUri": "https://d1w6u4xc3l95km.cloudfront.net/kanji-2015-03/08d04.svg", + "strokeOrderGifUri": "https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/8d04.gif", + "uri": "https://jisho.org/search/%E8%B4%84%23kanji" } \ No newline at end of file diff --git a/test/kanji_test_cases/5.json b/test/kanji_test_cases/5.json index d393d0a..5d3c8c7 100644 --- a/test/kanji_test_cases/5.json +++ b/test/kanji_test_cases/5.json @@ -1,7 +1,19 @@ { "query": "ネガティブ", - "expectedResult": { - "query": "ネガティブ", - "found": false - } + "found": false, + "taughtIn": null, + "jlptLevel": null, + "newspaperFrequencyRank": null, + "strokeCount": null, + "meaning": null, + "kunyomi": null, + "onyomi": null, + "onyomiExamples": null, + "kunyomiExamples": null, + "radical": null, + "parts": null, + "strokeOrderDiagramUri": null, + "strokeOrderSvgUri": null, + "strokeOrderGifUri": null, + "uri": null } \ No newline at end of file diff --git a/test/kanji_test_cases/6.json b/test/kanji_test_cases/6.json index ae8f5b4..29815f2 100644 --- a/test/kanji_test_cases/6.json +++ b/test/kanji_test_cases/6.json @@ -1,7 +1,19 @@ { "query": "wegmwrlgkrgmg", - "expectedResult": { - "query": "wegmwrlgkrgmg", - "found": false - } + "found": false, + "taughtIn": null, + "jlptLevel": null, + "newspaperFrequencyRank": null, + "strokeCount": null, + "meaning": null, + "kunyomi": null, + "onyomi": null, + "onyomiExamples": null, + "kunyomiExamples": null, + "radical": null, + "parts": null, + "strokeOrderDiagramUri": null, + "strokeOrderSvgUri": null, + "strokeOrderGifUri": null, + "uri": null } \ No newline at end of file diff --git a/test/kanji_test_cases/7.json b/test/kanji_test_cases/7.json index 3bc2ead..736c73d 100644 --- a/test/kanji_test_cases/7.json +++ b/test/kanji_test_cases/7.json @@ -1,78 +1,75 @@ { "query": "水", - "expectedResult": { - "query": "水", - "found": true, - "taughtIn": "grade 1", - "jlptLevel": "N5", - "newspaperFrequencyRank": "223", - "strokeCount": 4, - "meaning": "water", - "kunyomi": [ - "みず", - "みず-" - ], - "onyomi": [ - "スイ" - ], - "onyomiExamples": [ - { - "example": "水", - "reading": "スイ", - "meaning": "Wednesday, shaved ice (served with flavored syrup), water (fifth of the five elements)" - }, - { - "example": "水位", - "reading": "スイイ", - "meaning": "water level" - }, - { - "example": "用水", - "reading": "ヨウスイ", - "meaning": "irrigation water, water for fire, city water, cistern water" - }, - { - "example": "浄水", - "reading": "ジョウスイ", - "meaning": "clean water" - } - ], - "kunyomiExamples": [ - { - "example": "水", - "reading": "みず", - "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": "drinking water, potable water" - }, - { - "example": "呼び水", - "reading": "よびみず", - "meaning": "pump-priming, rousing, stimulation" - } - ], - "radical": { - "symbol": "水", - "forms": [ - "氵", - "氺" - ], - "meaning": "water" + "found": true, + "taughtIn": "grade 1", + "jlptLevel": "N5", + "newspaperFrequencyRank": 223, + "strokeCount": 4, + "meaning": "water", + "kunyomi": [ + "みず", + "みず-" + ], + "onyomi": [ + "スイ" + ], + "onyomiExamples": [ + { + "example": "水", + "reading": "スイ", + "meaning": "Wednesday, shaved ice (served with flavored syrup), water (fifth of the five elements)" }, - "parts": [ - "水" + { + "example": "水位", + "reading": "スイイ", + "meaning": "water level" + }, + { + "example": "用水", + "reading": "ヨウスイ", + "meaning": "irrigation water, water for fire, city water, cistern water" + }, + { + "example": "浄水", + "reading": "ジョウスイ", + "meaning": "clean water" + } + ], + "kunyomiExamples": [ + { + "example": "水", + "reading": "みず", + "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": "drinking water, potable water" + }, + { + "example": "呼び水", + "reading": "よびみず", + "meaning": "pump-priming, rousing, stimulation" + } + ], + "radical": { + "symbol": "水", + "forms": [ + "氵", + "氺" ], - "strokeOrderDiagramUri": "http://classic.jisho.org/static/images/stroke_diagrams/27700_frames.png", - "strokeOrderSvgUri": "http://d1w6u4xc3l95km.cloudfront.net/kanji-2015-03/06c34.svg", - "strokeOrderGifUri": "https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/6c34.gif", - "uri": "http://jisho.org/search/%E6%B0%B4%23kanji" - } + "meaning": "water" + }, + "parts": [ + "水" + ], + "strokeOrderDiagramUri": "https://classic.jisho.org/static/images/stroke_diagrams/27700_frames.png", + "strokeOrderSvgUri": "https://d1w6u4xc3l95km.cloudfront.net/kanji-2015-03/06c34.svg", + "strokeOrderGifUri": "https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/6c34.gif", + "uri": "https://jisho.org/search/%E6%B0%B4%23kanji" } \ No newline at end of file diff --git a/test/local_function_test_cases.dart b/test/local_function_test_cases.dart deleted file mode 100644 index d02c1e3..0000000 --- a/test/local_function_test_cases.dart +++ /dev/null @@ -1,293 +0,0 @@ -import 'package:unofficial_jisho_api/src/objects.dart'; -import 'package:unofficial_jisho_api/unofficial_jisho_api.dart'; - -import 'package:test/test.dart'; -import 'dart:convert'; -import 'package:http/http.dart' as http; - -void test_local_functions() async { - - -/* KANJI SEARCH FUNCTION TESTS START */ - - test('removeNewLines', () { - final result = removeNewlines('Line \nwith\r\n Newlines and spaces\n'); - expect(result, 'Line with Newlines and spaces'); - }); - - test('uriForKanjiSearch', () { - final result = uriForKanjiSearch('時'); - expect(result, 'http://jisho.org/search/%E6%99%82%23kanji'); - }); - - test('getUriForStrokeOrderDiagram', () { - final result = getUriForStrokeOrderDiagram('時'); - expect(result, 'http://classic.jisho.org/static/images/stroke_diagrams/26178_frames.png'); - }); - - test('uriForPhraseSearch', () { - final result = uriForPhraseSearch('時間'); - expect(result, 'http://jisho.org/api/v1/search/words?keyword=%E6%99%82%E9%96%93'); - }); - - final kanjiPage = (await http.get('http://jisho.org/search/%E6%99%82%23kanji')).body; - - test('containsKanjiGlyph', () { - final result = containsKanjiGlyph(kanjiPage, '時'); - expect(result, true); - }); - - test('getStringBetweenIndicies', () { - final result = getStringBetweenIndicies('String\n\rwith\nNewlines', 3, 9); - expect(result, 'ingw'); - }); - - test('getStringBetweenStrings', () { - const data = 'STArT I want this string END'; - final result = getStringBetweenStrings(data, 'STArT', 'END'); - expect(result, ' I want this string '); - }); - - test('getIntBetweenStrings', () { - final result = getIntBetweenStrings(kanjiPage, '', ' strokes'); - expect(result, 10); - }); - - test('getAllGlobalGroupMatches', () { - - }); - - test('parseAnchorsToArray', () { - const htmlCode = - ''' -
    - '''; - - final result = parseAnchorsToArray(htmlCode); - expect(result, [ - 'Hello', 'Hi', 'How are you doing']); - }); - - test('getYomi', () { - final result = getYomi(kanjiPage, 'On'); - expect(result, ['ジ']); - - }); - - test('getKunyomi', () { - final result = getKunyomi(kanjiPage); - expect(result, ['とき', '-どき']); - }); - - test('getOnyomi', () { - final result = getOnyomi(kanjiPage); - expect(result, ['ジ']); - }); - - test('getYomiExamples', () { - final result = getYomiExamples(kanjiPage, 'On'); - expect( - json.encode(result), - json.encode([ - YomiExample( - example: '時', - reading: 'ジ', - meaning: '''hour, o'clock, (specified) time, when ..., during ...''' - ), - YomiExample( - example: '時価', - reading: 'ジカ', - meaning: 'current value, price, market value' - ), - YomiExample( - example: '零時', - reading: 'レイジ', - meaning: '''twelve o'clock, midnight, noon''' - ), - YomiExample( - example: '平時', - reading: 'ヘイジ', - meaning: 'peacetime, time of peace, ordinary times, normal times' - ), - ]) - ); - }); - - test('getOnyomiExamples', () { - final result = getOnyomiExamples(kanjiPage); - expect( - json.encode(result), - json.encode([ - YomiExample( - example: '時', - reading: 'ジ', - meaning: '''hour, o'clock, (specified) time, when ..., during ...''' - ), - YomiExample( - example: '時価', - reading: 'ジカ', - meaning: 'current value, price, market value' - ), - YomiExample( - example: '零時', - reading: 'レイジ', - meaning: '''twelve o'clock, midnight, noon''' - ), - YomiExample( - example: '平時', - reading: 'ヘイジ', - meaning: 'peacetime, time of peace, ordinary times, normal times' - ), - ]) - ); - }); - - test('getKunyomiExamples', () { - final result = getKunyomiExamples(kanjiPage); - expect( - json.encode(result), - json.encode([ - YomiExample( - example: '時', - reading: 'とき', - meaning: 'time, hour, moment, occasion, case, chance, opportunity, season, the times, the age, the day, tense' - ), - YomiExample( - example: '時折', - reading: 'ときおり', - meaning: 'sometimes' - ), - YomiExample( - example: '切り替え時', - reading: 'きりかえとき', - meaning: 'time to switch over, response time' - ), - YomiExample( - example: '逢魔が時', - reading: 'おうまがとき', - meaning: '''twilight, time for disasters (similar to 'the witching hour' but not midnight)''' - ), - ]) - ); - }); - - test('getRadical', () { - final result = getRadical(kanjiPage); - expect( - json.encode(result), - json.encode(Radical( - symbol: '日', - meaning: 'sun, day' - )) - ); - }); - - test('getParts', () { - final result = getParts(kanjiPage); - expect(result, ['土', '寸', '日']); - }); - - test('getSvgUri', () { - final result = getSvgUri(kanjiPage); - expect(result, 'http://d1w6u4xc3l95km.cloudfront.net/kanji-2015-03/06642.svg'); - }); - - test('getGifUri', () { - final result = getGifUri(kanjiPage); - expect(result, 'https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/3c.gif'); - }); - - test('getNewspaperFrequencyRank', () { - final result = getNewspaperFrequencyRank(kanjiPage); - expect(result, 16); - }); - - test('parseKanjiPageData', () { - final result = parseKanjiPageData(kanjiPage, '時'); - - final expectedResult = KanjiResult(); - expectedResult.query = '時'; - expectedResult.found = true; - expectedResult.taughtIn = 'grade 2'; - expectedResult.jlptLevel = 'N5'; - expectedResult.newspaperFrequencyRank = 16; - expectedResult.strokeCount = 10; - expectedResult.meaning = 'time, hour'; - expectedResult.kunyomi = ['とき', '-どき']; - expectedResult.onyomi = ['ジ']; - expectedResult.onyomiExamples = - [ - YomiExample( - example: '時', - reading: 'ジ', - meaning: '''hour, o'clock, (specified) time, when ..., during ...''' - ), - YomiExample( - example: '時価', - reading: 'ジカ', - meaning: 'current value, price, market value' - ), - YomiExample( - example: '零時', - reading: 'レイジ', - meaning: '''twelve o'clock, midnight, noon''' - ), - YomiExample( - example: '平時', - reading: 'ヘイジ', - meaning: 'peacetime, time of peace, ordinary times, normal times' - ), - ]; - expectedResult.kunyomiExamples = - [ - YomiExample( - example: '時', - reading: 'とき', - meaning: 'time, hour, moment, occasion, case, chance, opportunity, season, the times, the age, the day, tense' - ), - YomiExample( - example: '時折', - reading: 'ときおり', - meaning: 'sometimes' - ), - YomiExample( - example: '切り替え時', - reading: 'きりかえとき', - meaning: 'time to switch over, response time' - ), - YomiExample( - example: '逢魔が時', - reading: 'おうまがとき', - meaning: '''twilight, time for disasters (similar to 'the witching hour' but not midnight)''' - ), - ]; - expectedResult.radical = - Radical( - symbol: '日', - meaning: 'sun, day' - ); - expectedResult.parts = ['土', '寸', '日']; - expectedResult.strokeOrderDiagramUri = 'http://classic.jisho.org/static/images/stroke_diagrams/26178_frames.png'; - expectedResult.strokeOrderSvgUri = 'http://d1w6u4xc3l95km.cloudfront.net/kanji-2015-03/06642.svg'; - expectedResult.strokeOrderGifUri = 'https://raw.githubusercontent.com/mistval/kanji_images/master/gifs/6642.gif'; - expectedResult.uri = 'http://jisho.org/search/%E6%99%82%23kanji'; - - expect( - json.encode(result), - json.encode(expectedResult) - ); - }); - - /* KANJI SEARCH FUNCTION TESTS END */ - -} \ No newline at end of file diff --git a/test/phrase_scrape_test_cases/0.json b/test/phrase_scrape_test_cases/0.json index 0fc210c..0fa1e1d 100644 --- a/test/phrase_scrape_test_cases/0.json +++ b/test/phrase_scrape_test_cases/0.json @@ -1,100 +1,97 @@ { + "found": true, "query": "車", - "expectedResult": { - "found": true, - "query": "車", - "uri": "https://jisho.org/word/%E8%BB%8A", - "tags": [ - "Common word", - "JLPT N5", - "Wanikani level 4" - ], - "meanings": [ - { - "seeAlsoTerms": [], - "sentences": [ - { - "english": "You cannot be too careful when you drive a car.", - "japanese": "車を運転する時はいくら注意してもしすぎることはない。", - "pieces": [ - { - "lifted": "くるま", - "unlifted": "車" - }, - { - "lifted": "", - "unlifted": "を" - }, - { - "lifted": "うんてん", - "unlifted": "運転" - }, - { - "lifted": "", - "unlifted": "する" - }, - { - "lifted": "とき", - "unlifted": "時" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "", - "unlifted": "いくら" - }, - { - "lifted": "ちゅうい", - "unlifted": "注意" - }, - { - "lifted": "", - "unlifted": "して" - }, - { - "lifted": "", - "unlifted": "も" - }, - { - "lifted": "", - "unlifted": "しすぎる" - }, - { - "lifted": "", - "unlifted": "こと" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "", - "unlifted": "ない" - } - ] - } - ], - "definition": "car; automobile; vehicle", - "supplemental": [], - "definitionAbstract": "", - "tags": [ - "noun" - ] - }, - { - "seeAlsoTerms": [], - "sentences": [], - "definition": "wheel", - "supplemental": [], - "definitionAbstract": "", - "tags": [ - "noun" - ] - } - ], - "otherForms": [], - "notes": [] - } + "uri": "https://jisho.org/word/%E8%BB%8A", + "tags": [ + "Common word", + "JLPT N5", + "Wanikani level 4" + ], + "meanings": [ + { + "seeAlsoTerms": [], + "sentences": [ + { + "english": "You cannot be too careful when you drive a car.", + "japanese": "車を運転する時はいくら注意してもしすぎることはない。", + "pieces": [ + { + "lifted": "くるま", + "unlifted": "車" + }, + { + "lifted": null, + "unlifted": "を" + }, + { + "lifted": "うんてん", + "unlifted": "運転" + }, + { + "lifted": null, + "unlifted": "する" + }, + { + "lifted": "とき", + "unlifted": "時" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": null, + "unlifted": "いくら" + }, + { + "lifted": "ちゅうい", + "unlifted": "注意" + }, + { + "lifted": null, + "unlifted": "して" + }, + { + "lifted": null, + "unlifted": "も" + }, + { + "lifted": null, + "unlifted": "しすぎる" + }, + { + "lifted": null, + "unlifted": "こと" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": null, + "unlifted": "ない" + } + ] + } + ], + "definition": "car; automobile; vehicle", + "supplemental": [], + "definitionAbstract": null, + "tags": [ + "noun" + ] + }, + { + "seeAlsoTerms": [], + "sentences": [], + "definition": "wheel", + "supplemental": [], + "definitionAbstract": null, + "tags": [ + "noun" + ] + } + ], + "otherForms": [], + "notes": [] } \ No newline at end of file diff --git a/test/phrase_scrape_test_cases/1.json b/test/phrase_scrape_test_cases/1.json index f67f673..2ab07b4 100644 --- a/test/phrase_scrape_test_cases/1.json +++ b/test/phrase_scrape_test_cases/1.json @@ -1,40 +1,37 @@ { + "found": true, "query": "日本人", - "expectedResult": { - "found": true, - "query": "日本人", - "uri": "https://jisho.org/word/%E6%97%A5%E6%9C%AC%E4%BA%BA", - "tags": [ - "Common word" - ], - "meanings": [ - { - "seeAlsoTerms": [], - "sentences": [], - "definition": "Japanese person; Japanese people", - "supplemental": [], - "definitionAbstract": "", - "tags": [ - "noun" - ] - }, - { - "seeAlsoTerms": [], - "sentences": [], - "definition": "Japanese people", - "supplemental": [], - "definitionAbstract": "The Japanese people are a nationality originating in the Japanese archipelago and are the predominant ethnic group of Japan. Worldwide, approximately 130 million people are of Japanese descent; of these, approximately 127 million are residents of Japan. People of Japanese ancestry who live in other countries are referred to as nikkeijin . The term ethnic Japanese may also be used in some contexts to refer to a locus of ethnic groups including the Yamato, Ainu and Ryukyuan people.", - "tags": [ - "wikipedia definition" - ] - } - ], - "otherForms": [ - { - "kanji": "日本人", - "kana": "にっぽんじん" - } - ], - "notes": [] - } + "uri": "https://jisho.org/word/%E6%97%A5%E6%9C%AC%E4%BA%BA", + "tags": [ + "Common word" + ], + "meanings": [ + { + "seeAlsoTerms": [], + "sentences": [], + "definition": "Japanese person; Japanese people", + "supplemental": [], + "definitionAbstract": null, + "tags": [ + "noun" + ] + }, + { + "seeAlsoTerms": [], + "sentences": [], + "definition": "Japanese people", + "supplemental": [], + "definitionAbstract": "The Japanese people are a nationality originating in the Japanese archipelago and are the predominant ethnic group of Japan. Worldwide, approximately 130 million people are of Japanese descent; of these, approximately 127 million are residents of Japan. People of Japanese ancestry who live in other countries are referred to as nikkeijin . The term ethnic Japanese may also be used in some contexts to refer to a locus of ethnic groups including the Yamato, Ainu and Ryukyuan people.", + "tags": [ + "wikipedia definition" + ] + } + ], + "otherForms": [ + { + "kanji": "日本人", + "kana": "にっぽんじん" + } + ], + "notes": [] } \ No newline at end of file diff --git a/test/phrase_scrape_test_cases/2.json b/test/phrase_scrape_test_cases/2.json index f5d463b..3d2ed78 100644 --- a/test/phrase_scrape_test_cases/2.json +++ b/test/phrase_scrape_test_cases/2.json @@ -1,135 +1,132 @@ { + "found": true, "query": "皆", - "expectedResult": { - "found": true, - "query": "皆", - "uri": "https://jisho.org/word/%E7%9A%86", - "tags": [ - "Common word", - "JLPT N5" - ], - "meanings": [ - { - "seeAlsoTerms": [], - "sentences": [ - { - "english": "The people which were here have all gone.", - "japanese": "ここにいた人々はみんな行ってしまった。", - "pieces": [ - { - "lifted": "", - "unlifted": "ここ" - }, - { - "lifted": "", - "unlifted": "に" - }, - { - "lifted": "", - "unlifted": "いた" - }, - { - "lifted": "ひとびと", - "unlifted": "人々" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "", - "unlifted": "みんな" - }, - { - "lifted": "い", - "unlifted": "行って" - }, - { - "lifted": "", - "unlifted": "しまった" - } - ] - } - ], - "definition": "all; everyone; everybody", - "supplemental": [ - "Usually written using kana alone" - ], - "definitionAbstract": "", - "tags": [ - "adverb", - "noun" - ] - }, - { - "seeAlsoTerms": [], - "sentences": [ - { - "english": "All the dinner had been eaten before he came.", - "japanese": "ごちそうはみんな彼が来ないうちに食べられてしまった。", - "pieces": [ - { - "lifted": "", - "unlifted": "ごちそう" - }, - { - "lifted": "", - "unlifted": "は" - }, - { - "lifted": "", - "unlifted": "みんな" - }, - { - "lifted": "かれ", - "unlifted": "彼" - }, - { - "lifted": "", - "unlifted": "が" - }, - { - "lifted": "らい", - "unlifted": "来" - }, - { - "lifted": "", - "unlifted": "ないうちに" - }, - { - "lifted": "た", - "unlifted": "食べられて" - }, - { - "lifted": "", - "unlifted": "しまった" - } - ] - } - ], - "definition": "everything", - "supplemental": [ - "Usually written using kana alone" - ], - "definitionAbstract": "", - "tags": [ - "adverb", - "noun" - ] - } - ], - "otherForms": [ - { - "kanji": "皆んな", - "kana": "みんな" - }, - { - "kanji": "皆", - "kana": "みな" - } - ], - "notes": [ - "皆んな: Irregular okurigana usage." - ] - } + "uri": "https://jisho.org/word/%E7%9A%86", + "tags": [ + "Common word", + "JLPT N5" + ], + "meanings": [ + { + "seeAlsoTerms": [], + "sentences": [ + { + "english": "The people which were here have all gone.", + "japanese": "ここにいた人々はみんな行ってしまった。", + "pieces": [ + { + "lifted": null, + "unlifted": "ここ" + }, + { + "lifted": null, + "unlifted": "に" + }, + { + "lifted": null, + "unlifted": "いた" + }, + { + "lifted": "ひとびと", + "unlifted": "人々" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": null, + "unlifted": "みんな" + }, + { + "lifted": "い", + "unlifted": "行って" + }, + { + "lifted": null, + "unlifted": "しまった" + } + ] + } + ], + "definition": "all; everyone; everybody", + "supplemental": [ + "Usually written using kana alone" + ], + "definitionAbstract": null, + "tags": [ + "adverb", + "noun" + ] + }, + { + "seeAlsoTerms": [], + "sentences": [ + { + "english": "All the dinner had been eaten before he came.", + "japanese": "ごちそうはみんな彼が来ないうちに食べられてしまった。", + "pieces": [ + { + "lifted": null, + "unlifted": "ごちそう" + }, + { + "lifted": null, + "unlifted": "は" + }, + { + "lifted": null, + "unlifted": "みんな" + }, + { + "lifted": "かれ", + "unlifted": "彼" + }, + { + "lifted": null, + "unlifted": "が" + }, + { + "lifted": "らい", + "unlifted": "来" + }, + { + "lifted": null, + "unlifted": "ないうちに" + }, + { + "lifted": "た", + "unlifted": "食べられて" + }, + { + "lifted": null, + "unlifted": "しまった" + } + ] + } + ], + "definition": "everything", + "supplemental": [ + "Usually written using kana alone" + ], + "definitionAbstract": null, + "tags": [ + "adverb", + "noun" + ] + } + ], + "otherForms": [ + { + "kanji": "皆んな", + "kana": "みんな" + }, + { + "kanji": "皆", + "kana": "みな" + } + ], + "notes": [ + "皆んな: Irregular okurigana usage." + ] } \ No newline at end of file diff --git a/test/phrase_scrape_test_cases/3.json b/test/phrase_scrape_test_cases/3.json index c66f9ae..dcc45ae 100644 --- a/test/phrase_scrape_test_cases/3.json +++ b/test/phrase_scrape_test_cases/3.json @@ -1,69 +1,69 @@ { + "found": true, "query": "ネガティブ", - "expectedResult": { - "found": true, - "query": "ネガティブ", - "uri": "https://jisho.org/word/%E3%83%8D%E3%82%AC%E3%83%86%E3%82%A3%E3%83%96", - "tags": [ - "Common word" - ], - "meanings": [ - { - "seeAlsoTerms": [], - "sentences": [], - "definition": "negative (e.g. thinking)", - "supplemental": [ - "Antonym: ポジティブ" - ], - "definitionAbstract": "", - "tags": [ - "na-adjective" - ] - }, - { - "seeAlsoTerms": [], - "sentences": [], - "definition": "negative (photography)", - "supplemental": [], - "definitionAbstract": "", - "tags": [ - "noun" - ] - }, - { - "seeAlsoTerms": [ - "陰極" - ], - "sentences": [], - "definition": "negative (electrical polarity)", - "supplemental": [], - "definitionAbstract": "", - "tags": [ - "noun" - ] - }, - { - "seeAlsoTerms": [], - "sentences": [], - "definition": "Negative (Finnish band)", - "supplemental": [], - "definitionAbstract": "Negative is a Finnish glam rock band founded at the end of 1997. Members of Negative cite musical influence such as Guns N' Roses, Queen, and Hanoi Rocks. The band itself labels the music as ”emotional rock’n roll”.", - "tags": [ - "wikipedia definition" - ] - } - ], - "otherForms": [ - { - "kanji": "ネガティヴ" - }, - { - "kanji": "ネガチブ" - }, - { - "kanji": "ネガチィブ" - } - ], - "notes": [] - } + "uri": "https://jisho.org/word/%E3%83%8D%E3%82%AC%E3%83%86%E3%82%A3%E3%83%96", + "tags": [ + "Common word" + ], + "meanings": [ + { + "seeAlsoTerms": [], + "sentences": [], + "definition": "negative (e.g. thinking)", + "supplemental": [ + "Antonym: ポジティブ" + ], + "definitionAbstract": null, + "tags": [ + "na-adjective" + ] + }, + { + "seeAlsoTerms": [], + "sentences": [], + "definition": "negative (photography)", + "supplemental": [], + "definitionAbstract": null, + "tags": [ + "noun" + ] + }, + { + "seeAlsoTerms": [ + "陰極" + ], + "sentences": [], + "definition": "negative (electrical polarity)", + "supplemental": [], + "definitionAbstract": null, + "tags": [ + "noun" + ] + }, + { + "seeAlsoTerms": [], + "sentences": [], + "definition": "Negative (Finnish band)", + "supplemental": [], + "definitionAbstract": "Negative is a Finnish glam rock band founded at the end of 1997. Members of Negative cite musical influence such as Guns N' Roses, Queen, and Hanoi Rocks. The band itself labels the music as ”emotional rock’n roll”.", + "tags": [ + "wikipedia definition" + ] + } + ], + "otherForms": [ + { + "kanji": "ネガティヴ", + "kana": null + }, + { + "kanji": "ネガチブ", + "kana": null + }, + { + "kanji": "ネガチィブ", + "kana": null + } + ], + "notes": [] } \ No newline at end of file diff --git a/test/phrase_scrape_test_cases/4.json b/test/phrase_scrape_test_cases/4.json index 5139c41..43b08bc 100644 --- a/test/phrase_scrape_test_cases/4.json +++ b/test/phrase_scrape_test_cases/4.json @@ -1,7 +1,9 @@ { + "found": false, "query": "grlgmregmneriireg", - "expectedResult": { - "query": "grlgmregmneriireg", - "found": false - } + "uri": null, + "tags": null, + "meanings": null, + "otherForms": null, + "notes": null } \ No newline at end of file diff --git a/test/unofficial_jisho_api_test.dart b/test/unofficial_jisho_api_test.dart index fd570b0..4d476e1 100644 --- a/test/unofficial_jisho_api_test.dart +++ b/test/unofficial_jisho_api_test.dart @@ -3,7 +3,6 @@ import 'package:path/path.dart' as path; import 'dart:convert'; import 'package:unofficial_jisho_api/unofficial_jisho_api.dart'; -import 'local_function_test_cases.dart' show test_local_functions; import 'package:test/test.dart'; final jisho = JishoApi(); @@ -14,41 +13,19 @@ List getFilePaths(String dirname) { return filenames.map((filename) => path.join(currentdir, 'test', dirname, filename.path)).toList(); } -void runTestCases(List testCaseFiles, String apiFunction) async { +void runTestCases(List testCaseFiles, Function apiFunction) async { for (var testCount = 0; testCount < testCaseFiles.length; testCount++) { final file = await File(testCaseFiles[testCount]).readAsString(); final testCase = jsonDecode(file); await test('Test ${testCount}', () async { - switch(apiFunction) { - case 'searchForKanji': { - final result = await jisho.searchForKanji(testCase['query']); - expect(result.toJson(), testCase['expectedResult']); - break; - } - case 'searchForExamples': { - final result = await jisho.searchForExamples(testCase['query']); - expect(result, testCase['expectedResult']); - break; - } - case 'scrapeForPhrase': { - final result = await jisho.scrapeForPhrase(testCase['query']); - expect(result, testCase['expectedResult']); - break; - } - throw 'No API function provided'; - } + final result = await apiFunction(testCase['query']); + expect(jsonEncode(result), jsonEncode(testCase)); }); } } void main() async { - - await test_local_functions(); - - await runTestCases(getFilePaths('kanji_test_cases'), 'searchForKanji'); - - await runTestCases(getFilePaths('example_test_cases'), 'searchForExamples'); - - await runTestCases(getFilePaths('phrase_scrape_test_cases'), 'scrapeForPhrase'); - + await runTestCases(getFilePaths('kanji_test_cases'), jisho.searchForKanji); + await runTestCases(getFilePaths('example_test_cases'), jisho.searchForExamples); + await runTestCases(getFilePaths('phrase_scrape_test_cases'), jisho.scrapeForPhrase); }