summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorSergey Kartashoff <gluke@php.net>2001-02-22 10:40:44 +0000
committerSergey Kartashoff <gluke@php.net>2001-02-22 10:40:44 +0000
commit8bf6bdc2b9e4412b20c3361ff9521d3fe46f0e38 (patch)
treed9884caf36b513df3ebd4a38b30e8be0367ff7be /ext
parent77d14126b1d37c9412ef285210d65751611d7ec4 (diff)
downloadphp-git-8bf6bdc2b9e4412b20c3361ff9521d3fe46f0e38.tar.gz
Added Ispell routines to work with Ispell data loaded into sql tables.
Example updated.
Diffstat (limited to 'ext')
-rw-r--r--ext/mnogosearch/php_mnogo.c27
-rw-r--r--ext/mnogosearch/test.php5
2 files changed, 30 insertions, 2 deletions
diff --git a/ext/mnogosearch/php_mnogo.c b/ext/mnogosearch/php_mnogo.c
index 10c35dd719..317383951e 100644
--- a/ext/mnogosearch/php_mnogo.c
+++ b/ext/mnogosearch/php_mnogo.c
@@ -57,6 +57,7 @@
#define UDM_PARAM_PHRASE_MODE 11
#define UDM_PARAM_MIN_WORD_LEN 12
#define UDM_PARAM_MAX_WORD_LEN 13
+#define UDM_PARAM_ISPELL_MODE 14
/* udm_add_search_limit constants */
#define UDM_LIMIT_URL 1
@@ -169,9 +170,10 @@ DLEXPORT PHP_MINIT_FUNCTION(mnogosearch)
REGISTER_LONG_CONSTANT("UDM_PARAM_WORD_MATCH", UDM_PARAM_WORD_MATCH,CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UDM_PARAM_PHRASE_MODE", UDM_PARAM_PHRASE_MODE,CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UDM_PARAM_MAX_WORD_LEN",UDM_PARAM_MAX_WORD_LEN,CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("UDM_PARAM_MAX_WORDLEN",UDM_PARAM_MAX_WORD_LEN,CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("UDM_PARAM_MAX_WORDLEN", UDM_PARAM_MAX_WORD_LEN,CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UDM_PARAM_MIN_WORD_LEN",UDM_PARAM_MIN_WORD_LEN,CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("UDM_PARAM_MIN_WORDLEN",UDM_PARAM_MIN_WORD_LEN,CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("UDM_PARAM_MIN_WORDLEN", UDM_PARAM_MIN_WORD_LEN,CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("UDM_PARAM_ISPELL_MODE", UDM_PARAM_ISPELL_MODE,CONST_CS | CONST_PERSISTENT);
/* udm_add_search_limit constants */
REGISTER_LONG_CONSTANT("UDM_LIMIT_CAT", UDM_LIMIT_CAT,CONST_CS | CONST_PERSISTENT);
@@ -207,6 +209,10 @@ DLEXPORT PHP_MINIT_FUNCTION(mnogosearch)
REGISTER_LONG_CONSTANT("UDM_PHRASE_ENABLED", UDM_PHRASE_ENABLED,CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UDM_PHRASE_DISABLED", UDM_PHRASE_DISABLED,CONST_CS | CONST_PERSISTENT);
+ /* ispell mode params */
+ REGISTER_LONG_CONSTANT("UDM_ISPELL_MODE_DB", UDM_ISPELL_MODE_DB,CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("UDM_ISPELL_USE_PREFIXES",UDM_ISPELL_USE_PREFIXES,CONST_CS | CONST_PERSISTENT);
+
/* word match mode params */
REGISTER_LONG_CONSTANT("UDM_MATCH_WORD", UDM_MATCH_WORD,CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UDM_MATCH_BEGIN", UDM_MATCH_BEGIN,CONST_CS | CONST_PERSISTENT);
@@ -443,6 +449,23 @@ DLEXPORT PHP_FUNCTION(udm_set_agent_param)
}
break;
+
+ case UDM_PARAM_ISPELL_MODE:
+ Agent->Conf->ispell_mode = atoi(val) & (UDM_ISPELL_MODE_DB | UDM_ISPELL_USE_PREFIXES);
+
+ if (Agent->Conf->ispell_mode & UDM_ISPELL_MODE_DB) {
+ if (UdmDBImportAffixes(Agent,Agent->charset) ||
+ UdmImportDictionaryFromDB(Agent)) {
+ RETURN_FALSE;
+ } else {
+ if(Agent->Conf->nspell) {
+ UdmSortDictionary(Agent->Conf);
+ UdmSortAffixes(Agent->Conf);
+ }
+ }
+ }
+
+ break;
case UDM_PARAM_CHARSET:
Agent->Conf->local_charset=UdmGetCharset(val);
diff --git a/ext/mnogosearch/test.php b/ext/mnogosearch/test.php
index da99a164c4..546b4b3df2 100644
--- a/ext/mnogosearch/test.php
+++ b/ext/mnogosearch/test.php
@@ -42,6 +42,11 @@
Udm_Set_Agent_Param($udm,UDM_PARAM_PHRASE_MODE,UDM_PHRASE_DISABLED);
Udm_Set_Agent_Param($udm,UDM_PARAM_MIN_WORD_LEN,2);
Udm_Set_Agent_Param($udm,UDM_PARAM_MAX_WORD_LEN,5);
+
+ if (!Udm_Set_Agent_Param($udm,UDM_PARAM_ISPELL_MODE,UDM_ISPELL_MODE_DB)) {
+ printf("Error #%d: '%s'\n",$errno,Udm_Error($udm));
+ exit;
+ }
// Stage 3: add search limits
// Udm_Add_Search_Limit($udm,UDM_LIMIT_URL,"http://www.mydomain.com/%");