[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG/src - indexsupport.c:1.1.2.3
Andreas Jung
andreas@digicool.com
Fri, 22 Feb 2002 21:14:37 -0500
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG/src
In directory cvs.zope.org:/tmp/cvs-serv13089/src
Modified Files:
Tag: ajung-textindexng-branch
indexsupport.c
Log Message:
added listIndexes()
=== Zope/lib/python/Products/PluginIndexes/TextIndexNG/src/indexsupport.c 1.1.2.2 => 1.1.2.3 ===
}
+
+static PyObject *
+listIndexes(PyObject *modinfo, PyObject *args)
+{
+ PyObject *wordlist, *word,*list;
+ int i;
+
+ list = PyList_New(0);
+
+ if (! (PyArg_ParseTuple(args,"OO",&wordlist,&word)))
+ return NULL;
+
+ for (i=0; i<PyList_Size(wordlist); i++) {
+ PyObject *item;
+
+ item = PyList_GetItem(wordlist,i);
+
+ if (! PyObject_Compare(item, word))
+ PyList_Append(list,PyInt_FromLong(i));
+ }
+
+ return list;
+}
+
static struct PyMethodDef indexsupport_module_methods[] =
{
{ "stopwordfilter", (PyCFunction) stopwordfilter, METH_VARARGS,
"stopwordfilter(wordslist,stopword dict') " "-- filters words from wordslist that are stopwords"
+ },
+ { "listIndexes", (PyCFunction) listIndexes, METH_VARARGS,
+ "listIndexes(list of words',word) " "-- find all positions of word in a list of words"
},
{ NULL, NULL }
};