Examples of PairOfIntFloat


Examples of edu.umd.cloud9.io.pair.PairOfIntFloat

                String term = m2.group(1);
                if ( !term.equals("NULL") ) {
                  float prob = Float.parseFloat(m2.group(2));
                  int engIndex = trgVocab.addOrGet(term);
                  logger.debug("Added: "+term+" with index: "+engIndex+" and prob:"+prob);
                  indexProbPairs.add(new PairOfIntFloat(engIndex, prob));
                  sumOfProbs += prob;
                }
              }
            }
            // if number of translations not set, we never cut-off, so all cases are long tails
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntFloat

                String term = m2.group(1);
                if (!term.equals("NULL")) {
                  float prob = Float.parseFloat(m2.group(2));
                  int engIndex = trgVocab.addOrGet(term);
                  logger.debug("Added: "+term+" with index: "+engIndex+" and prob:"+prob);
                  indexProbPairs.add(new PairOfIntFloat(engIndex, prob));
                  sumOfProbs+=prob;
                }
              }
            }
            if(sumOfProbs > probThreshold){
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntFloat

              }else{
                String term = m2.group(1);
                float prob = Float.parseFloat(m2.group(2));
                int engIndex = trgVocab.addOrGet(term);
                logger.debug("Added: "+term+" with index: "+engIndex+" and prob:"+prob);
                indexProbPairs.add(new PairOfIntFloat(engIndex, prob));
                sumprob+=prob;
              }
            }
            if(sumprob > PROB_THRESHOLD){
              cntShortTail++;    // for statistical purposes only
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntFloat

public class PairOfIntFloatTest {

  @Test
  public void testBasic() throws IOException {
    PairOfIntFloat pair = new PairOfIntFloat(1, 2.0f);

    assertEquals(1.0f, pair.getLeftElement(), 10e-6);
    assertEquals(2.0f, pair.getRightElement(), 10e-6);
  }
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntFloat

    assertEquals(2.0f, pair.getRightElement(), 10e-6);
  }

  @Test
  public void testSerialize() throws IOException {
    PairOfIntFloat origPair = new PairOfIntFloat(1, 2.0f);

    ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
    DataOutputStream dataOut = new DataOutputStream(bytesOut);

    origPair.write(dataOut);

    PairOfIntFloat pair = new PairOfIntFloat();

    pair.readFields(new DataInputStream(new ByteArrayInputStream(bytesOut.toByteArray())));

    assertEquals(1.0f, pair.getLeftElement(), 10e-6);
    assertEquals(2.0f, pair.getRightElement(), 10e-6);
  }
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntFloat

    assertEquals(2.0f, pair.getRightElement(), 10e-6);
  }

  @Test
  public void testComparison1() throws IOException {
    PairOfIntFloat pair1 = new PairOfIntFloat(1, 2.0f);
    PairOfIntFloat pair2 = new PairOfIntFloat(1, 2.0f);
    PairOfIntFloat pair3 = new PairOfIntFloat(1, 1.0f);
    PairOfIntFloat pair4 = new PairOfIntFloat(0, 9.0f);
    PairOfIntFloat pair5 = new PairOfIntFloat(9, 0.0f);

    assertTrue(pair1.equals(pair2));
    assertFalse(pair1.equals(pair3));

    assertTrue(pair1.compareTo(pair2) == 0);
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntFloat

  @Test
  public void testComparison2() throws IOException {
    WritableComparator comparator = new PairOfIntFloat.Comparator();

    PairOfIntFloat pair1 = new PairOfIntFloat(1, 2.0f);
    PairOfIntFloat pair2 = new PairOfIntFloat(1, 2.0f);
    PairOfIntFloat pair3 = new PairOfIntFloat(1, 1.0f);
    PairOfIntFloat pair4 = new PairOfIntFloat(0, 9.0f);
    PairOfIntFloat pair5 = new PairOfIntFloat(9, 0.0f);

    assertTrue(WritableComparatorTestHarness.compare(comparator, pair1, pair2) == 0);
    assertTrue(WritableComparatorTestHarness.compare(comparator, pair1, pair3) > 0);
    assertTrue(WritableComparatorTestHarness.compare(comparator, pair1, pair4) > 0);
    assertTrue(WritableComparatorTestHarness.compare(comparator, pair1, pair5) < 0);
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntFloat

  public TopNScoredInts(int n) {
    queue = new ScoredIntPriorityQueue(n);
  }

  public void add(int n, float f) {
    queue.insert(new PairOfIntFloat(n, f));
  }
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntFloat

  // int numberOfTopics, int numberOfTerms, boolean approximateBeta) throws IOException {
  public static HMapIV<double[]> importBeta(SequenceFile.Reader sequenceFileReader,
      int numberOfTopics, int numberOfTerms) throws IOException {
    HMapIV<double[]> beta = new HMapIV<double[]>();

    PairOfIntFloat pairOfIntFloat = new PairOfIntFloat();

    HMapIDW hashMap = new HMapIDW();
    // HashMap hashMap = new HashMap();

    // ProbDist hashMap = null;
    // if (!approximateBeta) {
    // hashMap = new HashMap();
    // } else {
    // hashMap = new BloomMap();
    // }

    while (sequenceFileReader.next(pairOfIntFloat, hashMap)) {
      Preconditions.checkArgument(
          pairOfIntFloat.getLeftElement() > 0 && pairOfIntFloat.getLeftElement() <= numberOfTopics,
          "Invalid beta vector for term " + pairOfIntFloat.getLeftElement() + "...");

      // topic is from 1 to K
      int topicIndex = pairOfIntFloat.getLeftElement() - 1;
      double logNormalizer = pairOfIntFloat.getRightElement();
      // double logNormalizer = Math.log(pairOfIntFloat.getRightElement());
      // double logNormalizer = Math.log(hashMap.getNormalizeFactor());

      // logNormalizer = LogMath.add(pairOfIntFloat.getRightElement(),
      // Settings.DEFAULT_LOG_ETA + Math.log(numberOfTerms));
View Full Code Here

Examples of edu.umd.cloud9.io.pair.PairOfIntFloat

      Map<Integer, String> termIndex = new HashMap<Integer, String>();
      sequenceFileReader = new SequenceFile.Reader(fs, indexPath, conf);
      while (sequenceFileReader.next(intWritable, text)) {
        termIndex.put(intWritable.get(), text.toString());
      }
      PairOfIntFloat pairOfIntFloat = new PairOfIntFloat();
      // HMapIFW hmap = new HMapIFW();
      HMapIDW hmap = new HMapIDW();
      TreeMap<Double, Integer> treeMap = new TreeMap<Double, Integer>();
      sequenceFileReader = new SequenceFile.Reader(fs, betaPath, conf);
      while (sequenceFileReader.next(pairOfIntFloat, hmap)) {
        treeMap.clear();

        System.out.println("==============================");
        System.out.println("Top ranked " + topDisplay + " terms for Topic "
            + pairOfIntFloat.getLeftElement());
        System.out.println("==============================");

        Iterator<Integer> itr1 = hmap.keySet().iterator();
        int temp1 = 0;
        while (itr1.hasNext()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.