Java 类org.apache.lucene.analysis.util.RollingCharBuffer 实例源码

项目:lucene-bo    文件:TibWordTokenizer.java   
/**
 * Initializes and populates {@see #scanner} 
 * 
 * The format of each line in filename must be as follows: inflected-form + space + lemma
 * @param filename the file containing the entries to be added
 * @throws FileNotFoundException 
 * @throws IOException
 */
private void init(Reader reader) throws FileNotFoundException, IOException {
    this.scanner = new Trie(true);
    // currently only adds the entries without any diff
    try (BufferedReader br = new BufferedReader(reader)) {
        String line;
        while ((line = br.readLine()) != null) {
            final int spaceIndex = line.indexOf(' ');
            if (spaceIndex == -1) {
                throw new IllegalArgumentException("The dictionary file is corrupted in the following line.\n" + line);
            } else {
                this.scanner.add(line.substring(0, spaceIndex), line.substring(spaceIndex+1));
            }
        }
        final Optimizer opt = new Optimizer();
        this.scanner.reduce(opt);
    }
    ioBuffer = new RollingCharBuffer();
    ioBuffer.reset(input);
}