summaryrefslogtreecommitdiff
path: root/decoder
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2011-03-03 13:14:08 -0500
committerChris Dyer <cdyer@cs.cmu.edu>2011-03-03 13:14:08 -0500
commit4ffb06ee501d9806542c34a9aac8e6406416d35b (patch)
treea023196f056a4dce46b52b3462c6dfde67784866 /decoder
parent0169e4df3e96540ee30f00408e42e087ce07afc4 (diff)
fix potential crash on long sentences
Diffstat (limited to 'decoder')
-rw-r--r--decoder/bottom_up_parser.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/decoder/bottom_up_parser.cc b/decoder/bottom_up_parser.cc
index aecf1cfa..e3751e23 100644
--- a/decoder/bottom_up_parser.cc
+++ b/decoder/bottom_up_parser.cc
@@ -219,8 +219,10 @@ void PassiveChart::ApplyUnaryRules(const int i, const int j) {
}
bool PassiveChart::Parse() {
- forest_->nodes_.reserve(input_.size() * input_.size() * 2);
- forest_->edges_.reserve(input_.size() * input_.size() * 1000); // TODO: reservation??
+ size_t in_size_2 = input_.size() * input_.size();
+ forest_->nodes_.reserve(in_size_2 * 2);
+ size_t res = min(2000000ul, in_size_2 * 1000);
+ forest_->edges_.reserve(res);
goal_idx_ = -1;
for (int gi = 0; gi < grammars_.size(); ++gi)
act_chart_[gi]->SeedActiveChart(*grammars_[gi]);