@Test public void testReadAndLookUpTokenInfo() throws Exception { List<Short> tokenInfo = new ArrayList<>(); List<Integer> features = new ArrayList<>(); short[] tokenInfos = new short[3]; tokenInfos[0] = 1; tokenInfos[1] = 2; tokenInfos[2] = 3; int[] featureInfos = new int[2]; featureInfos[0] = 73; featureInfos[1] = 99; 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; entry.tokenInfos = tokenInfos; entry.featureInfos = featureInfos; 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)); assertEquals(99, tokenInfoBuffer2.lookupFeature(0, 1)); assertEquals(73, tokenInfoBuffer2.lookupFeature(0, 0)); }
@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();  }