From aa13090b66d7ee1ffc68ad242c6419a83cf364d9 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Wed, 12 Dec 2012 11:25:58 +0000 Subject: started an official API to the C runtime --- src/runtime/c/utils/pgf-chunk.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'src/runtime/c/utils/pgf-chunk.c') diff --git a/src/runtime/c/utils/pgf-chunk.c b/src/runtime/c/utils/pgf-chunk.c index c4d0d0b3f..d5e203368 100644 --- a/src/runtime/c/utils/pgf-chunk.c +++ b/src/runtime/c/utils/pgf-chunk.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -39,38 +38,28 @@ int main(int argc, char* argv[]) { GuString from_lang = gu_str_string(argv[3], pool); - FILE* infile = fopen(filename, "r"); - if (infile == NULL) { - fprintf(stderr, "couldn't open %s\n", filename); - status = EXIT_FAILURE; - goto fail; - } - - // Create an input stream from the input file - GuIn* in = gu_file_in(infile, pool); - // Create an exception frame that catches all errors. GuExn* err = gu_new_exn(NULL, gu_kind(type), pool); // Read the PGF grammar. - PgfPGF* pgf = pgf_read(in, pool, err); + PgfPGF* pgf = pgf_read(filename, pool, err); // If an error occured, it shows in the exception frame if (!gu_ok(err)) { fprintf(stderr, "Reading PGF failed\n"); status = EXIT_FAILURE; - goto fail_read; + goto fail; } - if (!pgf_load_meta_child_probs(pgf, "../../../treebanks/PennTreebank/ParseEngAbs3.probs", pool)) { + pgf_load_meta_child_probs(pgf, "../../../treebanks/PennTreebank/ParseEngAbs3.probs", pool, err); + if (!gu_ok(err)) { fprintf(stderr, "Loading meta child probs failed\n"); status = EXIT_FAILURE; - goto fail_read; + goto fail; } // Look up the source and destination concrete categories - PgfConcr* from_concr = - gu_map_get(pgf->concretes, &from_lang, PgfConcr*); + PgfConcr* from_concr = pgf_get_language(pgf, from_lang); if (!from_concr) { fprintf(stderr, "Unknown language\n"); status = EXIT_FAILURE; @@ -152,8 +141,6 @@ int main(int argc, char* argv[]) { ppool = NULL; } fail_concr: -fail_read: - fclose(infile); fail: gu_pool_free(pool); return status; -- cgit v1.2.3