Package edu.umd.cloud9.util.fd

Examples of edu.umd.cloud9.util.fd.Int2IntFrequencyDistributionEntry


      String[] alPair = alignment.split("-");
      int f = Integer.parseInt(alPair[0]);
      int e = Integer.parseInt(alPair[1]);

      if(!one2manyAlign.containsKey(f)){
        one2manyAlign.put(f, new ArrayListOfInts())
      }
      one2manyAlign.get(f).add(e);
    }

    // for each source token id, sort ids of its translations in ascending order
    for(Integer f : one2manyAlign.keySet()) {
      ArrayListOfInts lst = one2manyAlign.get(f);
      lst.sort();
      one2manyAlign.put(f, lst);
    }

    return one2manyAlign;
  }
View Full Code Here


      // Remember, token position is numbered started from one...
      if (positions.containsKey(term)) {
        positions.get(term).add(i + 1);
      } else {
        ArrayListOfInts l = new ArrayListOfInts();
        l.add(i + 1);
        positions.put(term, l);
      }
    }

    int doclength = 0;
    Iterator<Map.Entry<String, ArrayListOfInts>> it = positions.entrySet().iterator();
    Map.Entry<String, ArrayListOfInts> e;
    ArrayListOfInts positionsList;
    while (it.hasNext()) {
      e = it.next();
      positionsList = e.getValue();

      // We're storing tfs as shorts, so check for overflow...
      if (positionsList.size() >= TF_CUT) {
        // There are a few ways to handle this... If we're getting such a high tf, then it most
        // likely means that this is a junk doc.
        LOG.warn("Error: tf of " + e.getValue()
            + " will overflow max short value. docno=" + doc.getDocid() + ", term="
            + e.getKey());
        it.remove();
      } else {
        positionsList.trimToSize();
        doclength += positionsList.size();
      }
    }

    if ( positions.size() == 0 ) {
      return positions;
    }

    positions.put("", new ArrayListOfInts(new int[] { doclength }));
    return positions;
  }
View Full Code Here

    key.set("gold");
    reader.get(key, value);
    System.out.println("Complete postings list for 'gold': " + value);

    Int2IntFrequencyDistribution goldHist = new Int2IntFrequencyDistributionEntry();
    postings = value.getRightElement();
    for (PairOfInts pair : postings) {
      goldHist.increment(pair.getRightElement());
    }

    System.out.println("histogram of tf values for gold");
    for (PairOfInts pair : goldHist) {
      System.out.println(pair.getLeftElement() + "\t" + pair.getRightElement());
    }

    key.set("silver");
    reader.get(key, value);
    System.out.println("Complete postings list for 'silver': " + value);

    Int2IntFrequencyDistribution silverHist = new Int2IntFrequencyDistributionEntry();
    postings = value.getRightElement();
    for (PairOfInts pair : postings) {
      silverHist.increment(pair.getRightElement());
    }

    System.out.println("histogram of tf values for silver");
    for (PairOfInts pair : silverHist) {
      System.out.println(pair.getLeftElement() + "\t" + pair.getRightElement());
View Full Code Here

    assertEquals(5, list.get(3).getRightElement());
  }

  @Test
  public void testGetSortedEventsEntry() {
    Int2IntFrequencyDistribution fd = new Int2IntFrequencyDistributionEntry();
    testGetSortedEventsCommon(fd);
  }
View Full Code Here

    assertEquals(2, list.get(3).getRightElement());
  }

  @Test
  public void testIterableEntry() {
    Int2IntFrequencyDistribution fd = new Int2IntFrequencyDistributionEntry();
    testIterableCommon(fd);
  }
View Full Code Here

public class Int2IntFrequencyDistributionTest {

  @Test
  public void test1Entry() {
    Int2IntFrequencyDistribution fd = new Int2IntFrequencyDistributionEntry();
    test1Common(fd);
  }
View Full Code Here

    assertEquals(Math.log((float) 2 / 4), fd.computeLogRelativeFrequency(3), 10e-6);
  }

  @Test
  public void test2Entry() {
    Int2IntFrequencyDistribution fd = new Int2IntFrequencyDistributionEntry();
    test2Common(fd);
  }
View Full Code Here

    assertEquals(5, fd.get(4));
  }

  @Test
  public void test3Entry() {
    Int2IntFrequencyDistribution fd = new Int2IntFrequencyDistributionEntry();
    test3Common(fd);
  }
View Full Code Here

    assertEquals(0, fd.getSumOfCounts());
  }

  @Test(expected = RuntimeException.class)
  public void testFailedDecrement1Entry() {
    Int2IntFrequencyDistribution fd = new Int2IntFrequencyDistributionEntry();
    testFailedDecrement1Common(fd);
  }
View Full Code Here

    fd.decrement(1);
  }

  @Test(expected = RuntimeException.class)
  public void testFailedDecrement2Entry() {
    Int2IntFrequencyDistribution fd = new Int2IntFrequencyDistributionEntry();
    testFailedDecrement2Common(fd);
  }
View Full Code Here

TOP

Related Classes of edu.umd.cloud9.util.fd.Int2IntFrequencyDistributionEntry

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.