Codota Logo
Sequence
Code IndexAdd Codota to your IDE (free)

How to use
Sequence
in
opennlp.tools.ml.model

Best Java code snippets using opennlp.tools.ml.model.Sequence (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
List l =
  • Codota Iconnew LinkedList()
  • Codota IconCollections.emptyList()
  • Codota Iconnew ArrayList()
  • Smart code suggestions by Codota
}
origin: apache/opennlp

@Override
public Sequence read() throws IOException {
 ChunkSample sample = samples.read();
 if (sample != null) {
  String[] sentence = sample.getSentence();
  String[] tags = sample.getTags();
  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 = contextGenerator.getContext(i, sentence, tags, null);
   events[i] = new Event(tags[i], context);
  }
  return new Sequence<>(events,sample);
 }
 return null;
}
origin: apache/opennlp

@Override
public Event read() throws IOException {
 while (!eventIt.hasNext()) {
  Sequence<?> sequence = sequenceStream.read();
  if (sequence == null) {
   return null;
  }
  eventIt = Arrays.asList(sequence.getEvents()).iterator();
 }
 return eventIt.next();
}
origin: apache/opennlp

@SuppressWarnings("unchecked")
public Event[] updateContext(Sequence sequence, AbstractModel model) {
 Sequence<POSSample> pss = sequence;
 POSTagger tagger = new POSTaggerME(new POSModel("x-unspecified", model, null, new POSTaggerFactory()));
 String[] sentence = pss.getSource().getSentence();
 Object[] ac = pss.getSource().getAddictionalContext();
 String[] tags = tagger.tag(pss.getSource().getSentence());
 Event[] events = new Event[sentence.length];
 POSSampleEventStream.generateEvents(sentence, tags, ac, pcg)
   .toArray(events);
 return events;
}
origin: apache/opennlp

@Override
public Sequence read() throws IOException {
 POSSample sample = psi.read();
 if (sample != null) {
  String[] sentence = sample.getSentence();
  String[] tags = sample.getTags();
  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 = pcg.getContext(i, sentence, tags, null);
   events[i] = new Event(tags[i], context);
  }
  Sequence<POSSample> sequence = new Sequence<POSSample>(events,sample);
  return sequence;
 }
 return null;
}
origin: apache/opennlp

while ((sequence = sequenceStream.read()) != null) {
 Event[] taggerEvents = sequenceStream.updateContext(sequence, model);
 Event[] events = sequence.getEvents();
 boolean update = false;
 for (int ei = 0; ei < events.length; ei++, oei++) {
origin: apache/opennlp

@SuppressWarnings("unchecked")
public Event[] updateContext(Sequence sequence, AbstractModel model) {
 TokenNameFinder tagger = new NameFinderME(new TokenNameFinderModel(
   "x-unspecified", model, Collections.emptyMap(), null));
 String[] sentence = ((Sequence<NameSample>) sequence).getSource().getSentence();
 String[] tags = seqCodec.encode(tagger.find(sentence), sentence.length);
 Event[] events = new Event[sentence.length];
 NameFinderEventStream.generateEvents(sentence,tags,pcg).toArray(events);
 return events;
}
origin: apache/opennlp

@Override
public Sequence read() throws IOException {
 LemmaSample sample = samples.read();
 if (sample != null) {
  String[] sentence = sample.getTokens();
  String[] tags = sample.getTags();
  String[] preds = sample.getLemmas();
  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 = contextGenerator.getContext(i, sentence, tags, preds);
   events[i] = new Event(tags[i], context);
  }
  return new Sequence<>(events,sample);
 }
 return null;
}
origin: org.apache.opennlp/opennlp-tools

@Override
public Event read() throws IOException {
 while (!eventIt.hasNext()) {
  Sequence<?> sequence = sequenceStream.read();
  if (sequence == null) {
   return null;
  }
  eventIt = Arrays.asList(sequence.getEvents()).iterator();
 }
 return eventIt.next();
}
origin: org.apache.opennlp/opennlp-tools

@SuppressWarnings("unchecked")
public Event[] updateContext(Sequence sequence, AbstractModel model) {
 Sequence<POSSample> pss = sequence;
 POSTagger tagger = new POSTaggerME(new POSModel("x-unspecified", model, null, new POSTaggerFactory()));
 String[] sentence = pss.getSource().getSentence();
 Object[] ac = pss.getSource().getAddictionalContext();
 String[] tags = tagger.tag(pss.getSource().getSentence());
 Event[] events = new Event[sentence.length];
 POSSampleEventStream.generateEvents(sentence, tags, ac, pcg)
   .toArray(events);
 return events;
}
origin: apache/opennlp

@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;
 }
}
origin: ai.idylnlp/idylnlp-opennlp-tools-1.8.3

@Override
public Event read() throws IOException {
 while (!eventIt.hasNext()) {
  Sequence<?> sequence = sequenceStream.read();
  if (sequence == null) {
   return null;
  }
  eventIt = Arrays.asList(sequence.getEvents()).iterator();
 }
 return eventIt.next();
}
origin: ai.idylnlp/idylnlp-opennlp-tools-1.8.3

@SuppressWarnings("unchecked")
public Event[] updateContext(Sequence sequence, AbstractModel model) {
 Sequence<POSSample> pss = sequence;
 POSTagger tagger = new POSTaggerME(new POSModel("x-unspecified", model, null, new POSTaggerFactory()));
 String[] sentence = pss.getSource().getSentence();
 Object[] ac = pss.getSource().getAddictionalContext();
 String[] tags = tagger.tag(pss.getSource().getSentence());
 Event[] events = new Event[sentence.length];
 POSSampleEventStream.generateEvents(sentence, tags, ac, pcg)
   .toArray(events);
 return events;
}
origin: ai.idylnlp/idylnlp-opennlp-tools-1.8.3

@Override
public Sequence read() throws IOException {
 ChunkSample sample = samples.read();
 if (sample != null) {
  String[] sentence = sample.getSentence();
  String[] tags = sample.getTags();
  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 = contextGenerator.getContext(i, sentence, tags, null);
   events[i] = new Event(tags[i], context);
  }
  return new Sequence<>(events,sample);
 }
 return null;
}
origin: ai.idylnlp/idylnlp-opennlp-tools-1.8.3

while ((sequence = sequenceStream.read()) != null) {
 Event[] taggerEvents = sequenceStream.updateContext(sequence, model);
 Event[] events = sequence.getEvents();
 boolean update = false;
 for (int ei = 0; ei < events.length; ei++, oei++) {
origin: ai.idylnlp/idylnlp-opennlp-tools-1.8.3

@SuppressWarnings("unchecked")
public Event[] updateContext(Sequence sequence, AbstractModel model) {
 TokenNameFinder tagger = new NameFinderME(new TokenNameFinderModel(
   "x-unspecified", model, Collections.emptyMap(), null));
 String[] sentence = ((Sequence<NameSample>) sequence).getSource().getSentence();
 String[] tags = seqCodec.encode(tagger.find(sentence), sentence.length);
 Event[] events = new Event[sentence.length];
 NameFinderEventStream.generateEvents(sentence,tags,pcg).toArray(events);
 return events;
}
origin: org.apache.opennlp/opennlp-tools

@Override
public Sequence read() throws IOException {
 POSSample sample = psi.read();
 if (sample != null) {
  String[] sentence = sample.getSentence();
  String[] tags = sample.getTags();
  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 = pcg.getContext(i, sentence, tags, null);
   events[i] = new Event(tags[i], context);
  }
  Sequence<POSSample> sequence = new Sequence<POSSample>(events,sample);
  return sequence;
 }
 return null;
}
origin: org.apache.opennlp/opennlp-tools

while ((sequence = sequenceStream.read()) != null) {
 Event[] taggerEvents = sequenceStream.updateContext(sequence, model);
 Event[] events = sequence.getEvents();
 boolean update = false;
 for (int ei = 0; ei < events.length; ei++, oei++) {
origin: org.apache.opennlp/opennlp-tools

@SuppressWarnings("unchecked")
public Event[] updateContext(Sequence sequence, AbstractModel model) {
 TokenNameFinder tagger = new NameFinderME(new TokenNameFinderModel(
   "x-unspecified", model, Collections.emptyMap(), null));
 String[] sentence = ((Sequence<NameSample>) sequence).getSource().getSentence();
 String[] tags = seqCodec.encode(tagger.find(sentence), sentence.length);
 Event[] events = new Event[sentence.length];
 NameFinderEventStream.generateEvents(sentence,tags,pcg).toArray(events);
 return events;
}
origin: org.apache.opennlp/opennlp-tools

@Override
public Sequence read() throws IOException {
 ChunkSample sample = samples.read();
 if (sample != null) {
  String[] sentence = sample.getSentence();
  String[] tags = sample.getTags();
  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 = contextGenerator.getContext(i, sentence, tags, null);
   events[i] = new Event(tags[i], context);
  }
  return new Sequence<>(events,sample);
 }
 return null;
}
origin: ai.idylnlp/idylnlp-opennlp-tools-1.8.3

@Override
public Sequence read() throws IOException {
 POSSample sample = psi.read();
 if (sample != null) {
  String[] sentence = sample.getSentence();
  String[] tags = sample.getTags();
  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 = pcg.getContext(i, sentence, tags, null);
   events[i] = new Event(tags[i], context);
  }
  Sequence<POSSample> sequence = new Sequence<POSSample>(events,sample);
  return sequence;
 }
 return null;
}
opennlp.tools.ml.modelSequence

Javadoc

Class which models a sequence.

Most used methods

  • <init>
    Creates a new sequence made up of the specified events and derived from the specified source.
  • getEvents
    Returns the events which make up this sequence.
  • getSource
    Returns an object from which this sequence can be derived. This object is used when the events for t

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • orElseThrow (Optional)
  • Color (java.awt)
    The Color class is used encapsulate colors in the default sRGB color space or colors in arbitrary co
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • FileOutputStream (java.io)
    A file output stream is an output stream for writing data to aFile or to a FileDescriptor. Whether
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now