diff options
Diffstat (limited to 'contrib/tsearch2/gendict/dict_snowball.c.IN')
| -rw-r--r-- | contrib/tsearch2/gendict/dict_snowball.c.IN | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/contrib/tsearch2/gendict/dict_snowball.c.IN b/contrib/tsearch2/gendict/dict_snowball.c.IN new file mode 100644 index 0000000000..10ef6f1c5e --- /dev/null +++ b/contrib/tsearch2/gendict/dict_snowball.c.IN @@ -0,0 +1,52 @@ +/* + * example of Snowball dictionary + * http://snowball.tartarus.org/ + * Teodor Sigaev <teodor@sigaev.ru> + */ +#include <stdlib.h> +#include <string.h> + +#include "postgres.h" + +#include "dict.h" +#include "common.h" +#include "snowball/header.h" +#include "subinclude.h" + +typedef struct { + struct SN_env *z; + StopList stoplist; + int (*stem)(struct SN_env * z); +} DictSnowball; + + +PG_FUNCTION_INFO_V1(dinit_CFG_MODNAME); +Datum dinit_CFG_MODNAME(PG_FUNCTION_ARGS); + +Datum +dinit_CFG_MODNAME(PG_FUNCTION_ARGS) { + DictSnowball *d = (DictSnowball*)malloc( sizeof(DictSnowball) ); + + if ( !d ) + elog(ERROR, "No memory"); + memset(d,0,sizeof(DictSnowball)); + d->stoplist.wordop=lowerstr; + + if ( !PG_ARGISNULL(0) && PG_GETARG_POINTER(0)!=NULL ) { + text *in = PG_GETARG_TEXT_P(0); + readstoplist(in, &(d->stoplist)); + sortstoplist(&(d->stoplist)); + PG_FREE_IF_COPY(in, 0); + } + + d->z = CFG_PREFIX_create_env(); + if (!d->z) { + freestoplist(&(d->stoplist)); + elog(ERROR,"No memory"); + } + d->stem=CFG_PREFIX_stem; + + PG_RETURN_POINTER(d); +} + + |
