List of usage examples for org.apache.lucene.analysis.util RollingCharBuffer RollingCharBuffer
RollingCharBuffer
From source file:io.bdrc.lucene.bo.TibWordTokenizer.java
License:Apache License
/** * Constructs a TibWordTokenizer using a default lexicon file (here * "resource/output/total_lexicon.txt")/*from w ww . j a v a 2s . c o m*/ * * @throws IOException * the file containing the lexicon cannot be read */ public TibWordTokenizer() throws IOException { if (defaultTrie != null) { this.scanner = defaultTrie; ioBuffer = new RollingCharBuffer(); ioBuffer.reset(input); return; } InputStream stream = null; stream = CommonHelpers.getResourceOrFile("bo-compiled-trie.dump"); if (stream == null) { final String msg = "The default compiled Trie is not found. Either rebuild the Jar or run BuildCompiledTrie.main()" + "\n\tAborting..."; logger.error(msg); throw new IOException(msg); } else { init(stream); defaultTrie = scanner; } }
From source file:io.bdrc.lucene.bo.TibWordTokenizer.java
License:Apache License
/** * Constructs a TibWordTokenizer using a given trie * /*from w w w .ja va 2s . com*/ * @param trie * built with BuildCompiledTrie.java */ public TibWordTokenizer(Trie trie) { this.scanner = trie; ioBuffer = new RollingCharBuffer(); ioBuffer.reset(input); }
From source file:io.bdrc.lucene.bo.TibWordTokenizer.java
License:Apache License
public TibWordTokenizer(String trieFile) throws FileNotFoundException, IOException { System.out.println("\n\tcompiled Trie not found, building it."); long start = System.currentTimeMillis(); this.scanner = BuildCompiledTrie.buildTrie(Arrays.asList(trieFile)); long end = System.currentTimeMillis(); System.out.println("\tTime: " + (end - start) / 1000 + "s."); ioBuffer = new RollingCharBuffer(); ioBuffer.reset(input);/*w w w. j a va 2s.co m*/ }
From source file:io.bdrc.lucene.bo.TibWordTokenizer.java
License:Apache License
/** * Opens an existing compiled Trie//from w ww . j av a 2 s .c o m * * @param inputStream * the compiled Trie opened as a Stream */ private void init(InputStream inputStream) throws IOException { System.out.println("\n\tLoading the trie"); long start = System.currentTimeMillis(); this.scanner = new Trie(new DataInputStream(inputStream)); long end = System.currentTimeMillis(); System.out.println("\tTime: " + (end - start) / 1000 + "s."); ioBuffer = new RollingCharBuffer(); ioBuffer.reset(input); }