@@ -0,0 +1,725 @@
+package udf_KW;%0A%0Aimport java.io.IOException;%0Aimport java.math.BigDecimal;%0Aimport java.math.RoundingMode;%0A%0Aimport org.apache.pig.EvalFunc;%0Aimport org.apache.pig.data.Tuple;%0A%0Apublic class Keyword_Ratio extends EvalFunc%3CFloat%3E %7B%0A%0A%09@Override%0A%09public Float exec(Tuple input) throws IOException %7B%0A%09%09Float total = 0.0F;%0A%09%09if(input != null && !input.isNull()) %7B%0A%09%09%09String _html = (String)input.get(0);%0A%09%09%09Long _count = (Long)input.get(1);%0A%0A%09%09%09if(_html != null && !_html.isEmpty() && _count != null) %7B%0A%09%09%09%09int words = _html.trim().split(%22%5C%5Cs+%22).length; // Not ok: remove tags and stopwords%0A%0A%09%09%09%09total = BigDecimal.valueOf(_count).divide(BigDecimal.valueOf(words), 4, RoundingMode.HALF_UP).floatValue();%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return total;%0A%09%7D%0A%0A%7D%0A

Create udf_KW.java