use of com.atilika.kuromoji.dict.ConnectionCosts in project deeplearning4j by deeplearning4j.
the class ConnectionCostsCompilerTest method setUp.
@BeforeClass
public static void setUp() throws IOException {
File costsFile = File.createTempFile("kuromoji-connectioncosts-", ".bin");
costsFile.deleteOnExit();
String costs = "" + "3 3\n" + "0 0 1\n" + "0 1 2\n" + "0 2 3\n" + "1 0 4\n" + "1 1 5\n" + "1 2 6\n" + "2 0 7\n" + "2 1 8\n" + "2 2 9\n";
ConnectionCostsCompiler compiler = new ConnectionCostsCompiler(new FileOutputStream(costsFile));
compiler.readCosts(new ByteArrayInputStream(costs.getBytes(StandardCharsets.UTF_8)));
compiler.compile();
DataInputStream dataInput = new DataInputStream(new FileInputStream(costsFile));
int size = dataInput.readInt();
ShortBuffer costsBuffer = ByteBufferIO.read(dataInput).asShortBuffer();
dataInput.close();
connectionCosts = new ConnectionCosts(size, costsBuffer);
}
Aggregations