@@ -0,0 +1,907 @@
+package udf_KW;%0A%0Aimport java.io.IOException;%0Aimport java.util.Arrays;%0A%0Aimport org.apache.pig.EvalFunc;%0Aimport org.apache.pig.data.Tuple;%0A%0Apublic class Keyword_Count extends EvalFunc%3CLong%3E %7B%0A%0A%09@Override%0A%09public Long exec(Tuple input) throws IOException %7B%0A%09%09Long total = 0L;%0A%09%09if(input != null && !input.isNull()) %7B%0A%09%09%09String _html = (String)input.get(0);%0A%09%09%09String _keywords = (String)input.get(1);%0A%0A%09%09%09if(_html != null && !_html.isEmpty() && _keywords != null && !_keywords.isEmpty()) %7B%0A%09%09%09%09int threshold = 8; // Should also be a parameter%0A%09%09%09%09String%5B%5D keywords = _keywords.toString().split(%22,%22);%0A%09%09%09%09keywords = Arrays.copyOfRange(keywords, 0, Math.min(threshold, keywords.length));%0A%09%09%09%09%0A%09%09%09%09for(String keyword : keywords) %7B%0A%09%09%09%09%09int index = _html.indexOf(keyword);%0A%09%09%09%09%09while (index %3E= 0) %7B%0A%09%09%09%09%09    total++;%0A%09%09%09%09%09    index = _html.indexOf(keyword, index + 1);%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09return total;%0A%09%7D%0A%0A%7D%0A

Create Keyword_Count.java