public static List<Event> generateEvents(String[] sentence, String[] outcomes, NameContextGenerator cg) { List<Event> events = new ArrayList<>(outcomes.length); for (int i = 0; i < outcomes.length; i++) { events.add(new Event(outcomes[i], cg.getContext(i, sentence, outcomes,null))); } cg.updateAdaptiveData(sentence, outcomes); return events; }
@Override public Sequence read() throws IOException { NameSample sample = psi.read(); if (sample != null) { String[] sentence = sample.getSentence(); String[] tags = seqCodec.encode(sample.getNames(), sentence.length); Event[] events = new Event[sentence.length]; for (int i = 0; i < sentence.length; i++) { // it is safe to pass the tags as previous tags because // the context generator does not look for non predicted tags String[] context; if (useOutcomes) { context = pcg.getContext(i, sentence, tags, null); } else { context = pcg.getContext(i, sentence, null, null); } events[i] = new Event(tags[i], context); } return new Sequence<>(events,sample); } else { return null; } }
public static List<Event> generateEvents(String[] sentence, String[] outcomes, NameContextGenerator cg) { List<Event> events = new ArrayList<>(outcomes.length); for (int i = 0; i < outcomes.length; i++) { events.add(new Event(outcomes[i], cg.getContext(i, sentence, outcomes,null))); } cg.updateAdaptiveData(sentence, outcomes); return events; }
public static List<Event> generateEvents(String[] sentence, String[] outcomes, NameContextGenerator cg) { List<Event> events = new ArrayList<>(outcomes.length); for (int i = 0; i < outcomes.length; i++) { events.add(new Event(outcomes[i], cg.getContext(i, sentence, outcomes,null))); } cg.updateAdaptiveData(sentence, outcomes); return events; }
@Override public Sequence read() throws IOException { NameSample sample = psi.read(); if (sample != null) { String[] sentence = sample.getSentence(); String[] tags = seqCodec.encode(sample.getNames(), sentence.length); Event[] events = new Event[sentence.length]; for (int i = 0; i < sentence.length; i++) { // it is safe to pass the tags as previous tags because // the context generator does not look for non predicted tags String[] context; if (useOutcomes) { context = pcg.getContext(i, sentence, tags, null); } else { context = pcg.getContext(i, sentence, null, null); } events[i] = new Event(tags[i], context); } return new Sequence<>(events,sample); } else { return null; } }
@Override public Sequence read() throws IOException { NameSample sample = psi.read(); if (sample != null) { String[] sentence = sample.getSentence(); String[] tags = seqCodec.encode(sample.getNames(), sentence.length); Event[] events = new Event[sentence.length]; for (int i = 0; i < sentence.length; i++) { // it is safe to pass the tags as previous tags because // the context generator does not look for non predicted tags String[] context; if (useOutcomes) { context = pcg.getContext(i, sentence, tags, null); } else { context = pcg.getContext(i, sentence, null, null); } events[i] = new Event(tags[i], context); } return new Sequence<>(events,sample); } else { return null; } }