#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#include "stem_english.h"
#include "crc32.h"

static void *stemobj = NULL;

static int
not_here(char *s)
{
    croak("%s not implemented on this architecture", s);
    return -1;
}

static double
constant(char *name, int arg)
{
    errno = 0;
    switch (*name) {
    }
    errno = EINVAL;
    return 0;

not_there:
    errno = ENOENT;
    return 0;
}


MODULE = Search::OpenFTS::Dict::PorterEng               PACKAGE = Search::OpenFTS::Dict::PorterEng


double
constant(name,arg)
        char *          name
        int             arg

PROTOTYPES: DISABLE

char *
Lexem( word )
        char *  word
	CODE:
	 if ( ! stemobj ) stemobj = setup_english_stemmer();
	 RETVAL = (char*)english_stem(stemobj, word, 0, strlen(word)-1 );
	OUTPUT:
	 RETVAL

int
LexemID( word )
        char *  word
	CODE:
	 char *res;
	 if ( ! stemobj ) stemobj = setup_english_stemmer();
	 res = (char*)english_stem(stemobj, word, 0, strlen(word)-1 );
	 RETVAL = crc32( res );
	OUTPUT:
	 RETVAL

int
makeID( word )
	char *  word
	CODE:
	RETVAL = crc32( word );
	OUTPUT:
	RETVAL

void
destroy()
	CODE:
	 if ( stemobj ) closedown_english_stemmer(stemobj);
	 stemobj = NULL;

