Examples of PairOfStrings


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

        String[] parts = rule.split("\\|\\|\\|");
        String[] lhs = parts[0].trim().split(" ");
        String[] rhs = parts[1].trim().split(" ");;
        for (String l : lhs) {
          for (String r : rhs) {
            pairsInSCFG.add(new PairOfStrings(l, r));
          }
        }
      }
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
View Full Code Here

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

      int e = entry.getRightElement();
      String eTerm = eVocab_f2e.get(e);

      //      LOG.info("Pr("+eTerm+"|"+token+")="+probEF);

      if (probEF > 0 && e > 0 && !docLangTokenizer.isStopWord(eTerm) && (translateOnly == null || !translateOnly.equals("indri") || indriPuncPattern.matcher(eTerm).matches()) && (pairsInSCFG == null || pairsInSCFG.contains(new PairOfStrings(token,eTerm)))) {     
        // assuming our bilingual dictionary is learned from normally segmented text, but we want to use bigram tokenizer for CLIR purposes
        // then we need to convert the translations of each source token into a sequence of bigrams
        // we can distribute the translation probability equally to the each bigram
        if (bigramSegment) {
          String[] eTokens = docLangTokenizer.processContent(eTerm);
View Full Code Here

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

      int e = entry.getRightElement();
      String eTerm = eVocab_f2e.get(e);

      //      LOG.info("Pr("+eTerm+"|"+token+")="+probEF);

      if (probEF > 0 && e > 0 && !docLangTokenizer.isStemmedStopWord(eTerm) && (pairsInSCFG == null || pairsInSCFG.contains(new PairOfStrings(token,eTerm)))) {     
        // assuming our bilingual dictionary is learned from normally segmented text, but we want to use bigram tokenizer for CLIR purposes
        // then we need to convert the translations of each source token into a sequence of bigrams
        // we can distribute the translation probability equally to the each bigram
        if (bigramSegment) {
          String[] eTokens = docLangTokenizer.processContent(eTerm);
View Full Code Here

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

        String[] parts = rule.split("\\|\\|\\|");
        String[] lhs = parts[1].trim().split(" ");
        String[] rhs = parts[2].trim().split(" ");;
        for (String l : lhs) {
          for (String r : rhs) {
            pairsInSCFG.add(new PairOfStrings(l, r));
            //            LOG.info("added "+l+"|||"+r);
          }
        }
      }
    } catch (UnsupportedEncodingException e) {
View Full Code Here

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

public class PairOfStringsTest {

  @Test
  public void testBasic() throws IOException {
    PairOfStrings pair = new PairOfStrings("hi", "there");

    assertEquals("hi", pair.getLeftElement());
    assertEquals("there", pair.getRightElement());
  }
View Full Code Here

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

    assertEquals("there", pair.getRightElement());
  }

  @Test
  public void testSerialize() throws IOException {
    PairOfStrings origPair = new PairOfStrings("hi", "there");

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

    origPair.write(dataOut);

    PairOfStrings pair = new PairOfStrings();

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

    assertEquals("hi", pair.getLeftElement());
    assertEquals("there", pair.getRightElement());
  }
View Full Code Here

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

    assertEquals("there", pair.getRightElement());
  }

  @Test
  public void testOptimizedSerialize() throws IOException {
    PairOfStrings pair1 = new PairOfStrings("hi", "there");
    ByteArrayOutputStream pair1_bytesOut = new ByteArrayOutputStream();
    DataOutputStream pair1_dataOut = new DataOutputStream(pair1_bytesOut);
    pair1.write(pair1_dataOut);
    byte[] bytes1 = pair1_bytesOut.toByteArray();

    PairOfStrings pair2 = new PairOfStrings("hi", "there");
    ByteArrayOutputStream pair2_bytesOut = new ByteArrayOutputStream();
    DataOutputStream pair2_dataOut = new DataOutputStream(pair2_bytesOut);
    pair2.write(pair2_dataOut);
    byte[] bytes2 = pair2_bytesOut.toByteArray();

    PairOfStrings pair3 = new PairOfStrings("hi", "howdy");
    ByteArrayOutputStream pair3_bytesOut = new ByteArrayOutputStream();
    DataOutputStream pair3_dataOut = new DataOutputStream(pair3_bytesOut);
    pair3.write(pair3_dataOut);
    byte[] bytes3 = pair3_bytesOut.toByteArray();

    PairOfStrings pair4 = new PairOfStrings("a", "howdy");
    ByteArrayOutputStream pair4_bytesOut = new ByteArrayOutputStream();
    DataOutputStream pair4_dataOut = new DataOutputStream(pair4_bytesOut);
    pair4.write(pair4_dataOut);
    byte[] bytes4 = pair4_bytesOut.toByteArray();

    PairOfStrings pair5 = new PairOfStrings("hi", "z");
    ByteArrayOutputStream pair5_bytesOut = new ByteArrayOutputStream();
    DataOutputStream pair5_dataOut = new DataOutputStream(pair5_bytesOut);
    pair5.write(pair5_dataOut);
    byte[] bytes5 = pair5_bytesOut.toByteArray();

    PairOfStrings.Comparator pairOfStringComparator = new PairOfStrings.Comparator();
    assertTrue(pairOfStringComparator.compare(bytes1, 0, bytes1.length, bytes2, 0, bytes2.length) == 0);
    assertFalse(pair1.equals(pair3));
View Full Code Here

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

    assertTrue(pairOfStringComparator.compare(bytes4, 0, bytes4.length, bytes5, 0, bytes5.length) < 0);
  }

  @Test
  public void testComparison1() throws IOException {
    PairOfStrings pair1 = new PairOfStrings("hi", "there");
    PairOfStrings pair2 = new PairOfStrings("hi", "there");
    PairOfStrings pair3 = new PairOfStrings("hi", "howdy");
    PairOfStrings pair4 = new PairOfStrings("a", "howdy");
    PairOfStrings pair5 = new PairOfStrings("hi", "z");
   
    assertTrue(pair1.equals(pair2));
    assertFalse(pair1.equals(pair3));

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

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

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

    PairOfStrings pair1 = new PairOfStrings("hi", "there");
    PairOfStrings pair2 = new PairOfStrings("hi", "there");
    PairOfStrings pair3 = new PairOfStrings("hi", "howdy");
    PairOfStrings pair4 = new PairOfStrings("a", "howdy");
    PairOfStrings pair5 = new PairOfStrings("hi", "z");
   
    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.PairOfStrings

        int tot=0;
       
        // First step of the computation of new mu
        while (iter.hasNext()){
          tot++;
          PairOfStrings now = iter.next();
          double w = Double.parseDouble(now.getRightElement());
          double x = Double.parseDouble(now.getLeftElement());
          sum += w;
          mu += x * w;
          diff1 += x*x*w;
          diff2 += 2*x*w;
          diff3 += w;
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.