@Test public void testCompleteLookUp() throws Exception { Map<Integer, String> resultMap = new HashMap<>(); resultMap.put(73, "hello"); resultMap.put(42, "今日は"); resultMap.put(99, "素敵な世界"); List<Short> tokenInfo = new ArrayList<>(); List<Integer> features = new ArrayList<>(); tokenInfo.add((short) 1); tokenInfo.add((short) 2); tokenInfo.add((short) 3); features.add(73); features.add(99); BufferEntry entry = new BufferEntry(); entry.tokenInfo = tokenInfo; entry.features = features; List<BufferEntry> bufferEntries = new ArrayList<>(); bufferEntries.add(entry); File file = File.createTempFile("kuromoji-tokeinfo-buffer-", ".bin"); file.deleteOnExit(); TokenInfoBufferCompiler compiler = new TokenInfoBufferCompiler(new FileOutputStream(file), bufferEntries); compiler.compile(); TokenInfoBuffer tokenInfoBuffer2 = new TokenInfoBuffer(new FileInputStream(file)); BufferEntry result = tokenInfoBuffer2.lookupEntry(0); assertEquals("hello", resultMap.get(result.featureInfos[0])); assertEquals("素敵な世界", resultMap.get(result.featureInfos[1])); }
@Override public void compile() throws IOException { ByteBufferIO.write(output, buffer); output.close(); }
TokenInfoBufferCompiler implements Compiler { @Override public void compile() throws IOException { ByteBufferIO.write(output, buffer); output.close(); } }
TokenInfoBufferCompiler implements Compiler { @Override public void compile() throws IOException { ByteBufferIO.write(output, buffer); output.close(); } TokenInfoBufferCompiler(OutputStream output, List<BufferEntry> entries); }
TokenInfoBufferCompiler implements Compiler { @Override public void compile() throws IOException { ByteBufferIO.write(output, buffer); output.close(); } TokenInfoBufferCompiler(OutputStream output, List<BufferEntry> entries); void putEntries(List<BufferEntry> entries); @Override void compile(); }
TokenInfoBufferCompiler implements Compiler { @Override public void compile() throws IOException { ByteBufferIO.write(output, buffer); output.close(); } TokenInfoBufferCompiler(OutputStream output, List<BufferEntry> entries); void putEntries(List<BufferEntry> entries); @Override void compile();  }