Update todos

This commit is contained in:
Oystein Kristoffer Tveit 2020-06-22 14:00:24 +02:00
parent 93e34ec3f9
commit 72d39bea55
1 changed files with 7 additions and 4 deletions

View File

@ -7,8 +7,6 @@ import 'package:html/dom.dart';
final htmlUnescape = html_entities.HtmlUnescape(); final htmlUnescape = html_entities.HtmlUnescape();
// TODO: Put public facing types in this file.
const String JISHO_API = 'https://jisho.org/api/v1/search/words'; const String JISHO_API = 'https://jisho.org/api/v1/search/words';
const String SCRAPE_BASE_URI = 'https://jisho.org/search/'; const String SCRAPE_BASE_URI = 'https://jisho.org/search/';
const String STROKE_ORDER_DIAGRAM_BASE_URI = 'https://classic.jisho.org/static/images/stroke_diagrams/'; const String STROKE_ORDER_DIAGRAM_BASE_URI = 'https://classic.jisho.org/static/images/stroke_diagrams/';
@ -46,7 +44,7 @@ String getStringBetweenIndicies(String data, int startIndex, int endIndex) {
String getStringBetweenStrings(String data, String startString, String endString) { String getStringBetweenStrings(String data, String startString, String endString) {
final regex = RegExp('${RegExp.escape(startString)}(.*?)${RegExp.escape(endString)}', dotAll: true); final regex = RegExp('${RegExp.escape(startString)}(.*?)${RegExp.escape(endString)}', dotAll: true);
final match = regex.allMatches(data).toList(); //TODO: Something wrong here final match = regex.allMatches(data).toList();
return match.isNotEmpty ? match[0].group(1).toString() : null; return match.isNotEmpty ? match[0].group(1).toString() : null;
} }
@ -237,6 +235,11 @@ String uriForExampleSearch(String phrase) {
return '${SCRAPE_BASE_URI}${Uri.encodeComponent(phrase)}%23sentences'; return '${SCRAPE_BASE_URI}${Uri.encodeComponent(phrase)}%23sentences';
} }
/* TODO: This is the wrong approach.
* Symbols such as are missing in mid sentence
* Maybe also JP fullwidth numbers?
*/
String getEndSymbolsOfExampleSentence(Element ul) { String getEndSymbolsOfExampleSentence(Element ul) {
final endSymbols = RegExp(r'<\/li>([^<>]+)$'); final endSymbols = RegExp(r'<\/li>([^<>]+)$');
return endSymbols.firstMatch(ul.innerHtml).group(1); return endSymbols.firstMatch(ul.innerHtml).group(1);
@ -274,7 +277,7 @@ ExampleResultData getKanjiAndKana(Element div) {
kanji += unlifted; kanji += unlifted;
kana += unlifted; kana += unlifted;
} }
} else { // TODO: This doesn't catch the "。" when it's not in a tag } else {
final text = content.text.trim(); final text = content.text.trim();
if (text != null) { if (text != null) {
kanji += text; kanji += text;