package com.alidata.odps.udtf.examples;
import com.aliyun.odps.udf.ExecutionContext;
import com.aliyun.odps.udf.UDFException;
import com.aliyun.odps.udf.UDTF;
import com.aliyun.odps.udf.annotation.Resolve;
import com.huaban.analysis.jieba.JiebaSegmenter;
import java.util.*;

// TODO define input and output types, e.g. "string,string->string,bigint".
@Resolve({"string,string->string,string"})
public class jiebafenci extends UDTF {

    @Override
    public void setup(ExecutionContext ctx) throws UDFException {

    }

    @Override
    public void process(Object[] args) throws UDFException {
        // TODO
        String a = (String) args[0];
        String content = (String) args[1];
        JiebaSegmenter segmenter = new JiebaSegmenter();
        List<String> result = segmenter.sentenceProcess(content);


        for (String t: result) {
            forward(a, t);
        }
    }

    @Override
    public void close() throws UDFException {

    }

}