[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ZopeSplitter/src - ZopeSplitter.c:1.5.10.3

Andreas Jung andreas@zope.com
Tue, 8 Jan 2002 14:21:15 -0500


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ZopeSplitter/src
In directory cvs.zope.org:/tmp/cvs-serv18004/src

Modified Files:
      Tag: ajung-textindexng-branch
	ZopeSplitter.c 
Log Message:
introducing new optional parameters for the constructor:

'maxlen' = <int> -- maximum length or returned words (stem) (default 64)
'singlechar' = 0|1 -- allow single chars to be indexed    (default 0)
'indexnumbers' = 0|1  -- allow indexing of numbers         (default 0)


=== Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ZopeSplitter/src/ZopeSplitter.c 1.5.10.2 => 1.5.10.3 ===
     int allow_single_chars;
     int index_numbers;
-    int max_words;
+    int max_len;
 }
 
 Splitter;
@@ -179,13 +179,13 @@
             if(startpos && i==0)
                 *startpos=here;
 
-            if(i++ < self->max_words)
+            if(i++ < self->max_len)
                 *b++ = c;
 
         } else if (i != 0) { /* We've found the end of a word */
 
-            if(i >= self->max_words)
-                i=self->max_words; /* "stem" the long word */
+            if(i >= self->max_len)
+                i=self->max_len; /* "stem" the long word */
 
             UNLESS(pyword = PyString_FromStringAndSize(wbuf, i)) {
                 self->here=here;
@@ -229,8 +229,8 @@
 
     /* We've reached the end of the string */
 
-    if(i >= self->max_words)
-        i=self->max_words; /* "stem" the long word */
+    if(i >= self->max_len)
+        i=self->max_len; /* "stem" the long word */
 
     if (i == 0) {
         /* No words */
@@ -435,7 +435,7 @@
     SplitterType__doc__ /* Documentation string */
 };
 
-static char *splitter_args[]={"doc","synstop","encoding","singlechar","indexnumbers","maxwords",NULL};
+static char *splitter_args[]={"doc","synstop","encoding","singlechar","indexnumbers","maxlen",NULL};
 
 
 static PyObject *
@@ -446,10 +446,10 @@
     char *encoding = "latin1";
     int single_char = 0;
     int index_numbers = 0;
-    int max_words= 64;
+    int max_len= 64;
 
     UNLESS(PyArg_ParseTupleAndKeywords(args,keywds,"O|Osiii",splitter_args, \
-                                       &doc,&synstop,&encoding,&single_char,&index_numbers,&max_words)) return NULL;
+                                       &doc,&synstop,&encoding,&single_char,&index_numbers,&max_len)) return NULL;
 
     UNLESS(self = PyObject_NEW(Splitter, &SplitterType)) return NULL;
 
@@ -469,7 +469,7 @@
     self->index = -1;
     self->allow_single_chars = single_char;
     self->index_numbers      = index_numbers;
-    self->max_words          = max_words;
+    self->max_len            = max_len;
 
     return (PyObject*)self;
 
@@ -482,7 +482,7 @@
 static struct PyMethodDef Splitter_module_methods[] =
     {
         { "ZopeSplitter", (PyCFunction)get_Splitter, METH_VARARGS|METH_KEYWORDS,
-            "ZopeSplitter(doc[,synstop][,encoding][,singlechar][,indexnumbers]) -- Return a word splitter"
+            "ZopeSplitter(doc[,synstop][,encoding][,singlechar][,indexnumbers][,maxlen]) -- Return a word splitter"
         },
 
         { NULL, NULL }