Beispiel #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);
  }