Package edu.umd.cloud9.util.array

Examples of edu.umd.cloud9.util.array.ArrayListOfFloats


      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


  public void testIterable() {
    int size = 1000;
    Random r = new Random();
    float[] floats = new float[size];

    ArrayListOfFloats list = new ArrayListOfFloats();
    for (int i = 0; i < size; i++) {
      float k = r.nextFloat();
      list.add(k);
      floats[i] = k;
    }

    int i=0;
    for ( Float v : list) {
View Full Code Here

    }
  }

  @Test
  public void testSetSize() {
    ArrayListOfFloats list = new ArrayListOfFloats();

    list.add(5.0f);
    assertEquals(1, list.size);
    assertEquals(5.0f, list.get(0), 10e-6);

    list.setSize(5);
    assertEquals(5, list.size);
    assertEquals(0.0f, list.get(1), 10e-6);
    assertEquals(0.0f, list.get(2), 10e-6);
    assertEquals(0.0f, list.get(3), 10e-6);
    assertEquals(0.0f, list.get(4), 10e-6);

    list.add(12.0f);
    assertEquals(6, list.size);
    assertEquals(12.0f, list.get(5), 10e-6);
  }
View Full Code Here

    assertEquals(12.0f, list.get(5), 10e-6);
  }
 
  @Test
  public void testSort() {
    ArrayListOfFloats a = new ArrayListOfFloats();
    assertEquals(0, a.size());

    a.add(5.2f).add(6f).add(5.9f).add(4.1f);
    assertEquals(4, a.size());

    a.sort();
    assertEquals(4, a.size());

    assertTrue(Math.abs(a.get(0)-4.1) < 0.0001);
    assertTrue(Math.abs(a.get(1)-5.2) < 0.0001);
    assertTrue(Math.abs(a.get(2)-5.9) < 0.0001);
    assertTrue(Math.abs(a.get(3)-6) < 0.0001);
  }
View Full Code Here

    assertTrue(Math.abs(a.get(3)-6) < 0.0001);
  }

  @Test
  public void testIntersection1() {
    ArrayListOfFloats a = new ArrayListOfFloats();
    a.add(5).add(3).add(1);

    a.sort();

    ArrayListOfFloats b = new ArrayListOfFloats();
    b.add(0).add(1).add(2).add(3);

    ArrayListOfFloats c = a.intersection(b);

    assertTrue(Math.abs(1 - c.get(0)) < 0.0001);
    assertTrue(Math.abs(3 - c.get(1)) < 0.0001);
    assertTrue(Math.abs(2 - c.size()) < 0.0001);
  }
View Full Code Here

    assertTrue(Math.abs(2 - c.size()) < 0.0001);
  }

  @Test
  public void testIntersection2() {
    ArrayListOfFloats a = new ArrayListOfFloats();
    a.add(5);

    ArrayListOfFloats b = new ArrayListOfFloats();
    b.add(0).add(1).add(2).add(3);

    ArrayListOfFloats c = a.intersection(b);
    assertTrue(c.size() == 0);
  }
View Full Code Here

    assertTrue(c.size() == 0);
  }

  @Test
  public void testIntersection3() {
    ArrayListOfFloats a = new ArrayListOfFloats();
    a.add(3).add(5).add(7).add(8).add(9);

    ArrayListOfFloats b = new ArrayListOfFloats();
    b.add(0).add(1).add(2).add(3);

    ArrayListOfFloats c = a.intersection(b);

    assertTrue(Math.abs(3 - c.get(0)) < 0.0001);
    assertEquals(1, c.size());
  }
View Full Code Here

  @Test
  public void testMerge1() {
    //CASE: interleaved

    ArrayListOfFloats a = new ArrayListOfFloats();
    a.add(3);
    a.add(7);
    a.add(10);

    ArrayListOfFloats b = new ArrayListOfFloats();
    b.add(0);
    b.add(4);
    b.add(9);

    ArrayListOfFloats c = a.merge(b);

    assertEquals(6, c.size());
    assertTrue(Math.abs(0 - c.get(0)) < 0.0001);
    assertTrue(Math.abs(3 - c.get(1)) < 0.0001);
    assertTrue(Math.abs(4 - c.get(2)) < 0.0001);
    assertTrue(Math.abs(7 - c.get(3)) < 0.0001);
    assertTrue(Math.abs(9 - c.get(4)) < 0.0001);
    assertTrue(Math.abs(10 - c.get(5)) < 0.0001);

    // c should be same as c2
    ArrayListOfFloats c2 = b.merge(a);
    assertEquals(c, c2);
  }
View Full Code Here

  @Test
  public void testMerge2() {
    //CASE: append

    ArrayListOfFloats a = new ArrayListOfFloats();
    a.add(3);
    a.add(7);
    a.add(10);

    ArrayListOfFloats b = new ArrayListOfFloats();
    b.add(11);
    b.add(19);
    b.add(21);

    ArrayListOfFloats c = a.merge(b);

    assertEquals(6, c.size());
    assertTrue(Math.abs(3 - c.get(0)) < 0.0001);
    assertTrue(Math.abs(7 - c.get(1)) < 0.0001);
    assertTrue(Math.abs(10 - c.get(2)) < 0.0001);
    assertTrue(Math.abs(11 - c.get(3)) < 0.0001);
    assertTrue(Math.abs(19 - c.get(4)) < 0.0001);
    assertTrue(Math.abs(21 - c.get(5)) < 0.0001);

    ArrayListOfFloats c2 = b.merge(a);
    assertEquals(c, c2);
}
View Full Code Here

  @Test
  public void testMerge3() {
    //CASE: one of the lists are empty
   
    ArrayListOfFloats a = new ArrayListOfFloats();
    a.add(3);
    a.add(7);
    a.add(10);

    ArrayListOfFloats b = new ArrayListOfFloats();

    ArrayListOfFloats c = a.merge(b);
    assertEquals(c, a);
   
    ArrayListOfFloats c2 = b.merge(a);
    assertEquals(c, c2);  
  }
View Full Code Here

TOP

Related Classes of edu.umd.cloud9.util.array.ArrayListOfFloats

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.