Search in sources :

Example 11 with ByteArray

use of com.hankcs.hanlp.corpus.io.ByteArray in project HanLP by hankcs.

the class TestBytesArray method testLoadByteArray.

/**
     * 无法在-Xms512m -Xmx512m -Xmn256m下运行<br>
     *     java.lang.OutOfMemoryError: GC overhead limit exceeded
     * @throws Exception
     */
public void testLoadByteArray() throws Exception {
    ByteArray byteArray = ByteArray.createByteArray(HanLP.Config.MaxEntModelPath + Predefine.BIN_EXT);
    MaxEntModel.create(byteArray);
}
Also used : ByteArray(com.hankcs.hanlp.corpus.io.ByteArray)

Example 12 with ByteArray

use of com.hankcs.hanlp.corpus.io.ByteArray in project HanLP by hankcs.

the class ByteUtilTest method testReadDouble.

public void testReadDouble() throws Exception {
    DataOutputStream out = new DataOutputStream(new FileOutputStream(DATA_TEST_OUT_BIN));
    out.writeDouble(0.123456789);
    out.writeInt(3389);
    ByteArray byteArray = ByteArray.createByteArray(DATA_TEST_OUT_BIN);
    System.out.println(byteArray.nextDouble());
    System.out.println(byteArray.nextInt());
}
Also used : DataOutputStream(java.io.DataOutputStream) FileOutputStream(java.io.FileOutputStream) ByteArray(com.hankcs.hanlp.corpus.io.ByteArray)

Example 13 with ByteArray

use of com.hankcs.hanlp.corpus.io.ByteArray in project HanLP by hankcs.

the class ByteUtilTest method testReadUTF.

public void testReadUTF() throws Exception {
    DataOutputStream out = new DataOutputStream(new FileOutputStream(DATA_TEST_OUT_BIN));
    out.writeUTF("hankcs你好123");
    ByteArray byteArray = ByteArray.createByteArray(DATA_TEST_OUT_BIN);
    System.out.println(byteArray.nextUTF());
}
Also used : DataOutputStream(java.io.DataOutputStream) FileOutputStream(java.io.FileOutputStream) ByteArray(com.hankcs.hanlp.corpus.io.ByteArray)

Example 14 with ByteArray

use of com.hankcs.hanlp.corpus.io.ByteArray in project HanLP by hankcs.

the class ByteUtilTest method testReadUnsignedShort.

public void testReadUnsignedShort() throws Exception {
    DataOutputStream out = new DataOutputStream(new FileOutputStream(DATA_TEST_OUT_BIN));
    int utflen = 123;
    out.writeByte((byte) ((utflen >>> 8) & 0xFF));
    out.writeByte((byte) ((utflen >>> 0) & 0xFF));
    ByteArray byteArray = ByteArray.createByteArray(DATA_TEST_OUT_BIN);
    System.out.println(byteArray.nextUnsignedShort());
}
Also used : DataOutputStream(java.io.DataOutputStream) FileOutputStream(java.io.FileOutputStream) ByteArray(com.hankcs.hanlp.corpus.io.ByteArray)

Example 15 with ByteArray

use of com.hankcs.hanlp.corpus.io.ByteArray in project HanLP by hankcs.

the class TestBytesArray method testWriteAndRead.

public void testWriteAndRead() throws Exception {
    DataOutputStream out = new DataOutputStream(new FileOutputStream(DATA_OUT_DAT));
    out.writeChar('H');
    out.writeChar('e');
    out.writeChar('l');
    out.writeChar('l');
    out.writeChar('o');
    out.close();
    ByteArray byteArray = ByteArray.createByteArray(DATA_OUT_DAT);
    while (byteArray.hasMore()) {
        System.out.println(byteArray.nextChar());
    }
}
Also used : DataOutputStream(java.io.DataOutputStream) FileOutputStream(java.io.FileOutputStream) ByteArray(com.hankcs.hanlp.corpus.io.ByteArray)

Aggregations

ByteArray (com.hankcs.hanlp.corpus.io.ByteArray)21 DataOutputStream (java.io.DataOutputStream)5 FileOutputStream (java.io.FileOutputStream)5 Nature (com.hankcs.hanlp.corpus.tag.Nature)2 DoubleArrayTrie (com.hankcs.hanlp.collection.trie.DoubleArrayTrie)1 LinkedList (java.util.LinkedList)1