static per_thread_data * init(JNIEnv *env, jclass cls) { per_thread_data *ptd; /* Get the locale from the environment... * perhaps we should someday get it from the dictionary ?? */ setlocale(LC_ALL, ""); ptd = (per_thread_data *) malloc(sizeof(per_thread_data)); memset(ptd, 0, sizeof(per_thread_data)); ptd->panic_parse_opts = parse_options_create(); setup_panic_parse_options(ptd->panic_parse_opts); ptd->opts = parse_options_create(); parse_options_set_disjunct_cost(ptd->opts, 3); parse_options_set_max_sentence_length(ptd->opts, 170); parse_options_set_max_parse_time(ptd->opts, 30); parse_options_set_linkage_limit(ptd->opts, 1000); parse_options_set_short_length(ptd->opts, 10); parse_options_set_verbosity(ptd->opts,0); parse_options_set_spell_guess(ptd->opts, FALSE); /* Default to the english language; will need to fix * this if/when more languages are supported. */ ptd->dict = dictionary_create_lang("en"); if (!ptd->dict) throwException(env, "Error: unable to open dictionary"); else test(); return ptd; }
static void setup_panic_parse_options(Parse_Options opts) { parse_options_set_disjunct_cost(opts, 4.0f); parse_options_set_min_null_count(opts, 1); parse_options_set_max_null_count(opts, 100); parse_options_set_max_parse_time(opts, 60); parse_options_set_islands_ok(opts, 1); parse_options_set_short_length(opts, 12); parse_options_set_all_short_connectors(opts, 1); parse_options_set_linkage_limit(opts, 100); parse_options_set_spell_guess(opts, false); }
static void setup_panic_parse_options(Parse_Options opts) { parse_options_set_disjunct_cost(opts, 3); parse_options_set_min_null_count(opts, 1); parse_options_set_max_null_count(opts, MAX_SENTENCE); parse_options_set_max_parse_time(opts, 60); parse_options_set_islands_ok(opts, 1); parse_options_set_short_length(opts, 6); parse_options_set_all_short_connectors(opts, 1); parse_options_set_linkage_limit(opts, 100); parse_options_set_verbosity(opts,0); parse_options_set_spell_guess(opts, FALSE); }
static per_thread_data * init(JNIEnv *env, jclass cls) { const char *codeset, *dict_version; per_thread_data *ptd; /* Get the locale from the environment... * perhaps we should someday get it from the dictionary ?? */ setlocale(LC_ALL, ""); /* Everything breaks if the locale is not UTF-8; check for this, * and force the issue ! */ codeset = nl_langinfo(CODESET); if (!strstr(codeset, "UTF") && !strstr(codeset, "utf")) { prt_error("Warning: JNI: locale %s was not UTF-8; force-setting to en_US.UTF-8\n", codeset); setlocale(LC_CTYPE, "en_US.UTF-8"); } ptd = (per_thread_data *) malloc(sizeof(per_thread_data)); memset(ptd, 0, sizeof(per_thread_data)); ptd->panic_parse_opts = parse_options_create(); setup_panic_parse_options(ptd->panic_parse_opts); ptd->opts = parse_options_create(); parse_options_set_disjunct_costf(ptd->opts, 3.0f); parse_options_set_max_sentence_length(ptd->opts, 170); parse_options_set_max_parse_time(ptd->opts, 30); parse_options_set_linkage_limit(ptd->opts, 1000); parse_options_set_short_length(ptd->opts, 10); parse_options_set_verbosity(ptd->opts,0); parse_options_set_spell_guess(ptd->opts, FALSE); /* Default to the english language; will need to fix * this if/when more languages are supported. */ ptd->dict = dictionary_create_lang("en"); if (!ptd->dict) throwException(env, "Error: unable to open dictionary"); else test(); dict_version = linkgrammar_get_dict_version(ptd->dict); prt_error("Info: JNI: dictionary version %s\n", dict_version); return ptd; }
static void put_local_vars_in_opts(Parse_Options opts) { parse_options_set_verbosity(opts, local.verbosity); parse_options_set_max_parse_time(opts, local.timeout); parse_options_set_max_memory(opts, local.memory); parse_options_set_linkage_limit(opts, local.linkage_limit); parse_options_set_null_block(opts, local.null_block); parse_options_set_islands_ok(opts, local.islands_ok); parse_options_set_spell_guess(opts, local.spell_guess); parse_options_set_short_length(opts, local.short_length); parse_options_set_echo_on(opts, local.echo_on); parse_options_set_cost_model_type(opts, local.cost_model); parse_options_set_disjunct_costf(opts, local.max_cost); parse_options_set_batch_mode(opts, local.batch_mode); parse_options_set_panic_mode(opts, local.panic_mode); parse_options_set_screen_width(opts, local.screen_width); parse_options_set_allow_null(opts, local.allow_null); parse_options_set_use_cluster_disjuncts(opts, local.use_cluster_disjuncts); #ifdef USE_FAT_LINKAGES parse_options_set_use_fat_links(opts, local.use_fat_links); parse_options_set_display_union(opts, local.display_union); #endif /* USE_FAT_LINKAGES */ #ifdef USE_SAT_SOLVER parse_options_set_use_sat_parser(opts, local.use_sat_solver); #endif parse_options_set_use_viterbi(opts, local.use_viterbi); parse_options_set_screen_width(opts, local.screen_width); parse_options_set_display_on(opts, local.display_on); parse_options_set_display_postscript(opts, local.display_postscript); parse_options_set_display_constituents(opts, local.display_constituents); parse_options_set_max_sentence_length(opts, local.max_sentence_length); parse_options_set_display_bad(opts, local.display_bad); parse_options_set_display_disjuncts(opts, local.display_disjuncts); parse_options_set_display_links(opts, local.display_links); parse_options_set_display_senses(opts, local.display_senses); parse_options_set_display_walls(opts, local.display_walls); }
static void put_local_vars_in_opts(Command_Options* copts) { Parse_Options opts = copts->popts; parse_options_set_verbosity(opts, local.verbosity); parse_options_set_debug(opts, local.debug); parse_options_set_test(opts, local.test); parse_options_set_max_parse_time(opts, local.timeout); parse_options_set_max_memory(opts, local.memory); parse_options_set_linkage_limit(opts, local.linkage_limit); parse_options_set_islands_ok(opts, local.islands_ok); parse_options_set_spell_guess(opts, local.spell_guess); parse_options_set_short_length(opts, local.short_length); parse_options_set_cost_model_type(opts, local.cost_model); parse_options_set_disjunct_cost(opts, local.max_cost); parse_options_set_use_cluster_disjuncts(opts, local.use_cluster_disjuncts); #ifdef USE_SAT_SOLVER parse_options_set_use_sat_parser(opts, local.use_sat_solver); #endif parse_options_set_use_viterbi(opts, local.use_viterbi); parse_options_set_display_morphology(opts, local.display_morphology); copts->screen_width = local.screen_width; copts->echo_on = local.echo_on; copts->batch_mode = local.batch_mode; copts->panic_mode = local.panic_mode; copts->allow_null = local.allow_null; copts->display_on = local.display_on; copts->display_walls = local.display_walls; copts->display_postscript = local.display_postscript; copts->display_constituents = local.display_constituents; copts->display_bad = local.display_bad; copts->display_disjuncts = local.display_disjuncts; copts->display_links = local.display_links; copts->display_senses = local.display_senses; }