Java 类org.apache.lucene.index.DocsAndPositionsEnum 实例源码

项目:lams    文件:Lucene40TermVectorsReader.java   
@Override
public DocsAndPositionsEnum docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse, int flags) throws IOException {

  if (!storePositions && !storeOffsets) {
    return null;
  }

  TVDocsAndPositionsEnum docsAndPositionsEnum;
  if (reuse != null && reuse instanceof TVDocsAndPositionsEnum) {
    docsAndPositionsEnum = (TVDocsAndPositionsEnum) reuse;
  } else {
    docsAndPositionsEnum = new TVDocsAndPositionsEnum();
  }
  docsAndPositionsEnum.reset(liveDocs, positions, startOffsets, endOffsets, payloadOffsets, payloadData);
  return docsAndPositionsEnum;
}
项目:lams    文件:PhraseQuery.java   
public PostingsAndFreq(DocsAndPositionsEnum postings, int docFreq, int position, Term... terms) {
  this.postings = postings;
  this.docFreq = docFreq;
  this.position = position;
  nTerms = terms==null ? 0 : terms.length;
  if (nTerms>0) {
    if (terms.length==1) {
      this.terms = terms;
    } else {
      Term[] terms2 = new Term[terms.length];
      System.arraycopy(terms, 0, terms2, 0, terms.length);
      Arrays.sort(terms2);
      this.terms = terms2;
    }
  } else {
    this.terms = null;
  }
}
项目:lams    文件:MultiPhraseQuery.java   
public UnionDocsAndPositionsEnum(Bits liveDocs, AtomicReaderContext context, Term[] terms, Map<Term,TermContext> termContexts, TermsEnum termsEnum) throws IOException {
  List<DocsAndPositionsEnum> docsEnums = new LinkedList<>();
  for (int i = 0; i < terms.length; i++) {
    final Term term = terms[i];
    TermState termState = termContexts.get(term).get(context.ord);
    if (termState == null) {
      // Term doesn't exist in reader
      continue;
    }
    termsEnum.seekExact(term.bytes(), termState);
    DocsAndPositionsEnum postings = termsEnum.docsAndPositions(liveDocs, null, DocsEnum.FLAG_NONE);
    if (postings == null) {
      // term does exist, but has no positions
      throw new IllegalStateException("field \"" + term.field() + "\" was indexed without position data; cannot run PhraseQuery (term=" + term.text() + ")");
    }
    cost += postings.cost();
    docsEnums.add(postings);
  }

  _queue = new DocsQueue(docsEnums);
  _posList = new IntQueue();
}
项目:lams    文件:PayloadTermQuery.java   
protected void processPayload(Similarity similarity) throws IOException {
  if (termSpans.isPayloadAvailable()) {
    final DocsAndPositionsEnum postings = termSpans.getPostings();
    payload = postings.getPayload();
    if (payload != null) {
      payloadScore = function.currentScore(doc, term.field(),
                                           spans.start(), spans.end(), payloadsSeen, payloadScore,
                                           docScorer.computePayloadFactor(doc, spans.start(), spans.end(), payload));
    } else {
      payloadScore = function.currentScore(doc, term.field(),
                                           spans.start(), spans.end(), payloadsSeen, payloadScore, 1F);
    }
    payloadsSeen++;

  } else {
    // zero out the payload?
  }
}
项目:fangorn    文件:HalfPairJoinPipelineTest.java   
public void testSimplePipeExecuteCallsNextAfterItself() throws Exception {
    HalfPairJoinPipeline pipeline = new HalfPairJoinPipeline(npa,
            StaircaseJoin.JOIN_BUILDER);
    IndexReader rdr = setupIndexWithDocs("(S(A(B C))(B(A C)))");
    DocsAndPositionsEnum aPosEnum = getPosEnum(rdr, 0, new Term("s", "A"));
    DocsAndPositionsEnum bPosEnum = getPosEnum(rdr, 0, new Term("s", "B"));

    GetAllPipe a = pipeline.new GetAllPipe(aPosEnum);
    SimplePipe b = pipeline.new SimplePipe(bPosEnum,
            Operator.DESCENDANT, a);
    a.setNext(b);
    NodePositions prev = new NodePositions();

    pipeline.setPrevBuffer(prev);

    NodePositions out = a.execute();
    assertPositions(new int[] { 0, 1, 2, 2 }, 0, out);

    assertPositions(new int[] { 0, 1, 2, 2 }, 0, ((StaircaseJoin)b.join).result);
    assertPositions(new int[] { 0, 1, 1, 5, 1, 2, 2, 4 }, 4, prev);
    assertFalse(prev == ((StaircaseJoin)b.join).result); // prev and firstBuffer are distinct

    assertPositions(new int[] { 0, 1, 2, 2, 1, 2, 1, 5 }, 8, ((StaircaseJoin)b.join).next);
}
项目:fangorn    文件:IndexTestCase.java   
protected DocsAndPositionsEnum getPosEnum(IndexReader r, int docid, Term t)
        throws IOException {
    List<AtomicReaderContext> leaves = r.getContext().leaves();
    for (AtomicReaderContext context : leaves) {
        AtomicReader reader = context.reader();
        DocsAndPositionsEnum termPositions = reader.termPositionsEnum(t);
        int doc;
        while ((doc = termPositions.nextDoc()) != DocsEnum.NO_MORE_DOCS
                && doc != docid) {
        }
        if (doc != DocsEnum.NO_MORE_DOCS) {
            return termPositions;
        }
    }
    assertFalse("Expected positions enum for doc " + docid, true);
    return null; // will never come here
}
项目:fangorn    文件:MPMGMRRJoin.java   
@Override
public NodePositions match(NodePositions prev, DocsAndPositionsEnum node)
        throws IOException {
    int freq = node.freq();
    result.reset();
    int numNextRead = 0;
    int pmark = 0;
    while (numNextRead < freq) {
        if (pmark == prev.size)
            break;
        nodePositionAware.getNextPosition(result, node);
        numNextRead++;
        prev.offset = pmark;
        pmark = doJoin(prev, pmark);
    }
    return result;
}
项目:fangorn    文件:MPMGJoinTest.java   
public void testResultsOrderedBy1stsPositions() throws Exception {
    IndexReader r = setupIndexWithDocs("(AA(CC DD)(AA(CC DD)(CC DD))(CC DD))");
    DocsAndPositionsEnum posEnum = initPrevGetNext(r, 8);
    joinAndAssertOutput(24, 10, join, prev, Operator.DESCENDANT, posEnum);

    assertNodePairPositions(new int[] { 0, 4, 0, 0 }, new int[] { 0, 1, 2,
            1 }, 0, lrdp.getPositionLength());
    assertNodePairPositions(new int[] { 0, 4, 0, 0 }, new int[] { 1, 2, 3,
            2 }, 1, lrdp.getPositionLength());
    assertNodePairPositions(new int[] { 0, 4, 0, 0 }, new int[] { 2, 3, 3,
            3 }, 2, lrdp.getPositionLength());
    assertNodePairPositions(new int[] { 0, 4, 0, 0 }, new int[] { 3, 4, 2,
            5 }, 3, lrdp.getPositionLength());
    assertNodePairPositions(new int[] { 1, 3, 1, 6 }, new int[] { 1, 2, 3,
            2 }, 4, lrdp.getPositionLength());
    assertNodePairPositions(new int[] { 1, 3, 1, 6 }, new int[] { 2, 3, 3,
            3 }, 5, lrdp.getPositionLength());
}
项目:fangorn    文件:LookaheadTermEarlyPipelineTest.java   
public void testFollowingPrunesAllButLeftBottommostInGetAllPositionsPipeline()
        throws Exception {
    String sent = "(A(B(D A)(E A)))";
    IndexReader rdr = setupIndexWithDocs(sent);
    DocsAndPositionsEnum aPosEnum = getPosEnum(rdr, 0, new Term("s", "A"));
    LookaheadTermEarlyPipeline pipeline = new LookaheadTermEarlyPipeline(
            npa, null);
    pipeline.setPrevBuffer(new NodePositions());
    GetAllLookaheadPipe pipe = pipeline.new GetAllLookaheadPipe(aPosEnum,
            Operator.FOLLOWING);
    assertEquals(0, pipeline.buffer.size);
    assertEquals(0, pipeline.buffer.offset);
    assertEquals(0, pipeline.prevPositions.size);
    assertEquals(0, pipeline.prevPositions.offset);
    pipe.execute();
    assertEquals(4, pipeline.prevPositions.size);
    assertEquals(0, pipeline.prevPositions.offset);
    assertPositions(new int[] { 0, 1, 3, 1 }, 0, pipeline.prevPositions);
}
项目:fangorn    文件:LookaheadTermEarlyPipelineTest.java   
public void testDescendantPrunesAllButTopmostInGetAllPositionsPipeline()
        throws Exception {
    String sent = "(A(B(D A)(E A)))";
    IndexReader rdr = setupIndexWithDocs(sent);
    DocsAndPositionsEnum aPosEnum = getPosEnum(rdr, 0, new Term("s", "A"));
    LookaheadTermEarlyPipeline pipeline = new LookaheadTermEarlyPipeline(
            npa, null);
    pipeline.setPrevBuffer(new NodePositions());
    GetAllLookaheadPipe pipe = pipeline.new GetAllLookaheadPipe(aPosEnum,
            Operator.DESCENDANT);
    assertEquals(0, pipeline.buffer.size);
    assertEquals(0, pipeline.buffer.offset);
    assertEquals(0, pipeline.prevPositions.size);
    assertEquals(0, pipeline.prevPositions.offset);
    pipe.execute();
    assertEquals(4, pipeline.prevPositions.size);
    assertEquals(0, pipeline.prevPositions.offset);
    assertPositions(new int[] { 0, 2, 0, 0 }, 0, pipeline.prevPositions);
}
项目:fangorn    文件:FullPairJoinPipelineTest.java   
public void testSimplePipelineConstruction() throws Exception {
    IndexReader r = setupIndexWithDocs("(A(B(C D)))");

    FullPairJoinPipeline pipeline = new FullPairJoinPipeline(lrdp, join);
    DocsAndPositionsEnum aPosEnum = getPosEnum(r, 0, new Term("s", "A"));
    DocsAndPositionsEnum bPosEnum = getPosEnum(r, 0, new Term("s", "B"));
    DocsAndPositionsEnum cPosEnum = getPosEnum(r, 0, new Term("s", "C"));
    PostingsAndFreq c = getPf(cPosEnum, 2);
    PostingsAndFreq b = getPf(bPosEnum, 1, c);
    PostingsAndFreq a = getPf(aPosEnum, 0, b);

    Pipe pipeA = pipeline.createExecPipeline(a, new Operator[] {
            Operator.DESCENDANT, Operator.FOLLOWING,
            Operator.PRECEDING_SIBLING });
    assertFirstPipe(a, Operator.DESCENDANT, true, pipeA);

    Pipe pipeB = pipeA.getNext();
    assertSimplePipe(b, Operator.FOLLOWING, 0, true, pipeB);

    Pipe pipeC = pipeB.getNext();
    assertSimplePipe(c, Operator.PRECEDING_SIBLING, 1, false, pipeC);
}
项目:fangorn    文件:MPMGModJoinTest.java   
public void testResultsOrderedBy1stsPositions() throws Exception {
    IndexReader r = setupIndexWithDocs("(AA(CC DD)(AA(CC DD)(CC DD))(CC DD))");
    DocsAndPositionsEnum posEnum = initPrevGetNext(r, 8);
    joinAndAssertOutput(24, 14, join, prev, Operator.DESCENDANT, posEnum);

    assertNodePairPositions(new int[] { 0, 4, 0, 0 }, new int[] { 0, 1, 2,
            1 }, 0, lrdp.getPositionLength());
    assertNodePairPositions(new int[] { 0, 4, 0, 0 }, new int[] { 1, 2, 3,
            2 }, 1, lrdp.getPositionLength());
    assertNodePairPositions(new int[] { 0, 4, 0, 0 }, new int[] { 2, 3, 3,
            3 }, 2, lrdp.getPositionLength());
    assertNodePairPositions(new int[] { 0, 4, 0, 0 }, new int[] { 3, 4, 2,
            5 }, 3, lrdp.getPositionLength());
    assertNodePairPositions(new int[] { 1, 3, 1, 6 }, new int[] { 1, 2, 3,
            2 }, 4, lrdp.getPositionLength());
    assertNodePairPositions(new int[] { 1, 3, 1, 6 }, new int[] { 2, 3, 3,
            3 }, 5, lrdp.getPositionLength());
}
项目:fangorn    文件:LookaheadTermEarlyMRRJoinTest.java   
public void testPrecedingOpWithNonePreceding() throws Exception {
    String sent = "(SS(NN(FF WW))(ZZ(FF WW))(PP(PP WW)))";
    String term1 = "FF";
    String term2 = "PP";
    Operator op = Operator.PRECEDING;
    for (Operator nextOp : lookaheadOps) {
        IndexReader r = setupIndexWithDocs(sent);
        DocsAndPositionsEnum posEnum = initPrevGetNext(r, 8, 0, term1,
                term2);
        lookaheadJoinAndAssertOutput(0, 2, join, prev, op, nextOp, posEnum,
                0);
    }

    assertTermEarlyJoin(sent, term1, op, term2, 8, new int[] {}, 2);

    assertRegularJoin(sent, term1, op, term2, 8, new int[] {}, 2);
}
项目:lams    文件:SegmentTermsEnum.java   
@Override
public DocsAndPositionsEnum docsAndPositions(Bits skipDocs, DocsAndPositionsEnum reuse, int flags) throws IOException {
  if (fr.fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
    // Positions were not indexed:
    return null;
  }

  assert !eof;
  currentFrame.decodeMetaData();
  return fr.parent.postingsReader.docsAndPositions(fr.fieldInfo, currentFrame.state, skipDocs, reuse, flags);
}
项目:lams    文件:IntersectTermsEnum.java   
@Override
public DocsAndPositionsEnum docsAndPositions(Bits skipDocs, DocsAndPositionsEnum reuse, int flags) throws IOException {
  if (fr.fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
    // Positions were not indexed:
    return null;
  }

  currentFrame.decodeMetaData();
  return fr.parent.postingsReader.docsAndPositions(fr.fieldInfo, currentFrame.termState, skipDocs, reuse, flags);
}
项目:lams    文件:CompressingTermVectorsReader.java   
@Override
public DocsAndPositionsEnum docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse, int flags) throws IOException {
  if (positions == null && startOffsets == null) {
    return null;
  }
  // TODO: slightly sheisty
  return (DocsAndPositionsEnum) docs(liveDocs, reuse, flags);
}
项目:lams    文件:Lucene3xTermVectorsReader.java   
@Override
public DocsAndPositionsEnum docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse, int flags) throws IOException {
  if (!storePositions && !storeOffsets) {
    return null;
  }

  TVDocsAndPositionsEnum docsAndPositionsEnum;
  if (reuse != null && reuse instanceof TVDocsAndPositionsEnum) {
    docsAndPositionsEnum = (TVDocsAndPositionsEnum) reuse;
  } else {
    docsAndPositionsEnum = new TVDocsAndPositionsEnum();
  }
  docsAndPositionsEnum.reset(liveDocs, termAndPostings[currentTerm]);
  return docsAndPositionsEnum;
}
项目:lams    文件:Lucene3xFields.java   
@Override
public DocsAndPositionsEnum docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse, int flags) throws IOException {
  PreDocsAndPositionsEnum docsPosEnum;
  if (fieldInfo.getIndexOptions() != IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) {
    return null;
  } else if (reuse == null || !(reuse instanceof PreDocsAndPositionsEnum)) {
    docsPosEnum = new PreDocsAndPositionsEnum();
  } else {
    docsPosEnum = (PreDocsAndPositionsEnum) reuse;
    if (docsPosEnum.getFreqStream() != freqStream) {
      docsPosEnum = new PreDocsAndPositionsEnum();
    }
  }
  return docsPosEnum.reset(termEnum, liveDocs);        
}
项目:lams    文件:Lucene41PostingsReader.java   
@Override
public DocsAndPositionsEnum docsAndPositions(FieldInfo fieldInfo, BlockTermState termState, Bits liveDocs,
                                             DocsAndPositionsEnum reuse, int flags)
  throws IOException {

  boolean indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
  boolean indexHasPayloads = fieldInfo.hasPayloads();

  if ((!indexHasOffsets || (flags & DocsAndPositionsEnum.FLAG_OFFSETS) == 0) &&
      (!indexHasPayloads || (flags & DocsAndPositionsEnum.FLAG_PAYLOADS) == 0)) {
    BlockDocsAndPositionsEnum docsAndPositionsEnum;
    if (reuse instanceof BlockDocsAndPositionsEnum) {
      docsAndPositionsEnum = (BlockDocsAndPositionsEnum) reuse;
      if (!docsAndPositionsEnum.canReuse(docIn, fieldInfo)) {
        docsAndPositionsEnum = new BlockDocsAndPositionsEnum(fieldInfo);
      }
    } else {
      docsAndPositionsEnum = new BlockDocsAndPositionsEnum(fieldInfo);
    }
    return docsAndPositionsEnum.reset(liveDocs, (IntBlockTermState) termState);
  } else {
    EverythingEnum everythingEnum;
    if (reuse instanceof EverythingEnum) {
      everythingEnum = (EverythingEnum) reuse;
      if (!everythingEnum.canReuse(docIn, fieldInfo)) {
        everythingEnum = new EverythingEnum(fieldInfo);
      }
    } else {
      everythingEnum = new EverythingEnum(fieldInfo);
    }
    return everythingEnum.reset(liveDocs, (IntBlockTermState) termState, flags);
  }
}
项目:lams    文件:MultiPhraseQuery.java   
DocsQueue(List<DocsAndPositionsEnum> docsEnums) throws IOException {
  super(docsEnums.size());

  Iterator<DocsAndPositionsEnum> i = docsEnums.iterator();
  while (i.hasNext()) {
    DocsAndPositionsEnum postings = i.next();
    if (postings.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
      add(postings);
    }
  }
}
项目:lams    文件:MultiPhraseQuery.java   
@Override
public final int nextDoc() throws IOException {
  if (_queue.size() == 0) {
    return NO_MORE_DOCS;
  }

  // TODO: move this init into positions(): if the search
  // doesn't need the positions for this doc then don't
  // waste CPU merging them:
  _posList.clear();
  _doc = _queue.top().docID();

  // merge sort all positions together
  DocsAndPositionsEnum postings;
  do {
    postings = _queue.top();

    final int freq = postings.freq();
    for (int i = 0; i < freq; i++) {
      _posList.add(postings.nextPosition());
    }

    if (postings.nextDoc() != NO_MORE_DOCS) {
      _queue.updateTop();
    } else {
      _queue.pop();
    }
  } while (_queue.size() > 0 && _queue.top().docID() == _doc);

  _posList.sort();
  _freq = _posList.size();

  return _doc;
}
项目:lams    文件:MultiPhraseQuery.java   
@Override
public final int advance(int target) throws IOException {
  while (_queue.top() != null && target > _queue.top().docID()) {
    DocsAndPositionsEnum postings = _queue.pop();
    if (postings.advance(target) != NO_MORE_DOCS) {
      _queue.add(postings);
    }
  }
  return nextDoc();
}
项目:fangorn    文件:LRDP.java   
public void getAllPositions(NodePositions buffer, DocsAndPositionsEnum node)
        throws IOException {
    int freq = node.freq();
    int posIndex = 0;
    buffer.reset();
    while (posIndex < freq) {
        getNextPosition(buffer, node);
        posIndex++;
    }
    // reset buffer offset
    buffer.offset = 0;
}
项目:fangorn    文件:MPMGModSingleJoinTest.java   
@Test
public void testNoResultsDesc() throws Exception {
    IndexReader r = setupIndexWithDocs("(DD(BB AA)(BB AA))");
    DocsAndPositionsEnum posEnum = initPrevGetNext(r, 8);
    joinAndAssertOutput(0, 3, jb, prev, Operator.DESCENDANT, posEnum);
    // 2 comparisons in MPMG
}
项目:fangorn    文件:LookaheadTermEarlyPipeline.java   
public LookaheadPipe(DocsAndPositionsEnum node, Operator op,
        Operator nextOp, Pipe prev) {
    super(node, prev);
    join = lateJoinBuilder.getHalfPairJoin(op, nodePositionAware);
    this.op = op;
    this.nextOp = nextOp;
}
项目:fangorn    文件:MPMGModSingleJoinTest.java   
@Test
public void testTree1Desc() throws Exception {
    IndexReader r = setupIndexWithDocs("(DD(AA DD)(AA CC)(AA CC))");
    DocsAndPositionsEnum posEnum = initPrevGetNext(r, 12);
    joinAndAssertOutput(4, 5, jb, prev, Operator.DESCENDANT, posEnum);
    // was 5 comparisons in MPMG
}
项目:fangorn    文件:MPMGMRRJoinTest.java   
@Test
public void testTree1Desc() throws Exception {
    IndexReader r = setupIndexWithDocs("(DD(AA DD)(AA CC)(AA CC))");
    DocsAndPositionsEnum posEnum = initPrevGetNext(r, 12);
    joinAndAssertOutput(4, 4, jb, prev, Operator.DESCENDANT, posEnum);
    // was 5 comparisons in MPMG
}
项目:fangorn    文件:MPMGJoin.java   
@Override
public void match(NodePositions prev, Operator op,
        DocsAndPositionsEnum node, NodePairPositions result) throws IOException {
    buffer.reset();
    result.reset();
    prev.offset = 0;
    nodePositionAware.getAllPositions(buffer, node);
    int nmark = 0;

    while (prev.offset + positionLength <= prev.size) {
        if (buffer.offset == buffer.size) {
            prev.offset += positionLength;
            buffer.offset = nmark;
        } else if (op.match(prev, buffer, operatorAware)) {
            // if next descendant/child
            result.add(prev, buffer, positionLength);
            buffer.offset += positionLength;
        } else if (operatorAware.startsBefore(prev.positions, prev.offset, buffer.positions, buffer.offset)) {
            buffer.offset += positionLength;
            nmark = buffer.offset;
        } else if (Operator.DESCENDANT.equals(op)
                || !operatorAware.descendant(prev.positions, prev.offset, buffer.positions, buffer.offset)) {
            // desc: skip to next prev
            // child: skip if not descendant
            prev.offset += positionLength;
            buffer.offset = nmark;
        } else { // is descendant but op is child so just iterate
            buffer.offset += positionLength;
        }
    }
}
项目:fangorn    文件:LookaheadTermEarlyJoinTest.java   
private void assertRegularJoin(String sent, String term1, Operator op,
        String term2, int expectedTerm1Num, int[] expectedResults,
        int expectedNumComparisons) throws IOException {
    IndexReader r = setupIndexWithDocs(sent);
    DocsAndPositionsEnum posEnum = initPrevGetNext(r, expectedTerm1Num, 0,
            term1, term2);
    joinAndAssertOutput(expectedResults.length, expectedNumComparisons, jb,
            prev, op, posEnum);
    int expectedOffset = expectedResults.length - 4;
    assertPositions(expectedResults, expectedOffset < 0 ? 0
            : expectedOffset, bufferResult);
}
项目:fangorn    文件:MPMGModSingleJoinTest.java   
@Test
public void testNoResultsChild() throws Exception {
    IndexReader r = setupIndexWithDocs("(DD(BB AA)(BB AA))");
    DocsAndPositionsEnum posEnum = initPrevGetNext(r, 8);
    joinAndAssertOutput(0, 3, jb, prev, Operator.CHILD, posEnum);
    // 2 comparisons in MPMG
}
项目:fangorn    文件:MPMGModSingleJoinTest.java   
@Test
public void testTree2Child() throws Exception {
    IndexReader r = setupIndexWithDocs("(AA(CC DD)(AA(CC DD)(CC DD))(CC DD))");
    DocsAndPositionsEnum posEnum = initPrevGetNext(r, 8);
    joinAndAssertOutput(0, 20, jb, prev, Operator.CHILD, posEnum);
    // was 23 in MPMG
}
项目:fangorn    文件:StaircaseJoinTest.java   
public void testAncestorOpWithNestedDescendants() throws Exception {
    IndexReader r = setupIndexWithDocs("(SS(AA(PP WW)(AA(DD WW)))(ZZ(DD ww))(AA(FF WW))(AA(DD(AA WW))))");
    DocsAndPositionsEnum posEnum = initPrevGetNext(r, 12, 0, "DD", "AA");
    joinAndAssertOutput(12, 13, jb, prev, Operator.ANCESTOR, posEnum);
    assertPositions(new int[] { 0, 2, 1, 12, 1, 2, 2, 4, 4, 5, 1, 12 }, 8,
            bufferResult);
}
项目:fangorn    文件:MPMGMRRJoinTest.java   
@Test
public void testTree3Child() throws Exception {
    IndexReader r = setupIndexWithDocs("(AA(AA DD)(AA DD)(AA DD))");
    DocsAndPositionsEnum posEnum = initPrevGetNext(r, 16);
    joinAndAssertOutput(12, 9, jb, prev, Operator.CHILD, posEnum);
    // was 22 in MPMG
}
项目:fangorn    文件:StaircaseJoinTest.java   
public void testParentError() throws Exception {
    String sent = "(S1 (S (PP (IN In) (NP (NP (NNP September)) (, ,) (NP (CD 2008)))) (, ,) (NP (DT the) (NN organization)) (VP (VBD marked) (NP (NP (NP (DT the) (JJ 5th) ('' ') (NN anniversary) ('' ')) (PP (IN of) (NP (NP (NP (DT the) (NNP RIAA) (POS 's)) (NN litigation) (NN campaign)) (PP (IN by) (S (VP (VBG publishing) (NP (DT a) (ADJP (RB highly) (JJ critical)) (, ,) (JJ detailed) (NN report))))) (, ,) (VP (VBN entitled) ('' ') (NP (NNP RIAA)) (PP (IN v.) (NP (NNP The) (NNP People))))))) (: :) (NP (NP (CD Five) (NNS Years)) (RB Later) (POS '))) (, ,) (S (VP (VBG concluding) (SBAR (IN that) (S (NP (DT the) (NN campaign)) (VP (AUX was) (NP (DT a) (NN failure)))))))) (. .)))";
    IndexReader r = setupIndexWithDocs(sent);
    DocsAndPositionsEnum posEnum = initPrevGetNext(r, 20, 0, "VP", "NP");
    joinAndAssertOutput(4, 99, jb, prev, Operator.PARENT, posEnum);
    assertPositions(new int[] { 14, 34, 6, 53 }, 0, bufferResult);
}
项目:fangorn    文件:StaircaseJoinTest.java   
public void testImmediateFollowingSibling() throws Exception {
    String sent = "(N(P(P(P(P(N A)(P B))(P C)(N D)(P N)(P E)))(N F)))";
    IndexReader r = setupIndexWithDocs(sent);
    DocsAndPositionsEnum posEnum = initPrevGetNext(r, 32, 0, "P", "N");
    joinAndAssertOutput(8, 50, jb, prev,
            Operator.IMMEDIATE_FOLLOWING_SIBLING, posEnum);
    assertPositions(new int[] { 3, 4, 4, 8, 6, 7, 2, 11 }, 4, bufferResult);
}
项目:fangorn    文件:HalfPairJoinPipelineTest.java   
public void testReturnsSingleGetAllPipeForDescendant1stOp()
        throws Exception {
    IndexReader r = setupIndexWithDocs("(A(B C))");
    HalfPairJoinPipeline pipeline = new HalfPairJoinPipeline(npa,
            StaircaseJoin.JOIN_BUILDER);
    DocsAndPositionsEnum aPosEnum = getPosEnum(r, 0, new Term("s", "A"));
    PostingsAndFreq pfRoot = getPf(aPosEnum, 0);
    Pipe p = pipeline.createExecPipeline(pfRoot,
            new Operator[] { Operator.DESCENDANT });
    assertGetAllPipe(aPosEnum, false, p);
}
项目:fangorn    文件:MPMGMRRJoinTest.java   
@Test
public void testTree2Child() throws Exception {
    IndexReader r = setupIndexWithDocs("(AA(CC DD)(AA(CC DD)(CC DD))(CC DD))");
    DocsAndPositionsEnum posEnum = initPrevGetNext(r, 8);
    joinAndAssertOutput(0, 8, jb, prev, Operator.CHILD, posEnum);
    // was 23 in MPMG
}
项目:fangorn    文件:MPMGJoinTest.java   
public void testDoesNotMatch() throws Exception {
    String sent = "(S1 (S (S (NP (NNP Chubb)) (VP (VBP &amp))) (: ;) (S (NP (NNP Co) (NN insurance) (NN company)) (VP (VP (AUX was) (RB not) (VP (VBN convinced) (PP (IN of) (NP (NP (DT the) (NN claim)) (PP (IN of) (NP (VBN stolen) (NN jewelry))))))) (CC and) (VP ( VBD accused) (NP (NNP Millard)) (PP (IN of) (NP (NN insurance) (NN fraud)))))) (. .)))";
    IndexReader r = setupIndexWithDocs(sent);
    DocsAndPositionsEnum vpPosEnum = initPrevGetNext(r, 28, 0, "NP", "VP");

    joinAndAssertOutput(0, 20, join, prev, Operator.DESCENDANT, vpPosEnum);
}
项目:fangorn    文件:StaircaseJoinTest.java   
public void testImmediatePreceding() throws Exception {
    String sent = "(N(P(P(P(P(N A)(P B))(P C)(N D)(P N)(P E)))(N F)))";
    IndexReader r = setupIndexWithDocs(sent);
    DocsAndPositionsEnum posEnum = initPrevGetNext(r, 20, 0, "N", "P");
    joinAndAssertOutput(16, 50, jb, prev, Operator.IMMEDIATE_PRECEDING,
            posEnum);
    assertPositions(new int[] { 0, 6, 2, 11, 0, 6, 3, 9, 2, 3, 4, 8, 5, 6,
            4, 8 }, 12, bufferResult);
}
项目:fangorn    文件:MPMGMRRJoinTest.java   
@Test
public void testTree3Desc() throws Exception {
    IndexReader r = setupIndexWithDocs("(AA(AA DD)(AA DD)(AA DD))");
    DocsAndPositionsEnum posEnum = initPrevGetNext(r, 16);
    joinAndAssertOutput(12, 3, jb, prev, Operator.DESCENDANT, posEnum);
    // was 14 in MPMG
}