Package org.apache.lucene.search.vectorhighlight.FieldPhraseList

Examples of org.apache.lucene.search.vectorhighlight.FieldPhraseList.WeightedPhraseInfo


    FieldFragList ffl = new FieldFragList( fragCharSize );

    List<WeightedPhraseInfo> wpil = new ArrayList<WeightedPhraseInfo>();
    Iterator<WeightedPhraseInfo> ite = fieldPhraseList.phraseList.iterator();
    WeightedPhraseInfo phraseInfo = null;
    int startOffset = 0;
    boolean taken = false;
    while( true ){
      if( !taken ){
        if( !ite.hasNext() ) break;
        phraseInfo = ite.next();
      }
      taken = false;
      if( phraseInfo == null ) break;

      // if the phrase violates the border of previous fragment, discard it and try next phrase
      if( phraseInfo.getStartOffset() < startOffset ) continue;

      wpil.clear();
      wpil.add( phraseInfo );
      int st = phraseInfo.getStartOffset() - MARGIN < startOffset ?
          startOffset : phraseInfo.getStartOffset() - MARGIN;
      int en = st + fragCharSize;
      startOffset = en;

      while( true ){
        if( ite.hasNext() ){
          phraseInfo = ite.next();
          taken = true;
          if( phraseInfo == null ) break;
        }
        else
          break;
        if( phraseInfo.getEndOffset() <= en )
          wpil.add( phraseInfo );
        else
          break;
      }
      ffl.add( st, en, wpil );
View Full Code Here


    if( fragCharSize < minFragCharSize )
      throw new IllegalArgumentException( "fragCharSize(" + fragCharSize + ") is too small. It must be " + minFragCharSize + " or higher." );
   
    List<WeightedPhraseInfo> wpil = new ArrayList<WeightedPhraseInfo>();
    IteratorQueue<WeightedPhraseInfo> queue = new IteratorQueue<WeightedPhraseInfo>(fieldPhraseList.getPhraseList().iterator());
    WeightedPhraseInfo phraseInfo = null;
    int startOffset = 0;
    while((phraseInfo = queue.top()) != null){
      // if the phrase violates the border of previous fragment, discard it and try next phrase
      if( phraseInfo.getStartOffset() < startOffset )  {
        queue.removeTop();
        continue;
      }
     
      wpil.clear();
      final int currentPhraseStartOffset = phraseInfo.getStartOffset();
      int currentPhraseEndOffset = phraseInfo.getEndOffset();
      int spanStart = Math.max(currentPhraseStartOffset - margin, startOffset);
      int spanEnd = Math.max(currentPhraseEndOffset, spanStart + fragCharSize);
      if (acceptPhrase(queue.removeTop(),  currentPhraseEndOffset - currentPhraseStartOffset, fragCharSize)) {
        wpil.add(phraseInfo);
      }
      while((phraseInfo = queue.top()) != null) { // pull until we crossed the current spanEnd
        if (phraseInfo.getEndOffset() <= spanEnd) {
          currentPhraseEndOffset = phraseInfo.getEndOffset();
          if (acceptPhrase(queue.removeTop(),  currentPhraseEndOffset - currentPhraseStartOffset, fragCharSize)) {
            wpil.add(phraseInfo);
          }
        } else {
          break;
View Full Code Here

    FieldFragList ffl = new SimpleFieldFragList( fragCharSize );

    List<WeightedPhraseInfo> wpil = new ArrayList<WeightedPhraseInfo>();
    Iterator<WeightedPhraseInfo> ite = fieldPhraseList.phraseList.iterator();
    WeightedPhraseInfo phraseInfo = null;
    while( true ){
      if( !ite.hasNext() ) break;
      phraseInfo = ite.next();
      if( phraseInfo == null ) break;
View Full Code Here

      assertEquals( "a(1.0)((0,1))", fpl.phraseList.get( 0 ).toString() );     
  }
  */

  public void testWeightedPhraseInfoComparisonConsistency() {
    WeightedPhraseInfo a = newInfo( 0, 0, 1 );
    WeightedPhraseInfo b = newInfo( 1, 2, 1 );
    WeightedPhraseInfo c = newInfo( 2, 3, 1 );
    WeightedPhraseInfo d = newInfo( 0, 0, 1 );
    WeightedPhraseInfo e = newInfo( 0, 0, 2 );

    assertConsistentEquals( a, a );
    assertConsistentEquals( b, b );
    assertConsistentEquals( c, c );
    assertConsistentEquals( d, d );
View Full Code Here

  }

  private WeightedPhraseInfo newInfo( int startOffset, int endOffset, float boost ) {
    LinkedList< TermInfo > infos = new LinkedList< TermInfo >();
    infos.add( new TermInfo( _TestUtil.randomUnicodeString( random() ), startOffset, endOffset, 0, 0 ) );
    return new WeightedPhraseInfo( infos, boost );
  }
View Full Code Here

    FieldFragList ffl = new FieldFragList( fragCharSize );

    List<WeightedPhraseInfo> wpil = new ArrayList<WeightedPhraseInfo>();
    Iterator<WeightedPhraseInfo> ite = fieldPhraseList.phraseList.iterator();
    WeightedPhraseInfo phraseInfo = null;
    int startOffset = 0;
    boolean taken = false;
    while( true ){
      if( !taken ){
        if( !ite.hasNext() ) break;
        phraseInfo = ite.next();
      }
      taken = false;
      if( phraseInfo == null ) break;

      // if the phrase violates the border of previous fragment, discard it and try next phrase
      if( phraseInfo.getStartOffset() < startOffset ) continue;

      wpil.clear();
      wpil.add( phraseInfo );
      int st = phraseInfo.getStartOffset() - margin < startOffset ?
          startOffset : phraseInfo.getStartOffset() - margin;
      int en = st + fragCharSize;
      if( phraseInfo.getEndOffset() > en )
        en = phraseInfo.getEndOffset();
      startOffset = en;

      while( true ){
        if( ite.hasNext() ){
          phraseInfo = ite.next();
          taken = true;
          if( phraseInfo == null ) break;
        }
        else
          break;
        if( phraseInfo.getEndOffset() <= en )
          wpil.add( phraseInfo );
        else
          break;
      }
      ffl.add( st, en, wpil );
View Full Code Here

    if( fragCharSize < minFragCharSize )
      throw new IllegalArgumentException( "fragCharSize(" + fragCharSize + ") is too small. It must be " + minFragCharSize + " or higher." );
   
    List<WeightedPhraseInfo> wpil = new ArrayList<WeightedPhraseInfo>();
    Iterator<WeightedPhraseInfo> ite = fieldPhraseList.getPhraseList().iterator();
    WeightedPhraseInfo phraseInfo = null;
    int startOffset = 0;
    boolean taken = false;
    while( true ){
      if( !taken ){
        if( !ite.hasNext() ) break;
        phraseInfo = ite.next();
      }
      taken = false;
      if( phraseInfo == null ) break;

      // if the phrase violates the border of previous fragment, discard it and try next phrase
      if( phraseInfo.getStartOffset() < startOffset ) continue;

      wpil.clear();
      wpil.add( phraseInfo );
      int firstOffset = phraseInfo.getStartOffset();
      int st = phraseInfo.getStartOffset() - margin < startOffset ?
          startOffset : phraseInfo.getStartOffset() - margin;
      int en = st + fragCharSize;
      if( phraseInfo.getEndOffset() > en )
        en = phraseInfo.getEndOffset();

      int lastEndOffset = phraseInfo.getEndOffset();
      while( true ){
        if( ite.hasNext() ){
          phraseInfo = ite.next();
          taken = true;
          if( phraseInfo == null ) break;
        }
        else
          break;
        if( phraseInfo.getEndOffset() <= en ){
          wpil.add( phraseInfo );
          lastEndOffset = phraseInfo.getEndOffset();
        }
        else
          break;
      }
      int matchLen = lastEndOffset - firstOffset;
View Full Code Here

      assertEquals( "a(1.0)((0,1))", fpl.phraseList.get( 0 ).toString() );     
  }
  */

  public void testWeightedPhraseInfoComparisonConsistency() {
    WeightedPhraseInfo a = newInfo( 0, 0, 1 );
    WeightedPhraseInfo b = newInfo( 1, 2, 1 );
    WeightedPhraseInfo c = newInfo( 2, 3, 1 );
    WeightedPhraseInfo d = newInfo( 0, 0, 1 );
    WeightedPhraseInfo e = newInfo( 0, 0, 2 );

    assertConsistentEquals( a, a );
    assertConsistentEquals( b, b );
    assertConsistentEquals( c, c );
    assertConsistentEquals( d, d );
View Full Code Here

  }

  private WeightedPhraseInfo newInfo( int startOffset, int endOffset, float boost ) {
    LinkedList< TermInfo > infos = new LinkedList<>();
    infos.add( new TermInfo( TestUtil.randomUnicodeString(random()), startOffset, endOffset, 0, 0 ) );
    return new WeightedPhraseInfo( infos, boost );
  }
View Full Code Here

    if( fragCharSize < minFragCharSize )
      throw new IllegalArgumentException( "fragCharSize(" + fragCharSize + ") is too small. It must be " + minFragCharSize + " or higher." );
   
    List<WeightedPhraseInfo> wpil = new ArrayList<>();
    IteratorQueue<WeightedPhraseInfo> queue = new IteratorQueue<>(fieldPhraseList.getPhraseList().iterator());
    WeightedPhraseInfo phraseInfo = null;
    int startOffset = 0;
    while((phraseInfo = queue.top()) != null){
      // if the phrase violates the border of previous fragment, discard it and try next phrase
      if( phraseInfo.getStartOffset() < startOffset )  {
        queue.removeTop();
        continue;
      }
     
      wpil.clear();
      final int currentPhraseStartOffset = phraseInfo.getStartOffset();
      int currentPhraseEndOffset = phraseInfo.getEndOffset();
      int spanStart = Math.max(currentPhraseStartOffset - margin, startOffset);
      int spanEnd = Math.max(currentPhraseEndOffset, spanStart + fragCharSize);
      if (acceptPhrase(queue.removeTop(),  currentPhraseEndOffset - currentPhraseStartOffset, fragCharSize)) {
        wpil.add(phraseInfo);
      }
      while((phraseInfo = queue.top()) != null) { // pull until we crossed the current spanEnd
        if (phraseInfo.getEndOffset() <= spanEnd) {
          currentPhraseEndOffset = phraseInfo.getEndOffset();
          if (acceptPhrase(queue.removeTop(),  currentPhraseEndOffset - currentPhraseStartOffset, fragCharSize)) {
            wpil.add(phraseInfo);
          }
        } else {
          break;
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.vectorhighlight.FieldPhraseList.WeightedPhraseInfo

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.