Class Parser

All Implemented Interfaces:
opennlp.tools.parser.Parser

public class Parser extends AbstractBottomUpParser
A shift reduce style Parser implementation based on Adwait Ratnaparkhi's 1998 thesis.
See Also:
  • Constructor Details

    • Parser

      public Parser(ParserModel model, int beamSize, double advancePercentage)
      Instantiates a Parser via a given model and other configuration parameters. Uses the default implementations of POSTaggerME and ChunkerME.
      Parameters:
      model - The ParserModel to use.
      beamSize - The number of different parses kept during parsing. Must be at least 1.
      advancePercentage - The minimal amount of probability mass which advanced outcomes must represent. Only outcomes which contribute to the top advancePercentage will be explored. Must be greater than 0 and at most 1.
      Throws:
      IllegalArgumentException - Thrown if model is null or a parameter is out of range.
      See Also:
    • Parser

      public Parser(ParserModel model, opennlp.tools.postag.POSTagger tagger, opennlp.tools.chunker.Chunker chunker, int beamSize, double advancePercentage)
      Instantiates a Parser via a given model and a caller-supplied POSTagger and Chunker. The build and check models and the head rules are taken from model; its tagger and chunker models are not used.
      Parameters:
      model - The ParserModel to use. Must not be null.
      tagger - The POSTagger used to tag. Must not be null.
      chunker - The Chunker used to chunk. Must not be null.
      beamSize - The number of different parses kept during parsing. Must be at least 1.
      advancePercentage - The minimal amount of probability mass which advanced outcomes must represent. Only outcomes which contribute to the top advancePercentage will be explored. Must be greater than 0 and at most 1.
      Throws:
      IllegalArgumentException - Thrown if a parameter is null or out of range.
      Since:
      3.0.0
      See Also:
    • Parser

      public Parser(ParserModel model)
      Instantiates a Parser via a given model. Uses the default implementations of POSTaggerME and ChunkerME and default values for beamSize and advancePercentage.
      Parameters:
      model - The ParserModel to use. Must not be null.
      Throws:
      IllegalArgumentException - Thrown if model is null.
      See Also:
  • Method Details

    • mergeReportIntoManifest

      public static void mergeReportIntoManifest(Map<String,String> manifest, Map<String,String> report, String namespace)
    • train

      public static ParserModel train(String languageCode, opennlp.tools.util.ObjectStream<opennlp.tools.parser.Parse> parseSamples, opennlp.tools.parser.HeadRules rules, opennlp.tools.util.TrainingParameters mlParams) throws IOException
      Starts a training of a ParserModel.
      Parameters:
      languageCode - An ISO conform language code.
      parseSamples - The samples as input.
      rules - The HeadRules to use.
      mlParams - The parameters for training.
      Returns:
      A valid ParserModel.
      Throws:
      IOException - Thrown if IO errors occurred during training.