Fix some bugs
This commit is contained in:
parent
1e35cde24d
commit
8a86413fdd
|
@ -147,12 +147,12 @@ class KanjiResult {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
var returnObject = {
|
||||||
'query': query,
|
'query': query,
|
||||||
'found': found,
|
'found': found,
|
||||||
'taughtIn': taughtIn,
|
'taughtIn': taughtIn,
|
||||||
'jlptLevel': jlptLevel,
|
'jlptLevel': jlptLevel,
|
||||||
'newspaperFrequencyRank': newspaperFrequencyRank.toString(),
|
'newspaperFrequencyRank': newspaperFrequencyRank.toString(), // TODO: Rewrite tests to make this value an int
|
||||||
'strokeCount': strokeCount,
|
'strokeCount': strokeCount,
|
||||||
'meaning': meaning,
|
'meaning': meaning,
|
||||||
'kunyomi': kunyomi,
|
'kunyomi': kunyomi,
|
||||||
|
@ -166,22 +166,27 @@ class KanjiResult {
|
||||||
'strokeOrderGifUri': strokeOrderGifUri,
|
'strokeOrderGifUri': strokeOrderGifUri,
|
||||||
'uri': uri
|
'uri': uri
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (newspaperFrequencyRank == null) returnObject.update('newspaperFrequencyRank', (value) => null);
|
||||||
|
returnObject.removeWhere((key, value) => value == null);
|
||||||
|
|
||||||
|
return returnObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExampleSentencePiece {
|
class ExampleSentencePiece {
|
||||||
String unlifted;
|
|
||||||
String lifted;
|
String lifted;
|
||||||
|
String unlifted;
|
||||||
|
|
||||||
ExampleSentencePiece({String unlifted, String lifted}){
|
ExampleSentencePiece({String lifted, String unlifted}){
|
||||||
this.unlifted = unlifted;
|
|
||||||
this.lifted = lifted;
|
this.lifted = lifted;
|
||||||
|
this.unlifted = unlifted;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
return {
|
return {
|
||||||
'unlifted': unlifted,
|
if (lifted != null) 'lifted': lifted,
|
||||||
'lifted': lifted
|
if (unlifted != null)'unlifted': unlifted
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,6 @@ ExampleResultData getKanjiAndKana(Element div) {
|
||||||
final ul = div.querySelector('ul');
|
final ul = div.querySelector('ul');
|
||||||
final contents = ul.children;
|
final contents = ul.children;
|
||||||
|
|
||||||
|
|
||||||
var kanji = '';
|
var kanji = '';
|
||||||
var kana = '';
|
var kana = '';
|
||||||
for (var i = 0; i < contents.length; i += 1) {
|
for (var i = 0; i < contents.length; i += 1) {
|
||||||
|
@ -270,7 +269,7 @@ ExampleResultData getKanjiAndKana(Element div) {
|
||||||
kanji += unlifted;
|
kanji += unlifted;
|
||||||
kana += unlifted;
|
kana += unlifted;
|
||||||
}
|
}
|
||||||
} else {
|
} else { // TODO: This doesn't catch the "。" when it's not in a tag
|
||||||
final text = content.text.trim();
|
final text = content.text.trim();
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
kanji += text;
|
kanji += text;
|
||||||
|
|
Loading…
Reference in New Issue