Make pyzet use INDEX_SUMMARISE_CAPITALISE, add src/pyzet/test.py
authorNick Downing <downing.nick@gmail.com>
Thu, 4 Jan 2018 02:58:46 +0000 (13:58 +1100)
committerNick Downing <nick@ndcode.org>
Tue, 6 Nov 2018 00:08:37 +0000 (11:08 +1100)
src/pyzet/test.py [new file with mode: 0755]
src/pyzet/zetmodule.c

diff --git a/src/pyzet/test.py b/src/pyzet/test.py
new file mode 100755 (executable)
index 0000000..d370ad9
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+import sys
+import zet
+
+if len(sys.argv) < 2:
+  sys.stdout.write('usage: {0:s} query\n'.format(sys.argv[0]))
+  sys.exit(1)
+
+index = zet.Index()
+search_results = index.search(sys.argv[1], 0, 10)
+sys.stdout.write(
+  'total results {0:f}\n\n'.format(search_results.total_results)
+)
+for i in search_results.results:
+  sys.stdout.write(
+    'docno {0:d} score {1:f} auxiliary {2:s}\n{3:s}\n\n'.format(
+      i.docno,
+      i.score,
+      i.auxiliary,
+      i.summary
+    )
+  )
index 0933b52..122c364 100644 (file)
@@ -1074,6 +1074,10 @@ static PyObject * Index_search(PyObject * self, PyObject * args,
         opts |= INDEX_SEARCH_ACCUMULATOR_LIMIT;
         opt.accumulator_limit = accumulator_limit;
     }
+#if 1 /* Nick */
+ opts |= INDEX_SEARCH_SUMMARY_TYPE;
+ opt.summary_type = INDEX_SUMMARISE_CAPITALISE;
+#endif
     if (!index_search(Index->idx, query, startdoc, len,
           result, &results, &total_results, &est, opts, &opt)) {
         char err_buf[1024];
@@ -1422,6 +1426,10 @@ zet_search(PyObject *self, PyObject *args) {
         index_delete(idx);
         return NULL;
     }
+#if 1 /* Nick */
+ opts |= INDEX_SEARCH_SUMMARY_TYPE;
+ opt.summary_type = INDEX_SUMMARISE_CAPITALISE;
+#endif
     if (!index_search(idx, query, startdoc, len, result, 
           &results, &total_results, &est, opts, &opt)) {
         PyErr_SetString(PyExc_StandardError, "Unable to perform search");