Class FeedforwardDependencyParser
java.lang.Object
opennlp.tools.depparse.FeedforwardDependencyParser
- All Implemented Interfaces:
opennlp.tools.depparse.DependencyParser
@ThreadSafe
public class FeedforwardDependencyParser
extends Object
implements opennlp.tools.depparse.DependencyParser
The neural
DependencyParser: an arc-standard decoder over the
FeedforwardDependencyModel. By default it decodes with the beam size the
model was refined with, or greedily for a model that was not refined; a beam size
given to the constructor overrides that. It scores configurations with learned dense
representations instead of the sparse feature conjunctions of
DependencyParserME.
Beam decoding retains the highest scoring transition sequences by summed log-probability. Complete arc-standard derivations for a sentence have equal length, so their scores need no length normalization.
The parser does not modify its model and keeps no per-parse state, so one instance can be shared between threads. An optional scoring cache, owned by the parser and bounded in bytes, stores the hidden-layer contribution of each feature position and embedding row it has scored.
- Since:
- 3.0.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionInitializes aFeedforwardDependencyParserwith the beam size of the model and without a scoring cache.FeedforwardDependencyParser(FeedforwardDependencyModel model, int beamSize) Initializes aFeedforwardDependencyParserwith a beam and without a scoring cache.FeedforwardDependencyParser(FeedforwardDependencyModel model, int beamSize, long scoringCacheBytes) Initializes aFeedforwardDependencyParserwith a beam and a scoring cache. -
Method Summary
-
Constructor Details
-
FeedforwardDependencyParser
Initializes aFeedforwardDependencyParserwith the beam size of the model and without a scoring cache.- Parameters:
model- The model to parse with. Must not benull.- Throws:
IllegalArgumentException- Thrown ifmodelisnull.- See Also:
-
FeedforwardDependencyParser
Initializes aFeedforwardDependencyParserwith a beam and without a scoring cache.- Parameters:
model- The model to parse with. Must not benull.beamSize- The number of transition sequences to retain. Must be positive;1decodes greedily.- Throws:
IllegalArgumentException- Thrown ifmodelisnullorbeamSizeis not positive.
-
FeedforwardDependencyParser
public FeedforwardDependencyParser(FeedforwardDependencyModel model, int beamSize, long scoringCacheBytes) Initializes aFeedforwardDependencyParserwith a beam and a scoring cache.- Parameters:
model- The model to parse with. Must not benull.beamSize- The number of transition sequences to retain. Must be positive;1decodes greedily.scoringCacheBytes- The bytes the scoring cache may use, or0for no cache. Must not be negative. The cache needs room for one slot per vocabulary entry and feature position before it stores a contribution.- Throws:
IllegalArgumentException- Thrown ifmodelisnull,beamSizeis not positive,scoringCacheBytesis negative, or a positivescoringCacheBytesis too small for the model's vocabularies.
-
-
Method Details
-
parse
- Specified by:
parsein interfaceopennlp.tools.depparse.DependencyParser- Throws:
IllegalStateException- Thrown if no model outcome is applicable in a configuration or the model produces a non-finite transition score.
-