Esempio n. 1
0
  public void run(Sentence source, Sentence target) {
    float sourceCount;
    float targetCount;
    if (!source.isSet("count_:")) {
      sourceCount = source.countChar(':');
    } else {
      sourceCount = (Integer) source.getValue("count_:");
    }

    if (!target.isSet("count_:")) {
      targetCount = target.countChar(':');
    } else {
      targetCount = (Integer) target.getValue("count_:");
    }

    float noTokensSource = 1;
    float noTokensTarget = 1;
    if (source.isSet("noTokens")) {
      noTokensSource = source.getNoTokens();
    }
    if (target.isSet("noTokens")) {
      noTokensTarget = target.getNoTokens();
    }

    setValue(Math.abs(sourceCount - targetCount) / noTokensTarget);
  }
Esempio n. 2
0
 /* (non-Javadoc)
  * @see wlv.mt.features.impl.Feature#run(wlv.mt.features.util.Sentence, wlv.mt.features.util.Sentence)
  */
 @Override
 public void run(Sentence source, Sentence target) {
   // TODO Auto-generated method stub
   ArrayList<String> ngrams = source.getNGrams(size);
   Iterator<String> it = ngrams.iterator();
   String ngram;
   int count = 0;
   int freq;
   int totalFreq = 0;
   int cutOff = LanguageModel.getCutOff(size, quart);
   while (it.hasNext()) {
     ngram = it.next();
     freq = LanguageModel.getFreq(ngram, size);
     if (freq <= cutOff && freq > 0) {
       count++;
     }
   }
   if (count == 0) {
     setValue(0);
   } else {
     setValue((float) count / ngrams.size());
   }
 }
Esempio n. 3
0
 /* (non-Javadoc)
  * @see wlv.mt.features.impl.Feature#run(wlv.mt.features.util.Sentence, wlv.mt.features.util.Sentence)
  */
 @Override
 public void run(Sentence source, Sentence target) {
   // TODO Auto-generated method stub
   float value = (Float) source.getValue("1_nb_ppl");
   setValue(value);
 }