Powered by OPF
OPF WIKI STATIC ARCHIVE
2,681 pages · 153 spaces · 776 tags · 4,025 history records · 96.2% of the original wiki recovered
Archived copy. This page was recovered from the Internet Archive snapshot of /pages/viewpage.action?pageId=36012112 taken on 2022-08-08. The original wiki at wiki.opf-labs.org is being decommissioned.

PIG User Defined Functions to operate on extracted web content

Created by Sven Schlarb on Dec 03, 2013 · last edited by Per Møldrup-Dalum · on Dec 03, 2013 (view history) · 13 versions

Working plan

Pig example

For now clone https://github.com/perdalum/warcbase and checkout the pig-integration branch. Running the unit tests will run the above Pig Latin script on the provided test gzip'ed ARC file. The language distribution reported by Tika is:

The UDF is added to the piggy bank of the warcbase project by adding this class that leverages Tika

package org.warcbase.pig.piggybank;
import org.apache.pig.EvalFunc;
import org.apache.pig.data.Tuple;
import org.apache.tika.language.LanguageIdentifier;
import java.io.IOException;
public class DetectLanguage extends EvalFunc<String> {
    @Override
    public String exec(Tuple input) throws IOException {
        if (input == null || input.size() == 0 || input.get(0) == null)

Unknown macro: {            return null;        }

        String text = (String) input.get(0);
        return new LanguageIdentifier(text).getLanguage();
    }
}

Goals

Create UDFs for