A shift-reduce constituency parser.
More...
#include <sr_parser.h>
|
enum | training_algorithm { EARLY_TERMINATION,
BEAM_SEARCH
} |
| The set of training algorithms available for the parser.
|
|
using | feature_vector = std::unordered_map< std::string, float > |
| Sparse vector representation of a state's features.
|
|
using | weight_vector = util::sparse_vector< trans_id, float > |
| A single weight vector for a specific transition.
|
|
using | weight_vectors = std::unordered_map< std::string, weight_vector > |
| A collection of weight vectors by feature type.
|
|
|
using | scored_trans = std::pair< trans_id, float > |
|
|
void | load (const std::string &prefix) |
|
std::tuple< weight_vectors, uint64_t, uint64_t > | train_batch (training_batch batch, parallel::thread_pool &pool, const training_options &options) |
| Calculates a weight update on a given batch of training trees. More...
|
|
std::pair< uint64_t, uint64_t > | train_instance (const parse_tree &tree, const std::vector< trans_id > &transitions, const training_options &options, weight_vectors &update) const |
| Calculates a weight update on a single tree. More...
|
|
std::pair< uint64_t, uint64_t > | train_early_termination (const parse_tree &tree, const std::vector< trans_id > &transitions, weight_vectors &update) const |
| Calculates a weight update on a single tree, using the greedy early termination training strategy. More...
|
|
std::pair< uint64_t, uint64_t > | train_beam_search (const parse_tree &tree, const std::vector< trans_id > &transitions, const training_options &options, weight_vectors &update) const |
| Calculates a weight update on a single tree, using beam search. More...
|
|
trans_id | best_transition (const feature_vector &features, const state &state, bool check_legality=false) const |
| Computes the most likely transition according to the current model. More...
|
|
std::vector< scored_trans > | best_transitions (const feature_vector &features, const state &state, size_t num, bool check_legality=false) const |
| Computes the \(k\) most likely transitions according to the current model. More...
|
|
A shift-reduce constituency parser.
The model is a simple linear classifier learned via the generalized averaged perceptron algorithm that seeks to classify a parser action given a parser state.
- See also
- http://people.sutd.edu.sg/~yue_zhang/pub/acl13.muhua.pdf
-
http://www.aclweb.org/anthology/W09-3825
meta::parser::sr_parser::sr_parser |
( |
const std::string & |
prefix | ) |
|
Loads a pre-trained parser from a prefix.
- Parameters
-
prefix | The prefix to load the parser model from |
Parses a POS-tagged sentence (represented as a sequence::sequence).
- Parameters
-
sentence | The sentence to be tagged |
- Returns
- the parse tree corresponding to the input sentence
Trains a model on the given parse trees using the supplied training options.
- Parameters
-
trees | The full parse trees for training |
options | The options used for training |
void meta::parser::sr_parser::save |
( |
const std::string & |
prefix | ) |
const |
- Parameters
-
prefix | The prefix to store the model in |
void meta::parser::sr_parser::load |
( |
const std::string & |
prefix | ) |
|
|
private |
- Parameters
-
prefix | The prefix to load the model from |
Calculates a weight update on a given batch of training trees.
- Parameters
-
batch | The batch to learn on |
pool | The thread pool to use for parsing the batch in parallel |
options | The training options |
- Returns
- a 3-tuple (update, correct actions, incorrect actions)
std::pair< uint64_t, uint64_t > meta::parser::sr_parser::train_instance |
( |
const parse_tree & |
tree, |
|
|
const std::vector< trans_id > & |
transitions, |
|
|
const training_options & |
options, |
|
|
weight_vectors & |
update |
|
) |
| const |
|
private |
Calculates a weight update on a single tree.
- Parameters
-
tree | The training tree |
transitions | The correct transitions for parsing this tree |
options | The training options |
update | The weight vector to place the update in |
- Returns
- (correct actions, incorrect actions)
std::pair< uint64_t, uint64_t > meta::parser::sr_parser::train_early_termination |
( |
const parse_tree & |
tree, |
|
|
const std::vector< trans_id > & |
transitions, |
|
|
weight_vectors & |
update |
|
) |
| const |
|
private |
Calculates a weight update on a single tree, using the greedy early termination training strategy.
- Parameters
-
tree | The training tree |
transitions | The correct transitions for parsing this tree |
options | The training options |
update | The weight vector to place the update in |
- Returns
- (correct actions, incorrect actions)
std::pair< uint64_t, uint64_t > meta::parser::sr_parser::train_beam_search |
( |
const parse_tree & |
tree, |
|
|
const std::vector< trans_id > & |
transitions, |
|
|
const training_options & |
options, |
|
|
weight_vectors & |
update |
|
) |
| const |
|
private |
Calculates a weight update on a single tree, using beam search.
- Parameters
-
tree | The training tree |
transitions | The correct transitions for parsing this tree |
options | The training options |
update | The weight vector to place the update in |
- Returns
- (correct actions, incorrect actions)
auto meta::parser::sr_parser::best_transition |
( |
const feature_vector & |
features, |
|
|
const state & |
state, |
|
|
bool |
check_legality = false |
|
) |
| const |
|
private |
Computes the most likely transition according to the current model.
- Parameters
-
features | The feature vector representation for the current state |
state | The current state |
check_legality | Whether or not to limit the transitions to only those that are "legal" according to the constraints given for each transition |
auto meta::parser::sr_parser::best_transitions |
( |
const feature_vector & |
features, |
|
|
const state & |
state, |
|
|
size_t |
num, |
|
|
bool |
check_legality = false |
|
) |
| const |
|
private |
Computes the \(k\) most likely transitions according to the current model.
- Parameters
-
features | The feature vector representation for the current state |
state | The current state |
check_legality | Whether or not to limit the transitions to only those that are "legal" according to the constraints given for each transition |
The documentation for this class was generated from the following files: