Package org.terrier.structures.postings

Examples of org.terrier.structures.postings.FieldPosting


  /**
   * {@inheritDoc}
   */
  public double score(Posting _p)
  {
    FieldPosting p = (FieldPosting)_p;
    if (requirement)
    {
      if (p.getFieldFrequencies()[fieldIndex] == 0)
      {
        return Double.NEGATIVE_INFINITY;
      }
    }
    else
    {
      if (p.getFieldFrequencies()[fieldIndex] > 0)
        return Double.NEGATIVE_INFINITY;
    }
    return 0;
  }
View Full Code Here


    super.prepare();
  }

  @Override
  public double score(Posting _p) {
    FieldPosting p = (FieldPosting)_p;
    final int[] tff = p.getFieldFrequencies();
    final int[] fieldLengths = p.getFieldLengths();
    final double[] normFieldFreqs = new double[fieldCount];
    for(int i=0;i<fieldCount;i++)
    {
      normFieldFreqs[i] = fieldWeights[i] * fieldNormalisations[i].normalise(tff[i], fieldLengths[i], fieldGlobalFrequencies[i]);
    }
    final double tf = StaTools.sum(normFieldFreqs);
    return basicModel.score(tf, super.documentFrequency, super.termFrequency, super.keyFrequency, p.getDocumentLength());
  }
View Full Code Here

    fieldTermFrequencies = ((FieldEntryStatistics)_es).getFieldFrequencies();
  }

  @Override
  public double score(Posting _p) {
    FieldPosting fp = (FieldPosting)_p;
    double q = 1.0d;
    double score = initialScore;
    double tf_q = super.termFrequency;
    final int[] tff = fp.getFieldFrequencies();
    final int[] fieldLengths = fp.getFieldLengths();
    for(int fi = 0; fi < fieldCount; fi++)
    {
      if (tff[fi] == 0)
        continue;
      final double tfn_i = this.fieldNormalisations[fi].normalise(tff[fi], fieldLengths[fi], fieldTermFrequencies[fi]);
View Full Code Here

    fieldTermFrequencies = ((FieldEntryStatistics)_es).getFieldFrequencies();
  }

  @Override
  public double score(Posting _p) {
    FieldPosting fp = (FieldPosting)_p;
    double q = 1.0d;
    double tf_q = super.termFrequency;
    final int[] tff = fp.getFieldFrequencies();
    final int[] fieldLengths = fp.getFieldLengths();
   
    double fieldsWithTerm = 0;
    for(int fi = 0; fi < fieldCount; fi++)
    {
      if (tff[fi] > 0)
View Full Code Here

  }

  @Override
  protected void writePostingNotDocid(Posting _p) throws IOException {
    super.writePostingNotDocid(_p);
    final FieldPosting p = (FieldPosting)_p;
    for(int fieldFrequency : p.getFieldFrequencies())
    {
      super.output.writeUnary(fieldFrequency+1);
    }
    //System.err.println("FieldDirectInvertedOutputStream: " + ArrayUtils.join(p.getFieldFrequencies(), ","));
  }
View Full Code Here

      // for each document
      for (int d = 0; d < dirTfs.length; d++) {
        DocumentIndexEntry de = documentIndex.getDocumentEntry(d);
        assertNotNull(de);
        ip = directIndex.getPostings((BitIndexPointer) de);
        FieldPosting fp = fieldsExpected ? (FieldPosting)ip : null;
        // for each term
        int t = 0;
        int countFoundTerms = 0;
        while (ip.next() != IterablePosting.EOL) {
          int termid = ip.getId();
          assertTrue(termid >= 0);
          String term = lexicon.getLexiconEntry(termid).getKey();
          assertNotNull(term);
          countFoundTerms++;
          assertTrue(dirTfs[d].containsKey(term));
          assertEquals(dirTfs[d].get(term), ip.getFrequency());
          assertEquals(doclens[d], ip.getDocumentLength());         
         
          if (fieldsExpected) {
            assertEquals(2, fp.getFieldFrequencies().length);
            for (int f = 0; f < 2; f++) {
              assertEquals(dirFfs[d].get(term)[f], fp.getFieldFrequencies()[f]);
            }
          }
          t++;
        }
        assertEquals(dirTfs[d].size() ,countFoundTerms);
        ip.close();
      }
      // post-check
      assertEquals(IterablePosting.EOL, ip.next());

      /**
       * Test {@link IterablePosting} entries from a {@link DirectIndexInputStream}
       */
      bpiis = (BitPostingIndexInputStream) index.getIndexStructureInputStream("direct");
      assertNotNull(bpiis);
      // for each document
      for (int d = 0; d < dirTfs.length; d++) {
        assertTrue(bpiis.hasNext());
        ip = bpiis.next();
        assertNotNull(ip);
        FieldPosting fp = fieldsExpected ? (FieldPosting)ip : null;
        // for each term
        int t = 0;
        int countFoundTerms = 0;
        while (ip.next() != IterablePosting.EOL) {
          int termid = ip.getId();
          assertTrue(termid >= 0);
          String term = lexicon.getLexiconEntry(termid).getKey();
          assertNotNull(term);
          countFoundTerms++;
          assertTrue(dirTfs[d].containsKey(term));
          assertEquals(dirTfs[d].get(term), ip.getFrequency());
          assertEquals(doclens[d], ip.getDocumentLength());         
         
          if (fieldsExpected) {
            assertEquals(2, fp.getFieldFrequencies().length);
            for (int f = 0; f < 2; f++) {
              assertEquals(dirFfs[d].get(term)[f], fp.getFieldFrequencies()[f]);
            }
          }
          t++;
        }
        assertEquals(dirTfs[d].size() ,countFoundTerms);
View Full Code Here

TOP

Related Classes of org.terrier.structures.postings.FieldPosting

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.