com.aliasi.lm.DeletingTrieReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aliasi-lingpipe Show documentation
Show all versions of aliasi-lingpipe Show documentation
This is the original Lingpipe:
http://alias-i.com/lingpipe/web/download.html
There were not made any changes to the source code.
package com.aliasi.lm;
import java.io.IOException;
abstract class DeletingTrieReader implements TrieReader {
private final TrieReader mReader;
long mNextCount;
DeletingTrieReader(TrieReader reader) throws IOException {
mReader = reader;
bufferCount();
}
public long readCount() {
return mNextCount;
}
public long readSymbol() throws IOException {
long sym;
while ((sym = mReader.readSymbol()) != -1L) {
if (bufferCount())
return sym;
else
flushDaughters();
}
return -1L;
}
long nextCount() throws IOException {
return mReader.readCount();
}
// buffer next count and return true if usable
abstract boolean bufferCount() throws IOException;
void flushDaughters() throws IOException {
while (mReader.readSymbol() != -1L) {
mReader.readCount();
flushDaughters();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy