package commons.math.formulas;

import basics.utl.SUtl;
import basics.utl.SysUtl;

public class Tanomito implements Formula
{

/**
 * Implements a tanomito weighting formula. This weight weights a pair by the frequency of the terms
 * and the frequency of the combined occurrence. INPUT: frequency (term_a), frequency (term_b),
 * frequency(term_a, term_b) OUTPUT: value between 0..1, 1: words occur only pairwise, 0: no pairs
 * of a and b.
 */
public double calculate(double...arg)
{
   double result = 0D;
   double H_a = arg[0];
   double H_b = arg[1];
   double H_ab = arg[2];
   result = H_ab / (H_a + H_b - H_ab);
   if(result < 0)
      SysUtl.trace(SUtl.sprint("% = % / (% + % - %)",result, H_ab, H_a, H_b, H_ab));
   return result;
}
}
