Class DependencyParserME

java.lang.Object
opennlp.tools.depparse.DependencyParserME
All Implemented Interfaces:
opennlp.tools.depparse.DependencyParser

@ThreadSafe public class DependencyParserME extends Object implements opennlp.tools.depparse.DependencyParser
A greedy transition-based DependencyParser: a classifier picks the next arc-standard Transition for each configuration until the parse is complete, always taking the highest scoring transition that is applicable.

The parser holds an immutable model and no per-parse state, so one instance can be shared between threads.

Since:
3.0.0
See Also:
  • DependencyParser
  • Constructor Details

  • Method Details

    • parse

      public opennlp.tools.depparse.DependencyTree parse(String[] tokens, String[] tags)
      Specified by:
      parse in interface opennlp.tools.depparse.DependencyParser
      Throws:
      IllegalStateException - Thrown if the model returns scores that do not match its outcomes or are not finite.
    • train

      public static DependencyModel train(String languageCode, opennlp.tools.util.ObjectStream<opennlp.tools.depparse.DependencySample> samples, opennlp.tools.util.TrainingParameters parameters) throws IOException
      Trains a greedy arc-standard parser model from dependency samples.

      Non-projective samples have no arc-standard derivation and are skipped during event generation.

      Parameters:
      languageCode - The ISO language code of the training data. Must not be null.
      samples - The training samples. Must not be null.
      parameters - The TrainingParameters. Must not be null and must select an event model trainer.
      Returns:
      A trained DependencyModel. Never null.
      Throws:
      IOException - Thrown if reading the samples fails.
      IllegalArgumentException - Thrown if a parameter is null or the configured trainer is not an event model trainer.