summaryrefslogtreecommitdiff
path: root/decoder/ff_const_reorder.cc
diff options
context:
space:
mode:
Diffstat (limited to 'decoder/ff_const_reorder.cc')
-rw-r--r--decoder/ff_const_reorder.cc54
1 files changed, 29 insertions, 25 deletions
diff --git a/decoder/ff_const_reorder.cc b/decoder/ff_const_reorder.cc
index 8bd3f4e2..c0269125 100644
--- a/decoder/ff_const_reorder.cc
+++ b/decoder/ff_const_reorder.cc
@@ -9,6 +9,7 @@
#include "hash.h"
#include "argument_reorder_model.h"
+#include <sstream>
#include <string>
#include <vector>
#include <stdio.h>
@@ -187,14 +188,6 @@ struct TargetTranslation {
vec_f_align_bit_array_(end_pos - begin_pos + 1, NULL),
vec_e_align_bit_array_(e_num_word, NULL) {
int len = end_pos - begin_pos + 1;
-
- /*vec_f_align_bit_array_.reserve(len);
- for (int i = 0; i < len; i++)
- vec_f_align_bit_array_.push_back(NULL);
-
- vec_e_align_bit_array_.reserve(e_num_word);
- for (int i = 0; i < e_num_word; i++)
- vec_e_align_bit_array_.push_back(NULL);*/
align_.reserve(1.5 * len);
}
~TargetTranslation() {
@@ -304,17 +297,16 @@ struct TargetTranslation {
if (target_end == -1) target_begin = -1;
}
- const uint16_t begin_pos_, end_pos_; // the position in parse
+ const uint16_t begin_pos_, end_pos_; // the position in parse
const uint16_t input_begin_pos_, input_end_pos_; // the position in input
const uint16_t e_num_words_;
vector<AlignmentPoint*> align_;
private:
- vector<SBitArray*> vec_f_align_bit_array_;
- vector<SBitArray*> vec_e_align_bit_array_;
-
vector<short> vec_left_most_;
vector<short> vec_right_most_;
+ vector<SBitArray*> vec_f_align_bit_array_;
+ vector<SBitArray*> vec_e_align_bit_array_;
};
struct FocusedConstituent {
@@ -710,7 +702,7 @@ struct ConstReorderFeatureImpl {
SparseVector<double>* features,
const TargetTranslation* target_translation,
const vector<const TargetTranslation*>& vec_node,
- std::vector<int>& findex) {
+ std::vector<int>& /*findex*/) {
if (b_srl_block_feature_ || b_srl_order_feature_) {
double logprob_srl_reorder_left = 0.0, logprob_srl_reorder_right = 0.0;
for (size_t i = 0; i < focused_srl_->focus_predicates_.size(); i++) {
@@ -1327,6 +1319,7 @@ struct ConstReorderFeatureImpl {
ConstReorderFeature::ConstReorderFeature(const std::string& param) {
pimpl_ = new ConstReorderFeatureImpl(param);
SetStateSize(ConstReorderFeatureImpl::ReserveStateSize());
+ SetIgnoredStateSize(ConstReorderFeatureImpl::ReserveStateSize());
name_ = "ConstReorderFeature";
}
@@ -1346,12 +1339,32 @@ void ConstReorderFeature::PrepareForInput(const SentenceMetadata& smeta) {
void ConstReorderFeature::TraversalFeaturesImpl(
const SentenceMetadata& /* smeta */, const Hypergraph::Edge& edge,
const vector<const void*>& ant_states, SparseVector<double>* features,
- SparseVector<double>* estimated_features, void* state) const {
+ SparseVector<double>* /*estimated_features*/, void* state) const {
pimpl_->SetConstReorderFeature(edge, features, ant_states, state);
}
-string ConstReorderFeature::usage(bool /*param*/, bool /*verbose*/) {
- return "ConstReorderFeature";
+string ConstReorderFeature::usage(bool show_params, bool show_details) {
+ ostringstream out;
+ out << "ConstReorderFeature";
+ if (show_params) {
+ out << " model_file_prefix [const_block=1 const_order=1] [srl_block=0 "
+ "srl_order=0]"
+ << "\nParameters:\n"
+ << " const_{block,order}: enable/disable constituency constraints.\n"
+ << " src_{block,order}: enable/disable semantic role labeling "
+ "constraints.\n";
+ }
+ if (show_details) {
+ out << "\n"
+ << "Soft reordering constraint features from "
+ "http://www.aclweb.org/anthology/P14-1106. To train the classifers, "
+ "use utils/const_reorder_model_trainer for constituency reordering "
+ "constraints and utils/argument_reorder_model_trainer for semantic "
+ "role labeling reordering constraints.\n"
+ << "Input segments should provide path to parse tree (resp. SRL parse) "
+ "as \"parse\" (resp. \"srl\") properties.\n";
+ }
+ return out.str();
}
boost::shared_ptr<FeatureFunction> CreateConstReorderModel(
@@ -1359,12 +1372,3 @@ boost::shared_ptr<FeatureFunction> CreateConstReorderModel(
ConstReorderFeature* ret = new ConstReorderFeature(param);
return boost::shared_ptr<FeatureFunction>(ret);
}
-
-boost::shared_ptr<FeatureFunction> ConstReorderFeatureFactory::Create(
- std::string param) const {
- return CreateConstReorderModel(param);
-}
-
-std::string ConstReorderFeatureFactory::usage(bool params, bool verbose) const {
- return ConstReorderFeature::usage(params, verbose);
-}