link-grammar-5.8.0/link-grammar/tokenize/spellcheck-aspell.c
/**
 * create a new spell-checker for the language 'lang'
 */
create a new spell-checker for the language 'lang'
create a new spell - checker for the language ' lang '
void * spellcheck_create(const char * lang)
{
	struct linkgrammar_aspell *aspell = NULL;
	size_t i = 0;
	AspellCanHaveError *spell_err = NULL;
	for (i = 0; i < sizeof(spellcheck_lang_mapping)/sizeof(char *); i += 2)
	{
		if (0 != strcmp(lang, spellcheck_lang_mapping[i])) continue;
		aspell = (struct linkgrammar_aspell *)malloc(sizeof(struct linkgrammar_aspell));
		if (!aspell)
		{
			prt_error("Error: out of memory. Aspell not used.\n");
			aspell = NULL;
			break;
		}
		aspell->config = NULL;
		aspell->speller = NULL;
		aspell->config = new_aspell_config();
		if (aspell_config_replace(aspell->config, ASPELL_LANG_KEY,
					spellcheck_lang_mapping[i]) == 0)
		{
			prt_error("Error: failed to set language in aspell: %s\n", lang);
			delete_aspell_config(aspell->config);
			free(aspell);
			aspell = NULL;
			break;
		}
		spell_err = new_aspell_speller(aspell->config);
		if (aspell_error_number(spell_err) != 0)
		{
			prt_error("Error: Aspell: %s\n", aspell_error_message(spell_err));
			delete_aspell_can_have_error(spell_err);
			delete_aspell_config(aspell->config);
			free(aspell);
			aspell = NULL;
			break;
		}
		aspell->speller = to_aspell_speller(spell_err);
		break;
	}
	return aspell;
}
void * spellcheck_create ( const char * lang ) { struct linkgrammar_aspell * aspell = NULL ; size_t i = 0 ; AspellCanHaveError * spell_err = NULL ; for ( i = 0 ; i < sizeof ( spellcheck_lang_mapping ) / sizeof ( char * ) ; i += 2 ) { if ( 0 != strcmp ( lang , spellcheck_lang_mapping [ i ] ) ) continue ; aspell = ( struct linkgrammar_aspell * ) malloc ( sizeof ( struct linkgrammar_aspell ) ) ; if ( ! aspell ) { prt_error ( " \n " ) ; aspell = NULL ; break ; } aspell -> config = NULL ; aspell -> speller = NULL ; aspell -> config = new_aspell_config ( ) ; if ( aspell_config_replace ( aspell -> config , ASPELL_LANG_KEY , spellcheck_lang_mapping [ i ] ) == 0 ) { prt_error ( " \n " , lang ) ; delete_aspell_config ( aspell -> config ) ; free ( aspell ) ; aspell = NULL ; break ; } spell_err = new_aspell_speller ( aspell -> config ) ; if ( aspell_error_number ( spell_err ) != 0 ) { prt_error ( " \n " , aspell_error_message ( spell_err ) ) ; delete_aspell_can_have_error ( spell_err ) ; delete_aspell_config ( aspell -> config ) ; free ( aspell ) ; aspell = NULL ; break ; } aspell -> speller = to_aspell_speller ( spell_err ) ; break ; } return aspell ; }
create a new spell-checker for the language 'lang'
create a new spell - checker for the language ' lang '