diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2012-06-12 11:30:01 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2012-06-12 11:30:01 +0000 |
| commit | c9c5675e1dba3dc371d53c8255743e0eb38488e2 (patch) | |
| tree | 8b0ebaee6197c13cc64048b7f25d176c45091141 /src/runtime/c/pgf/parser.c | |
| parent | 90306fa926bfebec64ffdd61524c67a45330cd46 (diff) | |
now there is a limit of 2000000 items in the chart of the robust parser. This prevents from explosion in the memory size but it will also prevent us from parsing some sentences.
Diffstat (limited to 'src/runtime/c/pgf/parser.c')
| -rw-r--r-- | src/runtime/c/pgf/parser.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/runtime/c/pgf/parser.c b/src/runtime/c/pgf/parser.c index a05600884..10bff32d6 100644 --- a/src/runtime/c/pgf/parser.c +++ b/src/runtime/c/pgf/parser.c @@ -31,6 +31,7 @@ typedef struct { PgfItem* target; PgfProduction meta_prod; int max_fid; + int item_count; } PgfParsing; typedef struct { @@ -686,6 +687,7 @@ pgf_parsing_production(PgfParseState* state, { PgfItem* item = pgf_new_item(state->offset, ccat, lin_idx, prod, conts, delta_prob, state->pool); + state->ps->item_count++; gu_buf_heap_push(state->agenda, &pgf_item_prob_order, &item); } @@ -875,6 +877,7 @@ pgf_parsing_td_predict(PgfParseState* before, PgfParseState* after, // Top-down prediction for meta rules PgfItem *item = pgf_new_item(before->offset, ccat, lin_idx, before->ps->meta_prod, conts, 0, before->pool); + before->ps->item_count++; item->inside_prob = ccat->cnccat->abscat->meta_prob; gu_buf_heap_push(before->agenda, &pgf_item_prob_order, &item); @@ -1425,6 +1428,9 @@ static PgfLiteralCallback pgf_meta_callback = static void pgf_parsing_proceed(PgfParseState* state, void** output) { while (*output == NULL) { + if (state->ps->item_count > state->ps->concr->item_quota) + break; + float best_prob = INFINITY; PgfParseState* before = NULL; @@ -1476,6 +1482,7 @@ pgf_new_parsing(PgfConcr* concr, GuPool* pool) ps->completed = NULL; ps->target = NULL; ps->max_fid = concr->max_fid; + ps->item_count = 0; PgfProductionExtern* pext = gu_new_variant(PGF_PRODUCTION_EXTERN, @@ -1757,11 +1764,13 @@ pgf_parser_init_state(PgfConcr* concr, PgfCId cat, size_t lin_idx, GuPool* pool) gu_seq_get(prods, PgfProduction, i); PgfItem* item = pgf_new_item(0, ccat, lin_idx, prod, conts, 0, pool); + ps->item_count++; gu_buf_heap_push(state->agenda, &pgf_item_prob_order, &item); } PgfItem *item = pgf_new_item(0, ccat, lin_idx, ps->meta_prod, conts, 0, pool); + ps->item_count++; item->inside_prob = ccat->cnccat->abscat->meta_prob; gu_buf_heap_push(state->agenda, &pgf_item_prob_order, &item); |
