Exemplo n.º 1
0
 /** Test of aveTranslationCount method, of class BaselineFeatures. */
 @Test
 public void testAveTranslationCount() {
   System.out.println("aveTranslationCount");
   Translation translation = new MockTranslation("A B C", "1 2 3 2 2 3 4");
   double minProb = 0.2;
   double expResult = 1.0;
   double result = instance.aveTranslationCount(translation, minProb);
   assertEquals(expResult, result, 0.0);
   double result2 = instance.aveTranslationCount(translation, 0.01);
   double expResult2 = 2.0;
   assertEquals(expResult2, result2, 0.0);
 }
Exemplo n.º 2
0
 /** Test of countPunctuationInTarget method, of class BaselineFeatures. */
 @Test
 public void testCountPunctuationInTarget() {
   System.out.println("countPunctuationInTarget");
   Translation translation = new MockTranslation("A B C E.", "1 2 3 !,");
   double expResult = 1.0;
   double result = BaselineFeatures.countPunctuationInTarget(translation);
   assertEquals(expResult, result, 0.0);
 }
Exemplo n.º 3
0
 /** Test of aveOccurencesInTarget method, of class BaselineFeatures. */
 @Test
 public void testAveOccurencesInTarget() {
   System.out.println("aveOccurencesInTarget");
   Translation translation = new MockTranslation("A B C", "1 2 3 2 2 3 4");
   double expResult = 7.0 / 4.0;
   double result = BaselineFeatures.aveOccurencesInTarget(translation);
   assertEquals(expResult, result, 0.0);
 }
Exemplo n.º 4
0
 /** Test of targetLMProb method, of class BaselineFeatures. */
 @Test
 public void testTargetLMProb() {
   System.out.println("targetLMProb");
   Translation translation = new MockTranslation("AA BBB C", "1 2 3 4");
   double expResult = 2.0;
   double result = instance.targetLMProb(translation);
   assertEquals(expResult, result, 0.0);
 }
Exemplo n.º 5
0
 /** Test of sourceLMProb method, of class BaselineFeatures. */
 @Test
 public void testSourceLMProb() {
   System.out.println("sourceLMProb");
   Translation translation = new MockTranslation("AA BBB C", "1 2 3 4");
   double expResult = 1.5;
   double result = instance.sourceLMProb(translation);
   assertEquals(expResult, result, 0.0);
 }
Exemplo n.º 6
0
 /** Test of aveSrcTkLen method, of class BaselineFeatures. */
 @Test
 public void testAveSrcTkLen() {
   System.out.println("aveSrcTkLen");
   Translation translation = new MockTranslation("AA BBB C", "1 2 3 4");
   double expResult = 2.0;
   double result = BaselineFeatures.aveSrcTkLen(translation);
   assertEquals(expResult, result, 0.0);
 }
Exemplo n.º 7
0
 /** Test of countTksInTrg method, of class BaselineFeatures. */
 @Test
 public void testCountTksInTrg() {
   System.out.println("countTksInTrg");
   Translation translation = new MockTranslation("A B C", "1 2 3 4");
   double expResult = 4.0;
   double result = BaselineFeatures.countTksInTrg(translation);
   assertEquals(expResult, result, 0.0);
 }
Exemplo n.º 8
0
 /** Test of percentUnigramsInLM method, of class BaselineFeatures. */
 @Test
 public void testPercentUnigramsInLM() {
   System.out.println("percentUnigramsInLM");
   Configurator.setConfig(
       "eu.monnetproject.translation.langmodel", "ms", "src/test/resources/model.lm");
   Translation translation = new MockTranslation("A B C E", "1 2 3");
   double expResult = 1.0;
   double result = instance.percentUnigramsInLM(translation);
   assertEquals(expResult, result, 0.0);
 }
Exemplo n.º 9
0
 /** Test of percentNGramsInTopBotQuartile method, of class BaselineFeatures. */
 @Test
 public void testPercentNGramsInTopBotQuartile() {
   System.out.println("percentNGramsInTopBotQuartile");
   Configurator.setConfig(
       "eu.monnetproject.translation.langmodel", "ms", "src/test/resources/model.lm");
   Translation translation = new MockTranslation("A B C", "1 2 3");
   int n = 1;
   double[] expResult = new double[] {1.0, 0.0};
   double[] result = instance.percentNGramsInTopBotQuartile(translation, n);
   assertArrayEquals(expResult, result, 0.0);
 }