Search in lower case and reverse result order.
app/src/main/java/eu/lepiller/nani/dictionary/ResultDictionary.java
| 126 | 126 | return null; | |
| 127 | 127 | ||
| 128 | 128 | // Check file format version | |
| 129 | - | if(!Arrays.equals(header, "NANI_JMDICT002".getBytes())) | |
| 129 | + | if(!Arrays.equals(header, "NANI_JMDICT002".getBytes())) { | |
| 130 | + | Log.d(TAG, "search: incompatible header: " + header); | |
| 130 | 131 | throw new IncompatibleFormatException(getName()); | |
| 132 | + | } | |
| 131 | 133 | ||
| 132 | - | byte[] search = text.getBytes(); | |
| 134 | + | byte[] search = text.toLowerCase().getBytes(); | |
| 133 | 135 | ||
| 136 | + | long tagsListPos = file.readInt(); | |
| 134 | 137 | long kanjiTriePos = file.readInt(); | |
| 135 | 138 | long readingTriePos = file.readInt(); | |
| 136 | 139 | long meaningTriePos = file.readInt(); | |
… | |||
| 147 | 150 | logHuffman(readingHuffman, new ArrayList<Boolean>()); | |
| 148 | 151 | ||
| 149 | 152 | // Search in Japanese, by kanji and reading | |
| 153 | + | Log.d(TAG, "search: by kanji and reading"); | |
| 150 | 154 | ArrayList<Integer> results = searchTrie(file, kanjiTriePos, search); | |
| 151 | 155 | ArrayList<Integer> readingResults = searchTrie(file, readingTriePos, search); | |
| 152 | 156 | if(results != null && readingResults != null) | |
… | |||
| 154 | 158 | else if (results == null) | |
| 155 | 159 | results = readingResults; | |
| 156 | 160 | ||
| 161 | + | Log.d(TAG, "search: by meaning"); | |
| 157 | 162 | // Search in other language, by meaning | |
| 158 | 163 | if(results == null || results.isEmpty()) | |
| 159 | 164 | results = searchTrie(file, meaningTriePos, search); | |
… | |||
| 181 | 186 | if(num > 10) | |
| 182 | 187 | break; | |
| 183 | 188 | num++; | |
| 184 | - | r.add(getValue(file, i)); | |
| 189 | + | r.add(0, getValue(file, i)); | |
| 185 | 190 | } | |
| 186 | 191 | return r; | |
| 187 | 192 | } catch (FileNotFoundException e) { | |