chiark / gitweb /
build default stopword list into server
authorrjk@greenend.org.uk <>
Sat, 29 Dec 2007 16:48:25 +0000 (16:48 +0000)
committerrjk@greenend.org.uk <>
Sat, 29 Dec 2007 16:48:25 +0000 (16:48 +0000)
CHANGES
debian/etc.disorder.config
doc/disorder_config.5.in
examples/config.sample.in
lib/configuration.c
tests/search.py

diff --git a/CHANGES b/CHANGES
index d558d9d38fc345883d54c1f07b84d1a6e2a5bdb5..6b1fc202315bd9fa282729e9bd185dd49b47b339 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,9 @@ See ChangeLog.d/* for detailed revision history.
 
 Users are now stored in the database rather than a configuration file.
 
 
 Users are now stored in the database rather than a configuration file.
 
+The server now has a built-in list of stopwords, so only additions need
+be mentioned in the configuration file.
+
 ** Web Interface
 
 The web interface now uses cookies to remember user identity, and allows
 ** Web Interface
 
 The web interface now uses cookies to remember user identity, and allows
index f5fd10c9037673ac0836e0fc111854bc8829907e..55e42d123d66b6cc82923b5eaade0cb8f05e06d1 100644 (file)
@@ -44,12 +44,5 @@ mixer /dev/mixer
 # The channel to control
 channel pcm
 
 # The channel to control
 channel pcm
 
-# Stopwords (i.e. ignored words) for the track search facility.
-stopword 01 02 03 04 05 06 07 08 09 10
-stopword 1 2 3 4 5 6 7 8 9
-stopword 11 12 13 14 15 16 17 18 19 20
-stopword 21 22 23 24 25 26 27 28 29 30
-stopword the a an and to too in on of we i am as im for is
-
 # include debconf configuration
 include /etc/disorder/conf.debconf
 # include debconf configuration
 include /etc/disorder/conf.debconf
index 3cb36aff622d675023ca6e3eb8eb228af8045988..8bc196353b0ac1a9374763bde598c9bc07ee2084 100644 (file)
@@ -571,6 +571,9 @@ over track names.
 .IP
 If \fBstopword\fR is used without arguments then the list of stopwords is
 cleared.
 .IP
 If \fBstopword\fR is used without arguments then the list of stopwords is
 cleared.
+.IP
+There is a default set of stopwords built in, but this option can be used to
+augment or replace that list.
 .TP
 .B tracklength \fIPATTERN\fR \fIMODULE\fR
 Specifies the module used to calculate the length of files matching
 .TP
 .B tracklength \fIPATTERN\fR \fIMODULE\fR
 Specifies the module used to calculate the length of files matching
index 1bf4088c59db2a7f4155b05e9da13288e93e75b9..6f214be4c323c688df8fa190e00294953d3d4034 100644 (file)
@@ -44,13 +44,3 @@ user jukebox
 mixer /dev/mixer
 # The channel to control
 channel pcm
 mixer /dev/mixer
 # The channel to control
 channel pcm
-
-# URL of the web interface
-url http://jukebox.anjou.terraraq.org.uk/
-
-# Stopwords (i.e. ignored words) for the track search facility.
-stopword 01 02 03 04 05 06 07 08 09 10
-stopword 1 2 3 4 5 6 7 8 9
-stopword 11 12 13 14 15 16 17 18 19 20
-stopword 21 22 23 24 25 26 27 28 29 30
-stopword the a an and to too in on of we i am as im for is
index 7ed92761d76fe0fe86137b3922f55bedee43bf76..bb30c2f33f0aaf2c20d87aa61b314bf9c36a6a8a 100644 (file)
@@ -1044,12 +1044,77 @@ static int config_include(struct config *c, const char *path) {
   return ret;
 }
 
   return ret;
 }
 
+static const char *const default_stopwords[] = {
+  "stopword",
+
+  "01",
+  "02",
+  "03",
+  "04",
+  "05",
+  "06",
+  "07",
+  "08",
+  "09",
+  "1",
+  "10",
+  "11",
+  "12",
+  "13",
+  "14",
+  "15",
+  "16",
+  "17",
+  "18",
+  "19",
+  "2",
+  "20",
+  "21",
+  "22",
+  "23",
+  "24",
+  "25",
+  "26",
+  "27",
+  "28",
+  "29",
+  "3",
+  "30",
+  "4",
+  "5",
+  "6",
+  "7",
+  "8",
+  "9",
+  "a",
+  "am",
+  "an",
+  "and",
+  "as",
+  "for",
+  "i",
+  "im",
+  "in",
+  "is",
+  "of",
+  "on",
+  "the",
+  "to",
+  "too",
+  "we",
+};
+#define NDEFAULT_STOPWORDS (sizeof default_stopwords / sizeof *default_stopwords)
+
 /** @brief Make a new default configuration */
 static struct config *config_default(void) {
   struct config *c = xmalloc(sizeof *c);
   const char *logname;
   struct passwd *pw;
 /** @brief Make a new default configuration */
 static struct config *config_default(void) {
   struct config *c = xmalloc(sizeof *c);
   const char *logname;
   struct passwd *pw;
+  struct config_state cs;
 
 
+  cs.path = "<internal>";
+  cs.line = 0;
+  cs.config = c;
   /* Strings had better be xstrdup'd as they will get freed at some point. */
   c->gap = 2;
   c->history = 60;
   /* Strings had better be xstrdup'd as they will get freed at some point. */
   c->gap = 2;
   c->history = 60;
@@ -1082,6 +1147,8 @@ static struct config *config_default(void) {
   c->dbversion = 2;
   c->cookie_login_lifetime = 86400;
   c->cookie_key_lifetime = 86400 * 7;
   c->dbversion = 2;
   c->cookie_login_lifetime = 86400;
   c->cookie_key_lifetime = 86400 * 7;
+  if(config_set(&cs, (int)NDEFAULT_STOPWORDS, (char **)default_stopwords))
+    exit(1);
   return c;
 }
 
   return c;
 }
 
index 3be6ec932a0074f73713beacdde9de18c80c093d..dab3939933c9301145905a818d9e777f78613718 100755 (executable)
@@ -89,6 +89,8 @@ def test():
     check_search_results([u"fi\u0300rst"], first)
     check_search_results([u"THI\u0301RD"], third)
     check_search_results([u"thI\u0301rd"], third)
     check_search_results([u"fi\u0300rst"], first)
     check_search_results([u"THI\u0301RD"], third)
     check_search_results([u"thI\u0301rd"], third)
+    # stopwords shouldn't show up
+    check_search_results(["01"], [])
     
     if failures > 0:
         sys.exit(1)
     
     if failures > 0:
         sys.exit(1)