/* CSTLEMMA - trainable lemmatiser Copyright (C) 2002, 2005 Center for Sprogteknologi, University of Copenhagen This file is part of CSTLEMMA. CSTLEMMA is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. CSTLEMMA is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with CSTLEMMA; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ long nextprime(unsigned long g) { int i; unsigned long smalldivisor; static int byte[12]= {1, 2, 2, 4, 2, 4, 2, 4, 6, 2, 6}; /*2-3,3-5,5-7,7-11,11-13,13-17,17-19,19-23,23-29,29-1,1-7*/ unsigned long bigdivisor; if(g & 1) ++g; /* even -> uneven */ smalldivisor = 2; i = 0; while((bigdivisor = g / smalldivisor) >= smalldivisor) { if(bigdivisor * smalldivisor == g) { ++g; smalldivisor = 2; i = 0; } else { smalldivisor += byte[i]; if(++i > 10) i = 3; } } return g; } long casesensitivehash(const char * cp) { long hash_temp = 0; while (*cp != '\0') { if(hash_temp < 0) hash_temp = (hash_temp << 1) +1; else hash_temp = hash_temp << 1; hash_temp ^= *cp; ++cp; } return hash_temp; }