public class ShiftReduceParser extends ParserGrammar implements Serializable
| Constructor and Description |
|---|
ShiftReduceParser(ShiftReduceOptions op) |
| Modifier and Type | Method and Description |
|---|---|
Tree |
apply(List<? extends HasWord> sentence)
A convenience method which wraps the ParserQuery and returns a Tree
|
static ShiftReduceParser |
averageModels(Collection<ShiftReduceParser> models) |
static ShiftReduceParser |
averageScoredModels(Collection<ScoredObject<ShiftReduceParser>> scoredModels) |
static List<Tree> |
binarizeTreebank(Treebank treebank,
Options op) |
static ShiftReduceOptions |
buildTrainingOptions(String tlppClass,
String[] args) |
void |
condenseFeatures()
Iterate over the feature weight map.
|
void |
copyWeights(ShiftReduceParser other)
Fill in the current object's weights with the other parser's weights.
|
String[] |
defaultCoreNLPFlags()
Returns a set of options which should be set by default when used
in corenlp.
|
void |
filterFeatures(Set<String> keep) |
Transition |
findEmergencyTransition(State state,
List<ParserConstraint> constraints)
Returns a transition which might not even be part of the model,
but will hopefully allow progress in an otherwise stuck parse
TODO: perhaps we want to create an EmergencyTransition class
which indicates that something has gone wrong
|
ScoredObject<Integer> |
findHighestScoringTransition(State state,
List<String> features,
boolean requireLegal)
Convenience method: returns one highest scoring transition, without any ParserConstraints
|
Collection<ScoredObject<Integer>> |
findHighestScoringTransitions(State state,
List<String> features,
boolean requireLegal,
int numTransitions,
List<ParserConstraint> constraints) |
static Set<String> |
findKnownStates(List<Tree> binarizedTrees) |
static void |
findKnownStates(Tree tree,
Set<String> knownStates) |
List<Eval> |
getExtraEvals()
TODO: add an eval which measures transition accuracy?
|
Options |
getOp() |
List<ParserQueryEval> |
getParserQueryEvals()
Return a list of Eval-style objects which care about the whole
ParserQuery, not just the finished tree
|
TreebankLangParserParams |
getTLPParams() |
static State |
initialStateFromGoldTagTree(Tree tree) |
static State |
initialStateFromTaggedSentence(List<? extends HasWord> words) |
static ShiftReduceParser |
loadModel(String path,
String... extraFlags) |
static void |
main(String[] args) |
void |
outputStats()
Output some random facts about the parser
|
ParserQuery |
parserQuery() |
List<Tree> |
readBinarizedTreebank(String treebankPath,
FileFilter treebankFilter) |
Treebank |
readTreebank(String treebankPath,
FileFilter treebankFilter) |
static void |
redoTags(List<Tree> trees,
Tagger tagger,
int nThreads) |
static void |
redoTags(Tree tree,
Tagger tagger) |
boolean |
requiresTags()
The model requires text to be pretagged
|
void |
saveModel(String path) |
void |
setOptionFlags(String... flags) |
TreebankLanguagePack |
treebankLanguagePack() |
public ShiftReduceParser(ShiftReduceOptions op)
public Options getOp()
getOp in class ParserGrammarpublic TreebankLangParserParams getTLPParams()
getTLPParams in class ParserGrammarpublic TreebankLanguagePack treebankLanguagePack()
treebankLanguagePack in class ParserGrammarpublic String[] defaultCoreNLPFlags()
ParserGrammardefaultCoreNLPFlags in class ParserGrammarpublic boolean requiresTags()
ParserGrammarrequiresTags in class ParserGrammarpublic void copyWeights(ShiftReduceParser other)
public static ShiftReduceParser averageScoredModels(Collection<ScoredObject<ShiftReduceParser>> scoredModels)
public static ShiftReduceParser averageModels(Collection<ShiftReduceParser> models)
public ParserQuery parserQuery()
parserQuery in class ParserGrammarpublic Tree apply(List<? extends HasWord> sentence)
ParserGrammarpublic void condenseFeatures()
public void outputStats()
public List<Eval> getExtraEvals()
getExtraEvals in class ParserGrammarpublic List<ParserQueryEval> getParserQueryEvals()
ParserGrammargetParserQueryEvals in class ParserGrammarpublic Transition findEmergencyTransition(State state, List<ParserConstraint> constraints)
public ScoredObject<Integer> findHighestScoringTransition(State state, List<String> features, boolean requireLegal)
public Collection<ScoredObject<Integer>> findHighestScoringTransitions(State state, List<String> features, boolean requireLegal, int numTransitions, List<ParserConstraint> constraints)
public static State initialStateFromTaggedSentence(List<? extends HasWord> words)
public static ShiftReduceOptions buildTrainingOptions(String tlppClass, String[] args)
public Treebank readTreebank(String treebankPath, FileFilter treebankFilter)
public List<Tree> readBinarizedTreebank(String treebankPath, FileFilter treebankFilter)
public void setOptionFlags(String... flags)
setOptionFlags in class ParserGrammarpublic static ShiftReduceParser loadModel(String path, String... extraFlags)
public void saveModel(String path)
public static void main(String[] args)