Fix trie lookup

Julien LepillerThu Jun 11 04:21:54+0200 2020

adde211

Fix trie lookup

app/src/main/java/eu/lepiller/nani/dictionary/FileDictionary.java

3333
3434
    interface TrieValsDecoder<T> {
3535
        T decodeVals(RandomAccessFile file, long pos) throws IOException;
36+
        void skipVals(RandomAccessFile file, long pos) throws IOException;
3637
    }
3738
3839
    private String mUrl;

254255
            return decoder.decodeVals(file, triePos);
255256
        }
256257
257-
        int valuesLength = file.readShort();
258-
        Log.v(TAG, "number of values: " + valuesLength);
259-
        file.skipBytes(valuesLength * 4);
258+
        decoder.skipVals(file, triePos);
260259
261260
        int transitionLength = file.readByte();
262261
        Log.v(TAG, "number of transitions: " + transitionLength);

app/src/main/java/eu/lepiller/nani/dictionary/ResultDictionary.java

105105
            public ArrayList<Integer> decodeVals(RandomAccessFile file, long pos) throws IOException {
106106
                return getValues(file, pos);
107107
            }
108+
109+
            @Override
110+
            public void skipVals(RandomAccessFile file, long pos) throws IOException {
111+
                file.seek(pos);
112+
                int valuesLength = file.readShort();
113+
                Log.v(TAG, "number of values: " + valuesLength);
114+
                file.skipBytes(valuesLength * 4);
115+
            }
108116
        });
109117
    }
110118

app/src/main/java/eu/lepiller/nani/dictionary/WadokuPitchDictionary.java

3232
            @Override
3333
            public String decodeVals(RandomAccessFile file, long pos) throws IOException {
3434
                file.seek(pos);
35+
                Log.d(TAG, "decoding at " + pos);
3536
                return getHuffmanString(file, huffman);
3637
            }
38+
39+
            @Override
40+
            public void skipVals(RandomAccessFile file, long pos) throws IOException {
41+
                file.seek(pos);
42+
                getHuffmanString(file, huffman);
43+
            }
3744
        });
3845
    }
3946

6370
            List<String> kanjis = r.getAlternatives();
6471
6572
            for(String k: kanjis) {
66-
                Log.d(TAG, "Searching pitch for " + k);
73+
                Log.d(TAG, "Searching pitch for " + Arrays.toString(k.getBytes()));
6774
                String pitch = findPitch(k, file);
6875
                if(pitch != null) {
6976
                    Log.d(TAG, "Found " + pitch);

app/src/main/res/drawable/ic_pitch_border.xml unknown status 1

1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
</shape>
4<
05<
\ No newline at end of file