package se.lth.cs.nlp.opinions; import java.util.ArrayList; import se.lth.cs.nlp.nlputils.ml_long.SymbolEncoder; public class Labeling { public int[] labels; Labeling(int[] labels) { this.labels = labels; } public Labeling(ArrayList sen, SymbolEncoder enc) { if(sen.size() == 0) throw new IllegalArgumentException("empty"); int n = sen.get(0).length - 1; if(n <= 0) throw new RuntimeException("no columns"); labels = new int[sen.size()]; for(int i = 0; i < sen.size(); i++) { String[] ss = sen.get(i); if(ss.length != n + 1) throw new IllegalArgumentException("illegal columns"); labels[i] = enc.encode(ss[n]); } DEBUG_LABEL_ENC = enc; } static SymbolEncoder DEBUG_LABEL_ENC; public String toString() { StringBuilder sb = new StringBuilder(); sb.append("["); for(int i = 0; i < labels.length; i++) { if(i > 0) sb.append(", "); sb.append(DEBUG_LABEL_ENC.decode(labels[i])); } sb.append("]"); return sb.toString(); } }