Permalink
Browse files

Add support for AND, OR, NOT boolean queries.

  • Loading branch information...
1 parent be0abea commit 66573ebf247fc2e6c225aef3a0072357aaac2943 @abhinav-upadhyay committed Mar 11, 2012
Showing with 24 additions and 3 deletions.
  1. +24 −0 apropos.c
  2. +0 −3 stopwords.txt
View
@@ -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");
View
@@ -14,7 +14,6 @@ all
also
always
an
-and
another
any
are
@@ -128,7 +127,6 @@ next
no
non
noone
-not
nothing
o
of
@@ -139,7 +137,6 @@ older
on
once
only
-or
order
our
out

0 comments on commit 66573eb

Please sign in to comment.