Ejemplo n.º 1
0
void dictionary_delete(Dictionary dict)
{
	if (!dict) return;

	if (verbosity > 0) {
		prt_error("Info: Freeing dictionary %s", dict->name);
	}

#ifdef USE_CORPUS
	lg_corpus_delete(dict->corpus);
#endif

	if (dict->affix_table != NULL) {
		affix_list_delete(dict->affix_table);
		dictionary_delete(dict->affix_table);
	}
	spellcheck_destroy(dict->spell_checker);

	connector_set_delete(dict->unlimited_connector_set);

	if (dict->close) dict->close(dict);

	pp_knowledge_close(dict->base_knowledge);
	pp_knowledge_close(dict->hpsg_knowledge);
	string_set_delete(dict->string_set);
	free_regexs(dict->regex_root);
#ifdef USE_ANYSPLIT
	free_anysplit(dict);
#endif
	free_dictionary(dict);
	xfree(dict, sizeof(struct Dictionary_s));
	object_open(NULL, NULL, NULL); /* Free the directory path cache */
}
Ejemplo n.º 2
0
pp_knowledge *pp_knowledge_open(const char *path)
{
  /* read knowledge from disk into pp_knowledge */
  FILE *f = dictopen(path, "r");
  if (NULL == f)
  {
    prt_error("Error: Couldn't find post-process knowledge file %s\n", path);
    return NULL;
  }
  pp_knowledge *k = (pp_knowledge *) malloc (sizeof(pp_knowledge));
  *k = (pp_knowledge){0};
  k->lt = pp_lexer_open(f);
  fclose(f);
  if (NULL == k->lt) goto failure;
  k->string_set = string_set_create();
  k->path = string_set_add(path, k->string_set);
  if (!read_starting_link_table(k)) goto failure;

  if (!read_link_sets(k)) goto failure;
  if (!read_rules(k)) goto failure;
  initialize_set_of_links_starting_bounded_domain(k);

  /* If the knowledge file was empty, do nothing at all. */
  if (0 == k->nStartingLinks)
  {
    pp_knowledge_close(k);
    return NULL;
  }

  return k;

failure:
  prt_error("Error: Unable to open knowledge file %s.\n", path);
  pp_knowledge_close(k);
  return NULL;
}
Ejemplo n.º 3
0
void post_process_close(Postprocessor *pp)
{
  /* frees up memory associated with pp, previously allocated by open */
  if (pp==NULL) return;
  string_set_delete(pp->sentence_link_name_set);
  pp_linkset_close(pp->set_of_links_of_sentence);
  pp_linkset_close(pp->set_of_links_in_an_active_rule);
  xfree(pp->relevant_contains_one_rules, 
	(1+pp->knowledge->n_contains_one_rules)
	*(sizeof pp->relevant_contains_one_rules[0]));
  xfree(pp->relevant_contains_none_rules,
	(1+pp->knowledge->n_contains_none_rules)
	*(sizeof pp->relevant_contains_none_rules[0]));
  pp_knowledge_close(pp->knowledge);
  free_pp_node(pp);
  xfree(pp, sizeof(Postprocessor));
}
Ejemplo n.º 4
0
void post_process_close(PostProcessor *pp)
{
	pp_knowledge_close(pp->knowledge);
	post_process_free(pp);
}