@Override public FastBufferedReader copy() { return new FastBufferedReader(bufferSize, wordConstituents); }
/** Creates a read-once ASCII graph. Instances created using this constructor can be * only accessed using a single call to {@link #nodeIterator(int)}. * * @param is an input stream containing an ASCII graph. */ public ASCIIGraph(final InputStream is) throws NumberFormatException, IOException { graphFile = null; fbr = new FastBufferedReader(new InputStreamReader(is, "ASCII")); n = Integer.parseInt(fbr.readLine(new MutableString()).toString()); if (n < 0) throw new IllegalArgumentException("Number of nodes must be nonnegative"); }
public synchronized void close() { if ( fbr == null ) return; try { fbr.close(); } catch ( IOException e ) { throw new RuntimeException( e ); } finally { fbr = null; } }
public boolean next( final MutableString word, final MutableString nonWord ) throws IOException { int i; final char buffer[] = this.buffer; if ( noMoreCharacters() ) return false; word.length( 0 ); nonWord.length( 0 ); for(;;) { for( i = 0; i < avail && isWordConstituent( buffer[ pos + i ] ); i++ ); word.append( buffer, pos, i ); pos += i; avail -= i; if ( avail > 0 || noMoreCharacters() ) break; } if ( noMoreCharacters() ) return true; for(;;) { for( i = 0; i < avail && ! isWordConstituent( buffer[ pos + i ] ); i++ ); nonWord.append( buffer, pos, i ); pos += i; avail -= i; if ( avail > 0 || noMoreCharacters() ) return true; } }
public void runTermsOnly() throws IOException { final ProgressLogger pl = new ProgressLogger( LOGGER, logInterval ); final PrintWriter[] localTerms = new PrintWriter[ numIndices ]; final int numTerms[] = new int[ numIndices ]; final FastBufferedReader terms = new FastBufferedReader( new InputStreamReader( new FileInputStream( inputBasename + DiskBasedIndex.TERMS_EXTENSION ), "UTF-8" ) ); for( int i = 0; i < numIndices; i++ ) localTerms[ i ] = new PrintWriter( new OutputStreamWriter( new FastBufferedOutputStream( new FileOutputStream( localBasename[ i ] + DiskBasedIndex.TERMS_EXTENSION ) ), "UTF-8" ) ); // The current term final MutableString currTerm = new MutableString(); pl.itemsName = "terms"; pl.logInterval = logInterval; pl.start( "Partitioning index terms..." ); int termNumber = 0, k; while( terms.readLine( currTerm ) != null ) { k = strategy.localIndex( termNumber ); // The local index for this term if ( numTerms[ k ] != strategy.localNumber( termNumber ) ) throw new IllegalStateException(); numTerms[ k ]++; currTerm.println( localTerms[ k ] ); pl.update(); termNumber++; } terms.close(); for( int i = 0; i < numIndices; i++ ) localTerms[ i ].close(); pl.done(); }
public boolean hasNext() { if ( toAdvance ) { try { k = 1 - k; hasNext = fastBufferedReader.readLine( s[ k ] ) != null; } catch (IOException e) { throw new RuntimeException( e ); } toAdvance = false; } return hasNext; }
this.word.length(0); this.nonWord.length(0); this.wordReader.setReader((Reader)new FastBufferedReader(allText)); try { this.writer.append( this.title ).append( "\t" ); this.writer.append(slinks); while (this.wordReader.next(this.word, this.nonWord)) { this.writer.append( this.word.toLowerCase() ).append( " " );
@Override public LineWordReader setReader(final Reader reader) { fastBufferedReader.setReader(reader); return this; }
public int read() throws IOException { if ( noMoreCharacters() ) return -1; avail--; return buffer[ pos++ ]; }
public void runTermsOnly() throws IOException { final ProgressLogger pl = new ProgressLogger( LOGGER, logInterval, TimeUnit.MILLISECONDS ); final PrintWriter[] localTerms = new PrintWriter[ numIndices ]; final int numTerms[] = new int[ numIndices ]; @SuppressWarnings("resource") final FastBufferedReader terms = new FastBufferedReader( new InputStreamReader( new FileInputStream( inputBasename + DiskBasedIndex.TERMS_EXTENSION ), "UTF-8" ) ); for( int i = 0; i < numIndices; i++ ) localTerms[ i ] = new PrintWriter( new OutputStreamWriter( new FastBufferedOutputStream( new FileOutputStream( localBasename[ i ] + DiskBasedIndex.TERMS_EXTENSION ) ), "UTF-8" ) ); // The current term final MutableString currTerm = new MutableString(); pl.itemsName = "terms"; pl.logInterval = logInterval; pl.start( "Partitioning index terms..." ); int termNumber = 0, k; while( terms.readLine( currTerm ) != null ) { k = strategy.localIndex( termNumber ); // The local index for this term if ( numTerms[ k ] != strategy.localNumber( termNumber ) ) throw new IllegalStateException(); numTerms[ k ]++; currTerm.println( localTerms[ k ] ); pl.update(); termNumber++; } terms.close(); for( int i = 0; i < numIndices; i++ ) localTerms[ i ].close(); pl.done(); }
public boolean hasNext() { if ( toAdvance ) { try { k = 1 - k; hasNext = fastBufferedReader.readLine( s[ k ] ) != null; } catch (IOException e) { throw new RuntimeException( e ); } toAdvance = false; } return hasNext; }
this.wordReader.setReader( ( Reader ) new FastBufferedReader( this.firstPar ) ); try { this.writer.append( this.title ).append( "\t" ); while( this.wordReader.next( this.word, this.nonWord ) ) { this.writer.append( this.word.toLowerCase() ).append( " " );
public boolean next( final MutableString word, final MutableString nonWord ) throws IOException { int i; final char buffer[] = this.buffer; if ( noMoreCharacters() ) return false; word.length( 0 ); nonWord.length( 0 ); for(;;) { for( i = 0; i < avail && isWordConstituent( buffer[ pos + i ] ); i++ ); word.append( buffer, pos, i ); pos += i; avail -= i; if ( avail > 0 || noMoreCharacters() ) break; } if ( noMoreCharacters() ) return true; for(;;) { for( i = 0; i < avail && ! isWordConstituent( buffer[ pos + i ] ); i++ ); nonWord.append( buffer, pos, i ); pos += i; avail -= i; if ( avail > 0 || noMoreCharacters() ) return true; } }
public LineWordReader setReader( final Reader reader ) { fastBufferedReader.setReader( reader ); return this; }
public int read() throws IOException { if ( noMoreCharacters() ) return -1; avail--; return buffer[ pos++ ]; }
public void runTermsOnly() throws IOException { final ProgressLogger pl = new ProgressLogger( LOGGER, logInterval ); final PrintWriter[] localTerms = new PrintWriter[ numIndices ]; final int numTerms[] = new int[ numIndices ]; final FastBufferedReader terms = new FastBufferedReader( new InputStreamReader( new FileInputStream( inputBasename + DiskBasedIndex.TERMS_EXTENSION ), "UTF-8" ) ); for( int i = 0; i < numIndices; i++ ) localTerms[ i ] = new PrintWriter( new OutputStreamWriter( new FastBufferedOutputStream( new FileOutputStream( localBasename[ i ] + DiskBasedIndex.TERMS_EXTENSION ) ), "UTF-8" ) ); // The current term final MutableString currTerm = new MutableString(); pl.itemsName = "terms"; pl.logInterval = logInterval; pl.start( "Partitioning index terms..." ); int termNumber = 0, k; while( terms.readLine( currTerm ) != null ) { k = strategy.localIndex( termNumber ); // The local index for this term if ( numTerms[ k ] != strategy.localNumber( termNumber ) ) throw new IllegalStateException(); numTerms[ k ]++; currTerm.println( localTerms[ k ] ); pl.update(); termNumber++; } terms.close(); for( int i = 0; i < numIndices; i++ ) localTerms[ i ].close(); pl.done(); }
public FastBufferedReader copy() { return new FastBufferedReader( bufferSize, wordConstituents ); }
public enum IndexType { /** An old-style, interleaved index. */ INTERLEAVED, /** A high-performance index which stores position separately. */ HIGH_PERFORMANCE, /** A quasi-succinct index. */ QUASI_SUCCINCT }