| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2006 September 30 | 2 ** 2006 September 30 |
| 3 ** | 3 ** |
| 4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
| 5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
| 6 ** | 6 ** |
| 7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
| 8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
| 9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
| 10 ** | 10 ** |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 */ | 119 */ |
| 120 static int porterClose(sqlite3_tokenizer_cursor *pCursor){ | 120 static int porterClose(sqlite3_tokenizer_cursor *pCursor){ |
| 121 porter_tokenizer_cursor *c = (porter_tokenizer_cursor *) pCursor; | 121 porter_tokenizer_cursor *c = (porter_tokenizer_cursor *) pCursor; |
| 122 sqlite3_free(c->zToken); | 122 sqlite3_free(c->zToken); |
| 123 sqlite3_free(c); | 123 sqlite3_free(c); |
| 124 return SQLITE_OK; | 124 return SQLITE_OK; |
| 125 } | 125 } |
| 126 /* | 126 /* |
| 127 ** Vowel or consonant | 127 ** Vowel or consonant |
| 128 */ | 128 */ |
| 129 static const char cType[] = { | 129 static const char vOrCType[] = { |
| 130 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, | 130 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, |
| 131 1, 1, 1, 2, 1 | 131 1, 1, 1, 2, 1 |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 /* | 134 /* |
| 135 ** isConsonant() and isVowel() determine if their first character in | 135 ** isConsonant() and isVowel() determine if their first character in |
| 136 ** the string they point to is a consonant or a vowel, according | 136 ** the string they point to is a consonant or a vowel, according |
| 137 ** to Porter ruls. | 137 ** to Porter ruls. |
| 138 ** | 138 ** |
| 139 ** A consonate is any letter other than 'a', 'e', 'i', 'o', or 'u'. | 139 ** A consonate is any letter other than 'a', 'e', 'i', 'o', or 'u'. |
| 140 ** 'Y' is a consonant unless it follows another consonant, | 140 ** 'Y' is a consonant unless it follows another consonant, |
| 141 ** in which case it is a vowel. | 141 ** in which case it is a vowel. |
| 142 ** | 142 ** |
| 143 ** In these routine, the letters are in reverse order. So the 'y' rule | 143 ** In these routine, the letters are in reverse order. So the 'y' rule |
| 144 ** is that 'y' is a consonant unless it is followed by another | 144 ** is that 'y' is a consonant unless it is followed by another |
| 145 ** consonent. | 145 ** consonent. |
| 146 */ | 146 */ |
| 147 static int isVowel(const char*); | 147 static int isVowel(const char*); |
| 148 static int isConsonant(const char *z){ | 148 static int isConsonant(const char *z){ |
| 149 int j; | 149 int j; |
| 150 char x = *z; | 150 char x = *z; |
| 151 if( x==0 ) return 0; | 151 if( x==0 ) return 0; |
| 152 assert( x>='a' && x<='z' ); | 152 assert( x>='a' && x<='z' ); |
| 153 j = cType[x-'a']; | 153 j = vOrCType[x-'a']; |
| 154 if( j<2 ) return j; | 154 if( j<2 ) return j; |
| 155 return z[1]==0 || isVowel(z + 1); | 155 return z[1]==0 || isVowel(z + 1); |
| 156 } | 156 } |
| 157 static int isVowel(const char *z){ | 157 static int isVowel(const char *z){ |
| 158 int j; | 158 int j; |
| 159 char x = *z; | 159 char x = *z; |
| 160 if( x==0 ) return 0; | 160 if( x==0 ) return 0; |
| 161 assert( x>='a' && x<='z' ); | 161 assert( x>='a' && x<='z' ); |
| 162 j = cType[x-'a']; | 162 j = vOrCType[x-'a']; |
| 163 if( j<2 ) return 1-j; | 163 if( j<2 ) return 1-j; |
| 164 return isConsonant(z + 1); | 164 return isConsonant(z + 1); |
| 165 } | 165 } |
| 166 | 166 |
| 167 /* | 167 /* |
| 168 ** Let any sequence of one or more vowels be represented by V and let | 168 ** Let any sequence of one or more vowels be represented by V and let |
| 169 ** C be sequence of one or more consonants. Then every word can be | 169 ** C be sequence of one or more consonants. Then every word can be |
| 170 ** represented as: | 170 ** represented as: |
| 171 ** | 171 ** |
| 172 ** [C] (VC){m} [V] | 172 ** [C] (VC){m} [V] |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 ** Allocate a new porter tokenizer. Return a pointer to the new | 632 ** Allocate a new porter tokenizer. Return a pointer to the new |
| 633 ** tokenizer in *ppModule | 633 ** tokenizer in *ppModule |
| 634 */ | 634 */ |
| 635 void sqlite3Fts3PorterTokenizerModule( | 635 void sqlite3Fts3PorterTokenizerModule( |
| 636 sqlite3_tokenizer_module const**ppModule | 636 sqlite3_tokenizer_module const**ppModule |
| 637 ){ | 637 ){ |
| 638 *ppModule = &porterTokenizerModule; | 638 *ppModule = &porterTokenizerModule; |
| 639 } | 639 } |
| 640 | 640 |
| 641 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ | 641 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| OLD | NEW |