prettify method
Return this hint table as a simpler structure.
The Map to be returned is set to the word to be translated as the key, and the list of translated words as the value.
Implementation
Map<String, List<String>> prettify() {
final prettified = <String, List<String>>{};
for (final token in tokens) {
for (final row in token.table.rows) {
final cells = row.cells;
for (final cell in cells) {
final colspan = cell.span;
final key = colspan > 0
? _fetchWordString(token: token).substring(0, colspan)
: token.value;
if (prettified.containsKey(key)) {
final hintsInternal = prettified[key]!;
final hint = cell.hint;
if (!hintsInternal.contains(hint)) {
hintsInternal.add(hint);
}
} else {
prettified[key] = [cell.hint];
}
}
}
}
return prettified;
}