Namazu-devel-ja(旧)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (Too many documents hit. Ignored) with and condition
古川です。
From: 小関 吉則 (KOSEKI Yoshinori) <kose@xxxxxxxxxxxxxxxxxx>
Subject: [namazu-devel-ja] Re: (Too many documents hit. Ignored) with and condition
Date: 15 Feb 2001 11:50:35 +0900
kose> しかし、Namazu は、
kose> 「B の検索」 -> 「A の検索」 -> and 処理
kose> なので too many になって検索できないなんですね。
そうですね。そして、この構造を大幅に変えることは難しそうなん
ですが…
それ以外に、あまりよくない点として、
'A and B' で too many になった時に、どちらの語が too many
になったのかが分からないので、ユーザが対処しにくい
ことがあると思いましたので、一つの語が too many になった場合で
も、個別のヒット数を表示し、その語を外して演算処理するようにし
てみました。
支持が得られれば、commit したいと思いますが…
--
Rei FURUKAWA
furukawa@xxxxxxxxxxxx
diff -U3 ./nmz/hlist.c.orig ./nmz/hlist.c
--- ./nmz/hlist.c.orig Thu Sep 7 22:28:42 2000
+++ ./nmz/hlist.c Tue Feb 13 22:40:15 2001
@@ -234,27 +234,18 @@
* Merge the left and right with AND rule.
*/
NmzResult
-nmz_andmerge(NmzResult left, NmzResult right, int *ignore)
+nmz_andmerge(NmzResult left, NmzResult right)
{
int i, j, v;
- if (*ignore && left.num > 0) {
- nmz_free_hlist(right);
- return left;
- }
- if (*ignore && right.num > 0) {
+ if (left.stat != SUCCESS || left.num <= 0) {
nmz_free_hlist(left);
return right;
}
-
- if (left.stat != SUCCESS || left.num <= 0) {
+ if (right.stat != SUCCESS || right.num <= 0) {
nmz_free_hlist(right);
return left;
}
- if (right.stat != SUCCESS || right.num <= 0) {
- nmz_free_hlist(left);
- return right;
- }
for (v = 0, i = 0, j = 0; i < left.num; i++) {
for (;; j++) {
@@ -293,18 +284,9 @@
* Merge the left and right with NOT rule.
*/
NmzResult
-nmz_notmerge(NmzResult left, NmzResult right, int *ignore)
+nmz_notmerge(NmzResult left, NmzResult right)
{
int i, j, v, f;
-
- if (*ignore && left.num > 0) {
- nmz_free_hlist(right);
- return left;
- }
- if (*ignore && right.num > 0) {
- nmz_free_hlist(left);
- return right;
- }
if (right.stat != SUCCESS || right.num <= 0) {
nmz_free_hlist(right);
diff -U3 ./nmz/hlist.h.orig ./nmz/hlist.h
--- ./nmz/hlist.h.orig Sun Jan 9 20:28:54 2000
+++ ./nmz/hlist.h Tue Feb 13 22:40:15 2001
@@ -3,8 +3,8 @@
#include "libnamazu.h" /* for NmzResult and enum nmz_* */
-extern NmzResult nmz_andmerge ( NmzResult left, NmzResult right, int *ignore );
-extern NmzResult nmz_notmerge ( NmzResult left, NmzResult right, int *ignore );
+extern NmzResult nmz_andmerge ( NmzResult left, NmzResult right);
+extern NmzResult nmz_notmerge ( NmzResult left, NmzResult right);
extern NmzResult nmz_ormerge ( NmzResult left, NmzResult right );
extern void nmz_malloc_hlist ( NmzResult * hlist, int n );
extern void nmz_realloc_hlist ( NmzResult * hlist, int n );
diff -U3 ./nmz/parser.c.orig ./nmz/parser.c
--- ./nmz/parser.c.orig Fri Jan 28 18:40:12 2000
+++ ./nmz/parser.c Tue Feb 13 22:40:15 2001
@@ -51,13 +51,13 @@
*
*/
-static NmzResult factor(int*);
+static NmzResult factor();
static int andop(void);
static NmzResult term(void);
static int orop(void);
static NmzResult
-factor(int *ignore)
+factor(void)
{
NmzResult val;
val.num = 0;
@@ -89,9 +89,8 @@
if (val.stat == ERR_FATAL)
return val;
if (val.stat == ERR_TOO_MUCH_MATCH ||
- val.stat == ERR_TOO_MUCH_MATCH)
+ val.stat == ERR_TOO_MUCH_HIT)
{
- *ignore = 1;
val.num = 0; /* assign 0 - this is important */
}
@@ -136,21 +135,33 @@
term(void)
{
NmzResult left, right;
- int ignore = 0, op;
+ int op;
- left = factor(&ignore);
- if (left.stat != SUCCESS)
+ left = factor();
+ switch (left.stat){
+ case SUCCESS:
+ case ERR_TOO_MUCH_MATCH:
+ case ERR_TOO_MUCH_HIT:
+ break;
+ default:
return left;
+ }
+
while ((op = andop())) {
- right = factor(&ignore);
- if (right.stat != SUCCESS)
- return right;
+ right = factor();
+ switch (right.stat){
+ case SUCCESS:
+ case ERR_TOO_MUCH_MATCH:
+ case ERR_TOO_MUCH_HIT:
+ break;
+ default:
+ return right;
+ }
if (op == AND_OP) {
- left = nmz_andmerge(left, right, &ignore);
+ left = nmz_andmerge(left, right);
} else if (op == NOT_OP) {
- left = nmz_notmerge(left, right, &ignore);
+ left = nmz_notmerge(left, right);
}
- ignore = 0;
}
return left;
}
@@ -185,15 +196,33 @@
NmzResult left, right;
left = term();
- if (left.stat != SUCCESS)
+ switch (left.stat){
+ case SUCCESS:
+ case ERR_TOO_MUCH_MATCH:
+ case ERR_TOO_MUCH_HIT:
+ break;
+ default:
return left;
+ }
while (orop()) {
right = term();
- if (right.stat != SUCCESS)
- return right;
+ switch (right.stat){
+ case SUCCESS:
+ case ERR_TOO_MUCH_MATCH:
+ case ERR_TOO_MUCH_HIT:
+ break;
+ default:
+ return right;
+ }
left = nmz_ormerge(left, right);
- if (left.stat != SUCCESS)
- return left;
+ switch (left.stat){
+ case SUCCESS:
+ case ERR_TOO_MUCH_MATCH:
+ case ERR_TOO_MUCH_HIT:
+ break;
+ default:
+ return left;
+ }
}
return left;
}
diff -U3 ./nmz/search.c.orig ./nmz/search.c
--- ./nmz/search.c.orig Tue Feb 13 22:23:49 2001
+++ ./nmz/search.c Tue Feb 13 22:46:11 2001
@@ -385,7 +385,7 @@
static NmzResult
do_phrase_search(const char *key, NmzResult val)
{
- int i, h = 0, ignore = 0;
+ int i, h = 0;
char *p, tmpkey[BUFSIZE], *words[QUERY_TOKEN_MAX + 1], *prevword = NULL;
FILE *phrase, *phrase_index;
struct nmz_hitnumlist *pr_hitnum = NULL; /* phrase hitnum */
@@ -442,13 +442,7 @@
} else if (val.num == 0) { /* phrase search is failed halfway */
continue;
} else {
- if (tmp.stat == ERR_TOO_MUCH_HIT ||
- val.stat == ERR_TOO_MUCH_HIT) {
- ignore = 1;
- } else {
- ignore = 0;
- }
- val = nmz_andmerge(val, tmp, &ignore);
+ val = nmz_andmerge(val, tmp);
strcpy(word_mix, prevword);
strcat(word_mix, word);