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: Ryuji Abe <raeva@xxxxxxxxxxxx>
Subject: [namazu-devel-ja] Re: (Too many documents hit. Ignored) with and condition
Date: Wed, 21 Feb 2001 12:32:20 +0900
raeva> nmz_andmergeとnmz_notmergeのインターフェースの変更を
raeva> Namazu 2.0.xに加えることには反対です。3番目の引数を
raeva> 単に無視すればいいと思いますが、いかがでしょうか。
3 番目の引数 int *ignore が NULL の時に、新仕様の動作をさせる
ようにしてみました。
--
Rei FURUKAWA
furukawa@xxxxxxxxxxxx
diff -U3 ./hlist.c.orig ./hlist.c
--- ./hlist.c.orig Thu Sep 7 22:28:42 2000
+++ ./hlist.c Fri Feb 23 00:41:52 2001
@@ -238,23 +238,23 @@
{
int i, j, v;
- if (*ignore && left.num > 0) {
+ if (ignore && *ignore && left.num > 0) {
nmz_free_hlist(right);
return left;
}
- if (*ignore && right.num > 0) {
+ if (ignore && *ignore && right.num > 0) {
nmz_free_hlist(left);
return right;
}
if (left.stat != SUCCESS || left.num <= 0) {
- nmz_free_hlist(right);
- return left;
- }
- if (right.stat != SUCCESS || right.num <= 0) {
nmz_free_hlist(left);
return right;
}
+ if (right.stat != SUCCESS || right.num <= 0) {
+ nmz_free_hlist(right);
+ return left;
+ }
for (v = 0, i = 0, j = 0; i < left.num; i++) {
for (;; j++) {
@@ -297,11 +297,11 @@
{
int i, j, v, f;
- if (*ignore && left.num > 0) {
+ if (ignore && *ignore && left.num > 0) {
nmz_free_hlist(right);
return left;
}
- if (*ignore && right.num > 0) {
+ if (ignore && *ignore && right.num > 0) {
nmz_free_hlist(left);
return right;
}
diff -U3 ./parser.c.orig ./parser.c
--- ./parser.c.orig Fri Jan 28 18:40:12 2000
+++ ./parser.c Fri Feb 23 00:59:08 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 */
}
@@ -132,25 +131,40 @@
return 0;
}
+static int
+failedstat(int stat)
+{
+ switch (stat) {
+ case SUCCESS:
+ case ERR_TOO_MUCH_MATCH:
+ case ERR_TOO_MUCH_HIT:
+ return 0;
+ default:
+ return 1;
+ }
+}
+
static NmzResult
term(void)
{
NmzResult left, right;
- int ignore = 0, op;
+ int op;
+
+ left = factor();
+ if (failedstat(left.stat)) {
+ return left;
+ }
- left = factor(&ignore);
- if (left.stat != SUCCESS)
- return left;
while ((op = andop())) {
- right = factor(&ignore);
- if (right.stat != SUCCESS)
+ right = factor();
+ if (failedstat(right.stat)){
return right;
+ }
if (op == AND_OP) {
- left = nmz_andmerge(left, right, &ignore);
+ left = nmz_andmerge(left, right, 0);
} else if (op == NOT_OP) {
- left = nmz_notmerge(left, right, &ignore);
+ left = nmz_notmerge(left, right, 0);
}
- ignore = 0;
}
return left;
}
@@ -185,15 +199,18 @@
NmzResult left, right;
left = term();
- if (left.stat != SUCCESS)
- return left;
+ if (failedstat(left.stat)){
+ return left;
+ }
while (orop()) {
right = term();
- if (right.stat != SUCCESS)
+ if (failedstat(right.stat)){
return right;
+ }
left = nmz_ormerge(left, right);
- if (left.stat != SUCCESS)
+ if (failedstat(left.stat)){
return left;
+ }
}
return left;
}
diff -U3 ./search.c.orig ./search.c
--- ./search.c.orig Tue Feb 13 22:23:49 2001
+++ ./search.c Fri Feb 23 00:46:13 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, 0);
strcpy(word_mix, prevword);
strcat(word_mix, word);