Package it.unimi.dsi.mg4j.query.nodes

Examples of it.unimi.dsi.mg4j.query.nodes.Term


public class DoublingTermExpander extends AbstractTermExpander {

  @Override
  public Query expand( Term term ) {
    return new MultiTerm( term, new Term( new MutableString( term.term ).append( term.term ) ) );
  }
View Full Code Here


    return new MultiTerm( term, new Term( new MutableString( term.term ).append( term.term ) ) );
  }

  @Override
  public Query expand( Prefix prefix ) {
    return new MultiTerm( new Term( prefix.prefix ), new Term( new MutableString( prefix.prefix ).append( prefix.prefix ) ) );
  }
View Full Code Here

    assertFalse( intervalIterator.hasNext() );
    assertFalse( documentIterator.hasNext() );
  }

  public void testQuery() throws IOException, QueryBuilderVisitorException {
    Query query = new Consecutive( new Term( "a" ), new Remap( new Select( "index1", new Term( "b" ) ), new CharSequence[] { "index1" }, new CharSequence[] { "index0" } ) );
    DocumentIteratorBuilderVisitor documentIteratorBuilderVisitor = new DocumentIteratorBuilderVisitor( indexMap, index0, Integer.MAX_VALUE );
    DocumentIterator documentIterator = query.accept( documentIteratorBuilderVisitor );
    assertTrue( documentIterator.hasNext() );
    assertEquals( 0, documentIterator.nextDocument() );
    IntervalIterator intervalIterator = documentIterator.intervalIterator( index0 );
View Full Code Here

    assertFalse( documentIterator.hasNext() );
  }

 
  public void testDoubleRemapping() throws IOException, QueryBuilderVisitorException {
    Query query = new Remap( new Or( new Term( "a" ), new Select( "index1", new Term( "b" ) ) ), new CharSequence[] { "index0", "index1" }, new CharSequence[] { "index2", "index3" } );
    DocumentIteratorBuilderVisitor documentIteratorBuilderVisitor = new DocumentIteratorBuilderVisitor( indexMap, index0, Integer.MAX_VALUE );
    DocumentIterator documentIterator = query.accept( documentIteratorBuilderVisitor );
    IntervalIterator intervalIterator;
   
    assertTrue( documentIterator.hasNext() );
View Full Code Here

  public void tearDown() {
    for( File f: new File( basename ).getParentFile().listFiles( (FileFilter)new PrefixFileFilter( new File( basename ).getName() ) ) )  f.delete();
  }

  public void testWeights() throws QueryBuilderVisitorException, IOException {
    Query query = new Weight( 0.5, new And( new Term( "a" ), new Term( "b" ) ) );
    DocumentIteratorBuilderVisitor documentIteratorBuilderVisitor = new DocumentIteratorBuilderVisitor( null, index, Integer.MAX_VALUE );
    DocumentIterator documentIterator = query.accept( documentIteratorBuilderVisitor );
    assertEquals( .5, documentIterator.weight(), 0 );
    documentIterator.dispose();

    query = new Weight( .1, new Weight( 0.5, new And( new Weight( .2, new Term( "a" ) ), new Term( "b" ) ) ) );
    documentIteratorBuilderVisitor = new DocumentIteratorBuilderVisitor( null, index, Integer.MAX_VALUE );
    documentIterator = query.accept( documentIteratorBuilderVisitor );
    assertEquals( .5, documentIterator.weight(), 0 );
    documentIterator.dispose();
}
View Full Code Here

TOP

Related Classes of it.unimi.dsi.mg4j.query.nodes.Term

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.