Package it.unimi.dsi.mg4j.index

Examples of it.unimi.dsi.mg4j.index.Index


  public boolean hasNext() {
    return documentIterator.hasNext();
  }

  private Index remapIndex( final Index index ) {
    final Index result = indexInverseRemapping.getindex  );
    return result == null ? index : result;
  }
View Full Code Here


    return indices;
  }
 
  public IntervalIterator intervalIterator( final Index index ) throws IOException {
    if ( ! indices.contains( index ) ) return IntervalIterators.TRUE;
    final Index remappedIndex = remapIndex( index );

    IntervalIterator intervalIterator = currentIterators.get( index );
    if ( intervalIterator == null ) currentIterators.put( index, intervalIterator = documentIterator.intervalIterator( remappedIndex ) );
    return intervalIterator;
  }
View Full Code Here

*/

public class RunQuery {

  public static void main( String arg[] ) throws Exception {
    /** First we open our indices. The booleans tell that we want random access to
     * the inverted lists, and we are going to use document sizes (for scoring--see below). */
    final Index text = Index.getInstance( arg[ 0 ] + "-text", true, true );
    final Index title = Index.getInstance( arg[ 0 ] + "-title", true, true );

    /* We need a map mapping index names to actual indices. Its keyset will be used by the
     * parser to distinguish correct index names (e.g., "text:foo title:bar"), and the mapping
     * itself will be used when transforming a query into a document iterator. We use a handy
     * fastutil array-based constructor. */
 
View Full Code Here

   *
   * @return the combined weighted score.
   */
  public double score() throws IOException {
    final double weight[] = this.currWeight;
    final Index index[] = this.currIndex;
    double result = 0;
    for( int i = n; i-- != 0; ) result += weight[ i ] * score( index[ i ] );
    return result; 
  }
View Full Code Here

                "A B C D E F F G G",
                "G A T H S K L J W L",
                "E S K D L J F K L S J D L S J D",
                "E B"
    ) ).run();
    Index index = DiskBasedIndex.getInstance( basename + "-text", true, true );

        /// String query = "A| B+C+G|W|S+J";
        DocumentIterator iterator = OrDocumentIterator.getInstance(
                index.documents("A"),
                MultiTermIndexIterator.getInstance(
                        index.documents("B"),
                        index.documents("C"),
                        index.documents("G")
                ),
                index.documents("W"),
                MultiTermIndexIterator.getInstance(
                        index.documents("S"),
                        index.documents("J")
                ));


        final int[] currDoc = new int[ 1 ];
        // A visitor invoking positionArray() on IndexIterators positioned on the current document.
View Full Code Here

  }
 
  public void testPaste() throws IOException, ConfigurationException, SecurityException, URISyntaxException, ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
   
   
    Index index = Index.getInstance( basename );
    assertEquals( 2, index.documents( 0 ).frequency() );     
    assertEquals( 2, index.documents( 1 ).frequency() );
    assertEquals( 1, index.documents( 2 ).frequency() );
    assertEquals( 1, index.documents( 3 ).frequency() );
   
    SemiExternalGammaList frequencies = new SemiExternalGammaList( new InputBitStream( basename + "-mo" + DiskBasedIndex.FREQUENCIES_EXTENSION ), 1, 4 );

    assertEquals( 2, frequencies.getLong( 0 ) );     
    assertEquals( 2, frequencies.getLong( 1 ) );     
View Full Code Here

  public void testSkipToEndOfList() throws ConfigurationException, SecurityException, IOException, URISyntaxException, ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
    String basename = File.createTempFile( getClass().getSimpleName(), "test" ).getCanonicalPath();
    new IndexBuilder( basename, new StringArrayDocumentCollection( new String[] { "a", "a", "c" } ) ).run();

    Index index = DiskBasedIndex.getInstance( basename + "-text", true, true );
    IndexIterator indexIterator = index.documents( "a" );
    assertEquals( Integer.MAX_VALUE, indexIterator.skipTo( Integer.MAX_VALUE ) );
    indexIterator.dispose();

    indexIterator = index.documents( "a" );
    assertEquals( 0, indexIterator.skipTo( 0 ) );
    assertEquals( 1, indexIterator.skipTo( 1 ) );
    assertEquals( Integer.MAX_VALUE, indexIterator.skipTo( 2 ) );
    indexIterator.dispose();
}
View Full Code Here

    FileLinesCollection flc;
    flc = new FileLinesCollection( basename + "-cluster-0.terms", "ASCII" );
    BinIO.storeObject( new ShiftAddXorSignedStringMap( flc.iterator(), new MWHCFunction<CharSequence>( flc , TransformationStrategies.utf16() ) ), basename + "-cluster-0.termmap" )
    flc = new FileLinesCollection( basename + "-cluster-1.terms", "ASCII" );
    BinIO.storeObject( new ShiftAddXorSignedStringMap( flc.iterator(), new MWHCFunction<CharSequence>( flc , TransformationStrategies.utf16() ) ), basename + "-cluster-1.termmap" )
    Index index = Index.getInstance( basename + "-cluster" );
    assertEquals( Integer.MAX_VALUE, index.documents( "b" ).skipTo( 2 ) );
  }
View Full Code Here

TOP

Related Classes of it.unimi.dsi.mg4j.index.Index

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.