summaryrefslogtreecommitdiff
path: root/ext/mnogosearch
diff options
context:
space:
mode:
authorSergey Kartashoff <gluke@php.net>2001-12-02 10:24:39 +0000
committerSergey Kartashoff <gluke@php.net>2001-12-02 10:24:39 +0000
commit77111db91234797e2409fcc71a0ed914b16e0ca3 (patch)
treeec4a5a78e3dbde4e9e73b54531cf8b0dd92399df /ext/mnogosearch
parent3c01151a080b35767f0bce1b1b6a619947b9ce79 (diff)
downloadphp-git-77111db91234797e2409fcc71a0ed914b16e0ca3.tar.gz
- Added synonym stuff support to mnogosearch module. Slightly changed
stored API. Example updated.
Diffstat (limited to 'ext/mnogosearch')
-rw-r--r--ext/mnogosearch/index.php10
-rw-r--r--ext/mnogosearch/php_mnogo.c12
2 files changed, 21 insertions, 1 deletions
diff --git a/ext/mnogosearch/index.php b/ext/mnogosearch/index.php
index 60ac656f12..f7b70b5300 100644
--- a/ext/mnogosearch/index.php
+++ b/ext/mnogosearch/index.php
@@ -43,6 +43,8 @@ $spell_file['en']='/opt/udm/ispell/en.dict';
// $spell_file['ru']='/opt/udm/ispell/ru.dict';
$stopwordtable_arr[]='stopword';
// $stopwordfile_arr[]='stopwords.txt';
+$synonym_arr[]='/opt/udm/synonym/english.syn';
+
$minwordlength=1;
$maxwordlength=32;
@@ -593,6 +595,14 @@ function make_nav($query_orig){
}
}
+ if (Udm_Api_Version() >= 30203) {
+ for ($i=0; $i < count($synonym_arr); $i++) {
+ if ($synonym_arr[$i] != '') {
+ Udm_Set_Agent_Param($udm_agent,UDM_PARAM_SYNONYM,$synonym_arr[$i]);
+ }
+ }
+ }
+
if ($m=='any') {
Udm_Set_Agent_Param($udm_agent,UDM_PARAM_SEARCH_MODE,UDM_MODE_ANY);
} elseif ($m=='all') {
diff --git a/ext/mnogosearch/php_mnogo.c b/ext/mnogosearch/php_mnogo.c
index 04c803bbe8..c1bfc53924 100644
--- a/ext/mnogosearch/php_mnogo.c
+++ b/ext/mnogosearch/php_mnogo.c
@@ -73,6 +73,7 @@
#define UDM_PARAM_BROWSER_CHARSET 18
#define UDM_PARAM_HLBEG 19
#define UDM_PARAM_HLEND 20
+#define UDM_PARAM_SYNONYM 21
/* udm_add_search_limit constants */
#define UDM_LIMIT_URL 1
@@ -259,7 +260,7 @@ DLEXPORT PHP_MINIT_FUNCTION(mnogosearch)
REGISTER_LONG_CONSTANT("UDM_PARAM_ISPELL_PREFIX",UDM_PARAM_ISPELL_PREFIXES,CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UDM_PARAM_PREFIXES", UDM_PARAM_ISPELL_PREFIXES,CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UDM_PARAM_PREFIX", UDM_PARAM_ISPELL_PREFIXES,CONST_CS | CONST_PERSISTENT);
-
+
REGISTER_LONG_CONSTANT("UDM_PARAM_CROSS_WORDS", UDM_PARAM_CROSS_WORDS,CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UDM_PARAM_CROSSWORDS", UDM_PARAM_CROSS_WORDS,CONST_CS | CONST_PERSISTENT);
@@ -269,6 +270,8 @@ DLEXPORT PHP_MINIT_FUNCTION(mnogosearch)
REGISTER_LONG_CONSTANT("UDM_PARAM_HLBEG", UDM_PARAM_HLBEG,CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UDM_PARAM_HLEND", UDM_PARAM_HLEND,CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("UDM_PARAM_SYNONYM", UDM_PARAM_SYNONYM,CONST_CS | CONST_PERSISTENT);
+
/* udm_add_search_limit constants */
REGISTER_LONG_CONSTANT("UDM_LIMIT_CAT", UDM_LIMIT_CAT,CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UDM_LIMIT_URL", UDM_LIMIT_URL,CONST_CS | CONST_PERSISTENT);
@@ -683,6 +686,13 @@ DLEXPORT PHP_FUNCTION(udm_set_agent_param)
UdmReplaceStrVar(Agent->Conf->vars,"HlBeg",val,UDM_VARSRC_GLOBAL);
break;
+
+ case UDM_PARAM_SYNONYM:
+ if (UdmSynonymListLoad(Agent->Conf,val)) {
+ php_error(E_WARNING,Agent->Conf->errstr);
+ RETURN_FALSE;
+ } else UdmSynonymListSort(&(Agent->Conf->SynList));
+ break;
#endif
case UDM_PARAM_STOPTABLE: