public Event next() { StringTokenizer st = new StringTokenizer(line); String outcome = st.nextToken(); int count = st.countTokens(); String[] context = new String[count]; for (int ci = 0; ci < count; ci++) { context[ci] = st.nextToken(); } return (new Event(outcome, context)); }
public Event next() { StringTokenizer st = new StringTokenizer(line); String outcome = st.nextToken(); int count = st.countTokens(); String[] context = new String[count]; for (int ci = 0; ci < count; ci++) { context[ci] = st.nextToken(); } return (new Event(outcome, context)); }
private Event createEvent(String obs) { int lastSpace = obs.lastIndexOf(separator); if (lastSpace == -1) return null; else return new Event(obs.substring(lastSpace+1), cg.getContext(obs.substring(0, lastSpace))); }
private Event createEvent(String obs) { int lastSpace = obs.lastIndexOf(' '); if (lastSpace == -1) return null; else { String[] contexts = obs.substring(0,lastSpace).split("\\s+"); float[] values = RealValueFileEventStream.parseContexts(contexts); return new Event(obs.substring(lastSpace+1),contexts,values); } }
public Event next() { int si = line.indexOf(' '); String outcome = line.substring(0, si); String[] contexts = line.substring(si + 1).split(" "); float[] values = parseContexts(contexts); return (new Event(outcome, contexts, values)); }
private Event createEvent(String obs) { int lastSpace = obs.lastIndexOf(' '); if (lastSpace == -1) return null; else { String[] contexts = obs.substring(0,lastSpace).split("\\s+"); float[] values = RealValueFileEventStream.parseContexts(contexts); return new Event(obs.substring(lastSpace+1),contexts,values); } }
private Event createEvent(String obs) { int lastSpace = obs.lastIndexOf(separator); if (lastSpace == -1) return null; else return new Event(obs.substring(lastSpace+1), cg.getContext(obs.substring(0, lastSpace))); }
private void addEvent(String outcome, Context np1) { List<String> feats = getFeatures(np1); events.add(new Event(outcome, feats.toArray(new String[feats.size()]))); }
private void addEvent(boolean same, Context np1, Context np2) { if (same) { List<String> feats = getFeatures(np1, np2); //System.err.println(SAME+" "+np1.headTokenText+" ("+np1.id+") -> "+np2.headTokenText+" ("+np2.id+") "+feats); events.add(new Event(SAME, feats.toArray(new String[feats.size()]))); } else { List<String> feats = getFeatures(np1, np2); //System.err.println(DIFF+" "+np1.headTokenText+" ("+np1.id+") -> "+np2.headTokenText+" ("+np2.id+") "+feats); events.add(new Event(DIFF, feats.toArray(new String[feats.size()]))); } }
public void addEvent(MentionContext ec) { List<String> features = getFeatures(ec); if (-1 == ec.getId()) { events.add(new Event(MaxentResolver.SAME, features.toArray(new String[features.size()]))); } else { events.add(new Event(MaxentResolver.DIFF, features.toArray(new String[features.size()]))); } }
public Event next() { int si = line.indexOf(' '); String outcome = line.substring(0, si); String[] contexts = line.substring(si + 1).split(" "); float[] values = parseContexts(contexts); return (new Event(outcome, contexts, values)); }
private Event createEvent(String obs) { int lastSpace = obs.lastIndexOf(StringUtils.SPACE); Event event = null; if (lastSpace != -1) { String label = obs.substring(lastSpace + 1); String[] contexts = obs.substring(0, lastSpace).split("\\s+"); // Split name and value float[] values = RealValueFileEventStream.parseContexts(contexts); // Label, feature name, feature value event = new Event(label, contexts, values); } return event; }
private void addEvent(String outcome, Context np1) { List<String> feats = getFeatures(np1); events.add(new Event(outcome, feats.toArray(new String[feats.size()]))); }
public Event next() { int split = line.indexOf(' '); String outcome = line.substring(0,split); String question = line.substring(split+1); Parse query = ParserTool.parseLine(question,parser,1)[0]; return (new Event(outcome, atcg.getContext(query))); }
@Override public Event next() { Tuple tuple = dataIter.next(); String[] featName; float[] featVal = VectorUtils.doubleToFloat(tuple.vector.getVector()); if (tuple.vector instanceof FeatNamedVector) { featName = ((FeatNamedVector) tuple.vector).featsName; } else if (tuple.vector instanceof SparseVector || tuple.vector instanceof DenseVector) { featName = new String[tuple.vector.getVector().length]; for (int i = 0; i < featName.length; i++) { featName[i] = String.valueOf(i); } } else { throw new NotImplementedException("Unknown vector type"); } return new Event(tuple.label, featName, featVal); }
/** * Adds a new instance to the data set with the given label (0 for negative, * 1 for positive). * * @param instance * @param label */ public void addInstance(T instance, int label) { String[] stringFeatures = new String[features.getNumFeatures()]; int i = 0; for (String feature : features.getFeatureNames()) { boolean value = features.featurizeToBool(feature, instance); stringFeatures[i++] = this.alphabet.lookup .get(new OpenNlpAlphabet.Key(feature, value)); } Event event = new Event(Integer.toString(label), stringFeatures); this.instances.add(event); }
/** * Adds a new instance to the data set with the given label (0 for negative, * 1 for positive). * * @param instance * @param label */ public void addInstance(T instance, int label) { String[] stringFeatures = new String[features.getNumFeatures()]; int i = 0; for (String feature : features.getFeatureNames()) { boolean value = features.featurizeToBool(feature, instance); stringFeatures[i++] = this.alphabet.lookup .get(new OpenNlpAlphabet.Key(feature, value)); } Event event = new Event(Integer.toString(label), stringFeatures); this.instances.add(event); }
@Override public Event next() throws IOException { try { Event event = null; if (this.corpusEventStream.hasNext()) { ClassificationEvent corpusEvent = this.corpusEventStream.next(); List<String> contextList = new ArrayList<String>(); List<Float> weightList = new ArrayList<Float>(); OpenNLPDecisionMaker.prepareData(corpusEvent.getFeatureResults(), contextList, weightList); String[] contexts = new String[contextList.size()]; float[] weights = new float[weightList.size()]; int i = 0; for (String context : contextList) { contexts[i++] = context; } i = 0; for (Float weight : weightList) { weights[i++] = weight; } event = new Event(corpusEvent.getClassification(), contexts, weights); } return event; } catch (TalismaneException e) { LOG.error(e.getMessage(), e); throw new RuntimeException(e); } }
/** * @param cas * the <code>JCas</code> object * @return return the instance of the input, represented in * <code>Event</code> */ protected final Event casToEvent(JCas cas) throws ConfigurationException { String goldAnswer = getGoldLabel(cas); if (null == goldAnswer) { goldAnswer = DecisionLabel.Abstain.toString(); } try { String[] contexts = constructContext(cas); float[] values = RealValueFileEventStream.parseContexts(contexts); return new Event(goldAnswer, contexts, values); } catch (ScoringComponentException e) { throw new ConfigurationException(e.getMessage()); } }