public class ShiftReduceParser extends ParserGrammar implements java.io.Serializable
Constructor and Description |
---|
ShiftReduceParser(ShiftReduceOptions op) |
ShiftReduceParser(ShiftReduceOptions op,
PerceptronModel model) |
Modifier and Type | Method and Description |
---|---|
static java.util.List<Tree> |
binarizeTreebank(java.lang.Iterable<Tree> treebank,
Options op) |
static ShiftReduceOptions |
buildTrainingOptions(java.lang.String tlppClass,
java.lang.String[] args) |
static boolean |
checkLeafBranching(Tree tree)
If an internal node goes directly to a leaf, that is an illegal tree.
|
static boolean |
checkRootTransition(Tree tree)
Some trees in the English datasets have a binary transition at
the top, which we don't like as it teaches the parser to
sometimes make binary transitions in normal trees
|
java.lang.String[] |
defaultCoreNLPFlags()
Returns a set of options which should be set by default when used
in corenlp.
|
java.util.List<Tree> |
filterTreebank(Treebank treebank)
Filters any trees which are obviously unacceptable for the sr parser training.
|
static java.util.Set<java.lang.String> |
findKnownStates(java.util.List<Tree> binarizedTrees) |
static void |
findKnownStates(Tree tree,
java.util.Set<java.lang.String> knownStates) |
java.util.List<Eval> |
getExtraEvals()
TODO: add an eval which measures transition accuracy?
|
Options |
getOp() |
java.util.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(java.util.List<? extends HasWord> words) |
java.util.Set<java.lang.String> |
knownStates()
Return an unmodifiableSet containing the known states (including binarization)
|
static ShiftReduceParser |
loadModel(java.lang.String path,
java.lang.String... extraFlags) |
static void |
main(java.lang.String[] args) |
Tree |
parse(java.util.List<? extends HasWord> sentence)
Parses the list of HasWord.
|
Tree |
parse(java.lang.String sentence)
Will parse the text in
sentence as if it represented
a single sentence by first processing it with a tokenizer. |
ParserQuery |
parserQuery() |
Tree |
parseTree(java.util.List<? extends HasWord> sentence)
Similar to parse(), but instead of returning an X tree on failure, returns null.
|
java.util.List<Tree> |
readBinarizedTreebank(java.lang.String treebankPath,
java.io.FileFilter treebankFilter) |
Treebank |
readTreebank(java.lang.String treebankPath,
java.io.FileFilter treebankFilter) |
static void |
redoTags(java.util.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(java.lang.String path) |
void |
setOptionFlags(java.lang.String... flags) |
java.util.Set<java.lang.String> |
tagSet()
Return the Set of POS tags used in the model.
|
TreebankLanguagePack |
treebankLanguagePack() |
apply, lemmatize, lemmatize, loadModelFromZip, loadTagger, tokenize
public ShiftReduceParser(ShiftReduceOptions op)
public ShiftReduceParser(ShiftReduceOptions op, PerceptronModel model)
public Options getOp()
getOp
in class ParserGrammar
public TreebankLangParserParams getTLPParams()
getTLPParams
in class ParserGrammar
public TreebankLanguagePack treebankLanguagePack()
treebankLanguagePack
in class ParserGrammar
public java.lang.String[] defaultCoreNLPFlags()
ParserGrammar
defaultCoreNLPFlags
in class ParserGrammar
public java.util.Set<java.lang.String> knownStates()
public java.util.Set<java.lang.String> tagSet()
public boolean requiresTags()
ParserGrammar
requiresTags
in class ParserGrammar
public ParserQuery parserQuery()
parserQuery
in interface ParserQueryFactory
parserQuery
in class ParserGrammar
public Tree parse(java.lang.String sentence)
ParserGrammar
sentence
as if it represented
a single sentence by first processing it with a tokenizer.parse
in class ParserGrammar
public Tree parse(java.util.List<? extends HasWord> sentence)
ParserGrammar
parse
in class ParserGrammar
sentence
- The input sentence (a List of words)public Tree parseTree(java.util.List<? extends HasWord> sentence)
ParserGrammar
parseTree
in class ParserGrammar
public java.util.List<Eval> getExtraEvals()
getExtraEvals
in class ParserGrammar
public java.util.List<ParserQueryEval> getParserQueryEvals()
ParserGrammar
getParserQueryEvals
in class ParserGrammar
public static State initialStateFromTaggedSentence(java.util.List<? extends HasWord> words)
public static ShiftReduceOptions buildTrainingOptions(java.lang.String tlppClass, java.lang.String[] args)
public Treebank readTreebank(java.lang.String treebankPath, java.io.FileFilter treebankFilter)
public java.util.List<Tree> readBinarizedTreebank(java.lang.String treebankPath, java.io.FileFilter treebankFilter)
public static boolean checkLeafBranching(Tree tree)
(ROOT (sentence (S (morfema.pronominal (PRON Se)) -----(sn (spec (PRON los)) grup.nom)----- (grup.verb (PROPN trago')) (sn (spec (PROPN la)) (grup.nom (DET tierra)))) (NOUN ....) (S (sadv (grup.adv (PROPN ya))) (neg (ADV no)) (grup.verb (ADV viven)) (sp (prep (VERB en)) (sn (grup.nom (ADP Cuba)))) (PROPN ...)) (conj (PUNCT y)) (S (sp (prep (CCONJ a)) (sn (grup.nom (ADP nadie)))) (sn (grup.nom (PRON le))) (grup.verb (PRON importa)) (sn (spec (VERB la)) (grup.nom (S (relatiu (DET que)) (grup.verb (PRON esten) (gerundi (VERB pasando))))))) (VERB ....)))
public static boolean checkRootTransition(Tree tree)
public java.util.List<Tree> filterTreebank(Treebank treebank)
public static java.util.List<Tree> binarizeTreebank(java.lang.Iterable<Tree> treebank, Options op)
public static java.util.Set<java.lang.String> findKnownStates(java.util.List<Tree> binarizedTrees)
public static void findKnownStates(Tree tree, java.util.Set<java.lang.String> knownStates)
public void setOptionFlags(java.lang.String... flags)
setOptionFlags
in class ParserGrammar
public static ShiftReduceParser loadModel(java.lang.String path, java.lang.String... extraFlags)
public void saveModel(java.lang.String path)
public static void main(java.lang.String[] args)