From 66573ebf247fc2e6c225aef3a0072357aaac2943 Mon Sep 17 00:00:00 2001 From: Abhinav Upadhyay Date: Sun, 11 Mar 2012 16:17:02 +0530 Subject: [PATCH] Add support for AND, OR, NOT boolean queries. --- apropos.c | 24 ++++++++++++++++++++++++ stopwords.txt | 3 --- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/apropos.c b/apropos.c index c61c7d1..ee711c8 100644 --- a/apropos.c +++ b/apropos.c @@ -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"); diff --git a/stopwords.txt b/stopwords.txt index f52231b..24afe64 100644 --- a/stopwords.txt +++ b/stopwords.txt @@ -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