class documentation

class TransitionParser(ParserI): (source)

Constructor: TransitionParser(algorithm)

View In Hierarchy

Class for transition based parser. Implement 2 algorithms which are "arc-standard" and "arc-eager"

Method __init__ No summary
Method parse No summary
Method train :param depgraphs : list of DependencyGraph as the training data :type depgraphs : DependencyGraph :param modelfile : file name to save the trained model :type modelfile : str
Constant ARC_EAGER Undocumented
Constant ARC_STANDARD Undocumented
Method _convert_to_binary_features :return : string of binary features in libsvm format which is 'featureID:value' pairs
Method _create_training_examples_arc_eager Create the training example in the libsvm format and write it to the input_file. Reference : 'A Dynamic Oracle for Arc-Eager Dependency Parsing' by Joav Goldberg and Joakim Nivre
Method _create_training_examples_arc_std Create the training example in the libsvm format and write it to the input_file. Reference : Page 32, Chapter 3. Dependency Parsing by Sandra Kubler, Ryan McDonal and Joakim Nivre (2009)
Method _get_dep_relation Undocumented
Method _is_projective Undocumented
Method _write_to_file write the binary features to input file and update the transition dictionary
Instance Variable _algorithm Undocumented
Instance Variable _dictionary Undocumented
Instance Variable _match_transition Undocumented
Instance Variable _transition Undocumented
def __init__(self, algorithm): (source)
Parameters
algorithm:strthe algorithm option of this parser. Currently support arc-standard and arc-eager algorithm
def parse(self, depgraphs, modelFile): (source)
Parameters
depgraphs:list(DependencyGraph)the list of test sentence, each sentence is represented as a dependency graph where the 'head' information is dummy
modelFileUndocumented
modelfile:strthe model file
Returns
list (DependencyGraph) with the 'head' and 'rel' information
def train(self, depgraphs, modelfile, verbose=True): (source)

:param depgraphs : list of DependencyGraph as the training data :type depgraphs : DependencyGraph :param modelfile : file name to save the trained model :type modelfile : str

ARC_EAGER: str = (source)

Undocumented

Value
'arc-eager'
ARC_STANDARD: str = (source)

Undocumented

Value
'arc-standard'
def _convert_to_binary_features(self, features): (source)

:return : string of binary features in libsvm format which is 'featureID:value' pairs

Parameters
features:list(str)list of feature string which is needed to convert to binary features
def _create_training_examples_arc_eager(self, depgraphs, input_file): (source)

Create the training example in the libsvm format and write it to the input_file. Reference : 'A Dynamic Oracle for Arc-Eager Dependency Parsing' by Joav Goldberg and Joakim Nivre

def _create_training_examples_arc_std(self, depgraphs, input_file): (source)

Create the training example in the libsvm format and write it to the input_file. Reference : Page 32, Chapter 3. Dependency Parsing by Sandra Kubler, Ryan McDonal and Joakim Nivre (2009)

def _get_dep_relation(self, idx_parent, idx_child, depgraph): (source)

Undocumented

def _is_projective(self, depgraph): (source)

Undocumented

def _write_to_file(self, key, binary_features, input_file): (source)

write the binary features to input file and update the transition dictionary

_algorithm = (source)

Undocumented

_dictionary: dict = (source)

Undocumented

_match_transition: dict = (source)

Undocumented

_transition: dict = (source)

Undocumented