Package edu.umd.cloud9.io.pair

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


    if (featSet > 2) {
      // uppercase token matching features : find uppercased tokens that exactly appear on both sides
      // lack of this evidence does not imply anything, but its existence might indicate parallel
//      fSentence.replaceAll("([',:;.?%!])", " $1 ");
//      eSentence.replaceAll("([',:;.?%!])", " $1 ");
      PairOfFloats pair = getUppercaseRatio(fTokenizer.processContent(fSentence), eTokenizer.processContent(eSentence));
      features.add("uppercaseratio1=" + pair.getLeftElement() );
      features.add("uppercaseratio2=" + pair.getRightElement() );
    }

    if (featSet > 3) {
      // future work = count number of single/double letter words in src and trg side
View Full Code Here


    // now, read tokens in first sentence and keep track of sequences of uppercased tokens in buffer
    HashSet<String> upperCaseMap1 = getUppercaseParts(tokens1);
    HashSet<String> upperCaseMap2 = getUppercaseParts(tokens2);
    float cntUpperRatio1 = getRatio(upperCaseMap1, upperCaseMap2);
    float cntUpperRatio2 = getRatio(upperCaseMap2, upperCaseMap1);
    PairOfFloats result = new PairOfFloats(cntUpperRatio1, cntUpperRatio2);
    return result;
  }
View Full Code Here

                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

                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

              }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

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

    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

    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

  @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

  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

TOP

Related Classes of edu.umd.cloud9.io.pair.PairOfIntFloat

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.