Examples of PairOfStringFloat


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

      float sumProb2 = 0;
      for (Entry<String> entry : probDist.entrySet()) {
        float pr = entry.getValue() / sumProb;
        if (pr > lexProbThreshold) {
          sumProb2 += pr;
          sortedFilteredProbDist.add(new PairOfStringFloat(entry.getKey(), pr));
        }
      }

      // re-normalize values after removal of low-prob entries
      float cumProb = 0;
      int cnt = 0;
      while (cnt < maxNumTrans && cumProb < cumProbThreshold && !sortedFilteredProbDist.isEmpty()) {
        PairOfStringFloat entry = sortedFilteredProbDist.pollLast();
        float pr = entry.getValue() / sumProb2;
        cumProb += pr;
        normProbDist.put(entry.getKey(), pr);
        cnt++;
      }

      probMap.put(sourceTerm, normProbDist);
    }
View Full Code Here

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

      float sumProb2 = 0;
      for (Entry<String> entry : probDist.entrySet()) {
        float pr = entry.getValue() / sumProb;
        if (pr > lexProbThreshold) {
          sumProb2 += pr;
          sortedFilteredProbDist.add(new PairOfStringFloat(entry.getKey(), pr));
        }
      }

      // re-normalize values after removal of low-prob entries
      float cumProb = 0;
      int cnt = 0;
      while (cnt < maxNumTrans && cumProb < cumProbThreshold && !sortedFilteredProbDist.isEmpty()) {
        PairOfStringFloat entry = sortedFilteredProbDist.pollLast();
        float pr = entry.getValue() / sumProb2;
        cumProb += pr;
        normProbDist.put(entry.getKey(), pr);
        cnt++;
      }

      probMap.put(sourceTerm, normProbDist);
    }
View Full Code Here

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

    assertTrue(pair.getRightElement() == 1.0f);
  }

  @Test
  public void testSerialize() throws IOException {
    PairOfStringFloat origPair = new PairOfStringFloat("hi", 2.0f);

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

    origPair.write(dataOut);

    PairOfStringFloat pair = new PairOfStringFloat();

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

    assertEquals("hi", pair.getLeftElement());
    assertTrue(pair.getRightElement() == 2.0f);
  }
View Full Code Here

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

    assertTrue(pair.getRightElement() == 2.0f);
  }

  @Test
  public void testComparison1() throws IOException {
    PairOfStringFloat pair1 = new PairOfStringFloat("hi", 1.0f);
    PairOfStringFloat pair2 = new PairOfStringFloat("hi", 1.0f);
    PairOfStringFloat pair3 = new PairOfStringFloat("hi", 0.0f);
    PairOfStringFloat pair4 = new PairOfStringFloat("a", 0.0f);
    PairOfStringFloat pair5 = new PairOfStringFloat("hi", 2.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.PairOfStringFloat

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

    PairOfStringFloat pair1 = new PairOfStringFloat("hi", 1.0f);
    PairOfStringFloat pair2 = new PairOfStringFloat("hi", 1.0f);
    PairOfStringFloat pair3 = new PairOfStringFloat("hi", 0.0f);
    PairOfStringFloat pair4 = new PairOfStringFloat("a", 0.0f);
    PairOfStringFloat pair5 = new PairOfStringFloat("hi", 2.0f);
   
    assertTrue(pair1.equals(pair2));
    assertFalse(pair1.equals(pair3));

    assertTrue(WritableComparatorTestHarness.compare(comparator, pair1, pair2) == 0);
View Full Code Here

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

public class PairOfStringFloatTest {

  @Test
  public void testBasic() throws IOException {
    PairOfStringFloat pair = new PairOfStringFloat("hi", 1.0f);

    assertEquals("hi", pair.getLeftElement());
    assertTrue(pair.getRightElement() == 1.0f);
  }
View Full Code Here

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

      float sumProb2 = 0;
      for (Entry<String> entry : probDist.entrySet()) {
        float pr = entry.getValue() / sumProb;
        if (pr > lexProbThreshold) {
          sumProb2 += pr;
          sortedFilteredProbDist.add(new PairOfStringFloat(entry.getKey(), pr));
        }
      }

      // re-normalize values after removal of low-prob entries
      float cumProb = 0;
      int cnt = 0;
      while (cnt < maxNumTrans && cumProb < cumProbThreshold && !sortedFilteredProbDist.isEmpty()) {
        PairOfStringFloat entry = sortedFilteredProbDist.pollLast();
        float pr = entry.getValue() / sumProb2;
        cumProb += pr;
        normProbDist.put(entry.getKey(), pr);
        cnt++;
      }

      probMap.put(sourceTerm, normProbDist);
    }
View Full Code Here

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

      float sumProb2 = 0;
      for (Entry<String> entry : probDist.entrySet()) {
        float pr = entry.getValue() / sumProb;
        if (pr > lexProbThreshold) {
          sumProb2 += pr;
          sortedFilteredProbDist.add(new PairOfStringFloat(entry.getKey(), pr));
        }
      }

      // re-normalize values after removal of low-prob entries
      float cumProb = 0;
      int cnt = 0;
      while (cnt < maxNumTrans && cumProb < cumProbThreshold && !sortedFilteredProbDist.isEmpty()) {
        PairOfStringFloat entry = sortedFilteredProbDist.pollLast();
        float pr = entry.getValue() / sumProb2;
        cumProb += pr;
        normProbDist.put(entry.getKey(), pr);
        cnt++;
      }

      probMap.put(sourceTerm, normProbDist);
    }
View Full Code Here

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

      float sumProb2 = 0;
      for (Entry<String> entry : probDist.entrySet()) {
        float pr = entry.getValue() / sumProb;
        if (pr > lexProbThreshold) {
          sumProb2 += pr;
          sortedFilteredProbDist.add(new PairOfStringFloat(entry.getKey(), pr));
        }
      }

      // re-normalize values after removal of low-prob entries
      float cumProb = 0;
      int cnt = 0;
      while (cnt < maxNumTrans && cumProb < cumProbThreshold && !sortedFilteredProbDist.isEmpty()) {
        PairOfStringFloat entry = sortedFilteredProbDist.pollLast();
        float pr = entry.getValue() / sumProb2;
        cumProb += pr;
        normProbDist.put(entry.getKey(), pr);
        cnt++;
      }

      probMap.put(sourceTerm, normProbDist);
    }
View Full Code Here

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

      float sumProb2 = 0;
      for (Entry<String> entry : probDist.entrySet()) {
        float pr = entry.getValue() / sumProb;
        if (pr > lexProbThreshold) {
          sumProb2 += pr;
          sortedFilteredProbDist.add(new PairOfStringFloat(entry.getKey(), pr));
        }
      }

      // re-normalize values after removal of low-prob entries
      float cumProb = 0;
      int cnt = 0;
      while (cnt < maxNumTrans && cumProb < cumProbThreshold && !sortedFilteredProbDist.isEmpty()) {
        PairOfStringFloat entry = sortedFilteredProbDist.pollLast();
        float pr = entry.getValue() / sumProb2;
        cumProb += pr;
        normProbDist.put(entry.getKey(), pr);
        cnt++;
      }

      probMap.put(sourceTerm, normProbDist);
    }
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.