public class BinaryLoader
extends java.lang.Object
Constructor and Description |
---|
BinaryLoader(java.io.File location) |
BinaryLoader(java.net.URL location) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Should be called when model reading finished
|
int[] |
readCounts()
Reads language model order and ngram counts
|
NgramTrieQuant |
readQuant(int order)
Reads weights quantation object from stream
|
void |
readTrieByteArr(byte[] arr)
Reads trie in form of byte array into provided array.
|
NgramTrieModel.TrieUnigram[] |
readUnigrams(int count)
Reads array of language model unigrams
|
java.lang.String[] |
readWords(int unigramNum)
Reads vocabulary of language model.
|
void |
verifyHeader()
Reads header from stream and checks if it matches trie header
|
public BinaryLoader(java.io.File location) throws java.io.IOException
java.io.IOException
public BinaryLoader(java.net.URL location) throws java.io.IOException
java.io.IOException
public void verifyHeader() throws java.io.IOException
java.io.IOException
- if reading from stream failedpublic int[] readCounts() throws java.io.IOException
java.io.IOException
- if reading from stream failedpublic NgramTrieQuant readQuant(int order) throws java.io.IOException
order
- - max order of ngrams for this modelNgramTrieQuant
java.io.IOException
- if reading from stream failedpublic NgramTrieModel.TrieUnigram[] readUnigrams(int count) throws java.io.IOException
count
- - amount of unigrams according to counts previously readNgramTrieModel.TrieUnigram
java.io.IOException
- if reading from stream failedpublic void readTrieByteArr(byte[] arr) throws java.io.IOException
NgramTrie
arr
- - byte array to read trie tojava.io.IOException
- if reading from stream failedpublic java.lang.String[] readWords(int unigramNum) throws java.io.IOException
unigramNum
- - amount of unigramsjava.io.IOException
- of reading from stream failedpublic void close() throws java.io.IOException
java.io.IOException
- if stream was corrupted