Skip to content

Commit

Permalink
Add support for AND, OR, NOT boolean queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav-upadhyay committed Mar 11, 2012
1 parent be0abea commit 66573eb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
24 changes: 24 additions & 0 deletions apropos.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,30 @@ main(int argc, char *argv[])
query = remove_stopwords(lower(str));
free(str);

char *temp;
str = query;
while ((temp = strstr(str, "and")) || (temp = strstr(str, "not"))
|| (temp = strstr(str, "or"))) {
switch (temp[0]) {
case 'a':
temp[0] = 'A';
temp[1] = 'N';
temp[2] = 'D';
break;

case 'n':
temp[0] = 'N';
temp[1] = 'O';
temp[2] = 'T';
break;
case 'o':
temp[0] = 'O';
temp[1] = 'R';
break;
}
str = temp + 1;
}
fprintf(stderr, "%s\n", query);
/* if any error occured in remove_stopwords, exit */
if (query == NULL)
errx(EXIT_FAILURE, "Try using more relevant keywords");
Expand Down
3 changes: 0 additions & 3 deletions stopwords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ all
also
always
an
and
another
any
are
Expand Down Expand Up @@ -128,7 +127,6 @@ next
no
non
noone
not
nothing
o
of
Expand All @@ -139,7 +137,6 @@ older
on
once
only
or
order
our
out
Expand Down

0 comments on commit 66573eb

Please sign in to comment.