use of com.yahoo.fsa.FSA in project vespa by vespa-engine.
the class ConceptNet method init.
private void init(String domain, String charsetname) {
_charset = Charset.forName(charsetname);
_fsa = new FSA(domain + ".fsa", charsetname);
if (!_fsa.isOk()) {
return;
}
FileInputStream file;
try {
file = new FileInputStream(domain + ".dat");
} catch (FileNotFoundException e) {
System.out.print("ConceptNet data file " + domain + ".dat" + " not found.\n");
return;
}
try {
_header = file.getChannel().map(MapMode.READ_ONLY, 0, 256);
_header.order(ByteOrder.LITTLE_ENDIAN);
if (h_magic() != 238579428) {
System.out.print("ConceptNet bad magic " + h_magic() + "\n");
return;
}
_index = file.getChannel().map(MapMode.READ_ONLY, 256, 8 * 4 * h_index_size());
_index.order(ByteOrder.LITTLE_ENDIAN);
_info = file.getChannel().map(MapMode.READ_ONLY, 256 + 8 * 4 * h_index_size(), 4 * h_info_size());
_info.order(ByteOrder.LITTLE_ENDIAN);
_catindex = file.getChannel().map(MapMode.READ_ONLY, 256 + 8 * 4 * h_index_size() + 4 * h_info_size(), 4 * h_catindex_size());
_catindex.order(ByteOrder.LITTLE_ENDIAN);
_strings = file.getChannel().map(MapMode.READ_ONLY, 256 + 8 * 4 * h_index_size() + 4 * h_info_size() + 4 * h_catindex_size(), h_strings_size());
_strings.order(ByteOrder.LITTLE_ENDIAN);
_ok = true;
} catch (IOException e) {
System.out.print("ConceptNet IO exception.\n");
return;
}
}
use of com.yahoo.fsa.FSA in project vespa by vespa-engine.
the class FSAIteratorTestCase method setUp.
protected void setUp() {
fsa = new FSA("src/test/fsa/test-iterator.fsa");
state = fsa.getState();
expected = new ArrayList<String>();
expected.add("abacus");
expected.add("abadan");
expected.add("abaisse");
expected.add("abdicate");
expected.add("abdomen");
expected.add("abdominous");
expected.add("dachs");
expected.add("dacia");
expected.add("daciaa");
expected.add("daciab");
expected.add("dacite");
expected.add("dacota");
}
use of com.yahoo.fsa.FSA in project vespa by vespa-engine.
the class UTF8TestCase method setUp.
protected void setUp() {
// fsa with one word (6 code points, 18 bytes)
fsa = new FSA("src/test/fsa/utf8.fsa");
state = fsa.getState();
int[] pbuf = { 0xe0, 0xa4, 0xb9 };
prefixBuf = convert(pbuf);
prefix = new String(prefixBuf, charset);
int[] sbuf = { 0xe0, 0xa4, 0xbf, 0xe0, 0xa4, 0xa8, 0xe0, 0xa5, 0x8d, 0xe0, 0xa4, 0xa6, 0xe0, 0xa5, 0x80 };
suffixBuf = convert(sbuf);
suffix = new String(suffixBuf, charset);
word = prefix + suffix;
}
use of com.yahoo.fsa.FSA in project vespa by vespa-engine.
the class FSATestCase method setUp.
protected void setUp() throws IOException {
fsa = new FSA(new FileInputStream("src/test/fsa/test-fsa.fsa"));
state = fsa.getState();
}
Aggregations