Exemple #1
0
/* In `stem(p, i, j)`, `p` is a `char` pointer, and the
 * string to be stemmed is from `p[i]` to
 * `p[j]` (inclusive).
 *
 * Typically, `i` is zero and `j` is the offset to the
 * last character of a string, `(p[j + 1] == '\0')`.
 * The stemmer adjusts the characters `p[i]` ... `p[j]`
 * and returns the new end-point of the string, `k`.
 *
 * Stemming never increases word length, so `i <= k <= j`.
 *
 * To turn the stemmer into a module, declare 'stem' as
 * extern, and delete the remainder of this file. */
int
stem(char *p, int index, int position) {
  /* Copy the parameters into statics. */
  b = p;
  k = position;
  k0 = index;

  if (k <= k0 + 1) {
    return k; /* --DEPARTURE-- */
  }

  /* With this line, strings of length 1 or 2 don't
   * go through the stemming process, although no
   * mention is made of this in the published
   * algorithm. Remove the line to match the published
   * algorithm. */
  step1ab();

  if (k > k0) {
    step1c();
    step2();
    step3();
    step4();
    step5();
  }

  return k;
}
Exemple #2
0
static size_t stem(char *p, size_t i, size_t j) {

    b  = p;
    k  = j;
    k0 = i; /* copy the parameters into statics */

    /*
     * DEPARTURE: This next 'if' statement prevents strings of length 1 or 2 from
     * going through the stemming process, although no mention is made of this in the
     * published algorithm. Remove the line to match the publishedalgorithm.
     */

    if (k <= k0 + 1)
        return k;

    step1ab();
    if (k > k0) {
        step1c();
        step2();
        step3();
        step4();
        step5();
    }

    return k;
}
Exemple #3
0
/* In stem(p,i,j), p is a char pointer, and the string to be stemmed is from
   p[i] to p[j] inclusive. Typically i is zero and j is the offset to the last
   character of a string, (p[j+1] == '\0'). The stemmer adjusts the
   characters p[i] ... p[j] and returns the new end-point of the string, k.
   Stemming never increases word length, so i <= k <= j. To turn the stemmer
   into a module, declare 'stem' as extern, and delete the remainder of this
   file.
*/
static ssize_t
stem(char *s, size_t z)
{
	/* copy the parameters into statics */
	b = s;
	k = z - 1;
	k0 = 0;

	if (k <= k0 + 1) {
		/*-DEPARTURE-*/
		return k;
	}

	/* With this line, strings of length 1 or 2 don't go through the
	   stemming process, although no mention is made of this in the
	   published algorithm. Remove the line to match the published
	   algorithm. */
	step1ab();
	step1c();
	step2();
	step3();
	step4();
	step5();
	return k;
}
int stem(char * p, int i, int j)
{  b = p; k = j; k0 = i; /* copy the parameters into statics */
   if (k <= k0+1) return k; /*-DEPARTURE-*/

   /* With this line, strings of length 1 or 2 don't go through the
      stemming process, although no mention is made of this in the
      published algorithm. Remove the line to match the published
      algorithm. */

   step1ab(); step1c(); step2(); step3(); step4(); step5();
   return k;
}
extern int stem_ts(struct stemmer * z, char * b, int k)
{
   if (k <= 1) return k; /*-DEPARTURE-*/
   z->b = b; z->k = k; /* copy the parameters into z */

   /* With this line, strings of length 1 or 2 don't go through the
      stemming process, although no mention is made of this in the
      published algorithm. Remove the line to match the published
      algorithm. */

   step1ab(z); step1c(z); step2(z); step3(z); step4(z); step5(z);
   return z->k;
}
Exemple #6
0
/* nml: this function slightly modified to not require external stemmer 
 * structure or length count (accepts NUL-terminated term) */
void stem_porters(void *opaque, char *term) {
   struct stemmer z;

   z.b = term; z.k = str_len(term) - 1; /* copy the parameters into z */
   if (z.k <= 1) return; /*-DEPARTURE-*/

   /* With this line, strings of length 1 or 2 don't go through the
      stemming process, although no mention is made of this in the
      published algorithm. Remove the line to match the published
      algorithm. */

   step1ab(&z); step1c(&z); step2(&z); step3(&z); step4(&z); step5(&z);
   term[z.k + 1] = '\0';  /* zero-terminate string */
}
Exemple #7
0
wchar_t*
s_stem(wchar_t *word) {
	wchar_t* copy;

	copy = malloc(sizeof(*copy) * (wcslen(word)+1));
	wcscpy(copy, word);	
	
	step1a(copy);
	step1b(copy);
	step1c(copy);
	step2(copy);
	step3(copy);
	step4(copy);
	step5(copy);
	
	return copy;
}