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