OLD | NEW |
1 /* | 1 /* |
2 ** 2006 July 10 | 2 ** 2006 July 10 |
3 ** | 3 ** |
4 ** The author disclaims copyright to this source code. | 4 ** The author disclaims copyright to this source code. |
5 ** | 5 ** |
6 ************************************************************************* | 6 ************************************************************************* |
7 ** Defines the interface to tokenizers used by fulltext-search. There | 7 ** Defines the interface to tokenizers used by fulltext-search. There |
8 ** are three basic components: | 8 ** are three basic components: |
9 ** | 9 ** |
10 ** sqlite3_tokenizer_module is a singleton defining the tokenizer | 10 ** sqlite3_tokenizer_module is a singleton defining the tokenizer |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 ** the tokenization rules supplied by a specific sqlite3_tokenizer | 45 ** the tokenization rules supplied by a specific sqlite3_tokenizer |
46 ** object. | 46 ** object. |
47 */ | 47 */ |
48 typedef struct sqlite3_tokenizer_module sqlite3_tokenizer_module; | 48 typedef struct sqlite3_tokenizer_module sqlite3_tokenizer_module; |
49 typedef struct sqlite3_tokenizer sqlite3_tokenizer; | 49 typedef struct sqlite3_tokenizer sqlite3_tokenizer; |
50 typedef struct sqlite3_tokenizer_cursor sqlite3_tokenizer_cursor; | 50 typedef struct sqlite3_tokenizer_cursor sqlite3_tokenizer_cursor; |
51 | 51 |
52 struct sqlite3_tokenizer_module { | 52 struct sqlite3_tokenizer_module { |
53 | 53 |
54 /* | 54 /* |
55 ** Structure version. Should always be set to 0. | 55 ** Structure version. Should always be set to 0 or 1. |
56 */ | 56 */ |
57 int iVersion; | 57 int iVersion; |
58 | 58 |
59 /* | 59 /* |
60 ** Create a new tokenizer. The values in the argv[] array are the | 60 ** Create a new tokenizer. The values in the argv[] array are the |
61 ** arguments passed to the "tokenizer" clause of the CREATE VIRTUAL | 61 ** arguments passed to the "tokenizer" clause of the CREATE VIRTUAL |
62 ** TABLE statement that created the fts3 table. For example, if | 62 ** TABLE statement that created the fts3 table. For example, if |
63 ** the following SQL is executed: | 63 ** the following SQL is executed: |
64 ** | 64 ** |
65 ** CREATE .. USING fts3( ... , tokenizer <tokenizer-name> arg1 arg2) | 65 ** CREATE .. USING fts3( ... , tokenizer <tokenizer-name> arg1 arg2) |
66 ** | 66 ** |
67 ** then argc is set to 2, and the argv[] array contains pointers | 67 ** then argc is set to 2, and the argv[] array contains pointers |
68 ** to the strings "arg1" and "arg2". | 68 ** to the strings "arg1" and "arg2". |
69 ** | 69 ** |
70 ** This method should return either SQLITE_OK (0), or an SQLite error | 70 ** This method should return either SQLITE_OK (0), or an SQLite error |
71 ** code. If SQLITE_OK is returned, then *ppTokenizer should be set | 71 ** code. If SQLITE_OK is returned, then *ppTokenizer should be set |
72 ** to point at the newly created tokenizer structure. The generic | 72 ** to point at the newly created tokenizer structure. The generic |
73 ** sqlite3_tokenizer.pModule variable should not be initialised by | 73 ** sqlite3_tokenizer.pModule variable should not be initialized by |
74 ** this callback. The caller will do so. | 74 ** this callback. The caller will do so. |
75 */ | 75 */ |
76 int (*xCreate)( | 76 int (*xCreate)( |
77 int argc, /* Size of argv array */ | 77 int argc, /* Size of argv array */ |
78 const char *const*argv, /* Tokenizer argument strings */ | 78 const char *const*argv, /* Tokenizer argument strings */ |
79 sqlite3_tokenizer **ppTokenizer /* OUT: Created tokenizer */ | 79 sqlite3_tokenizer **ppTokenizer /* OUT: Created tokenizer */ |
80 ); | 80 ); |
81 | 81 |
82 /* | 82 /* |
83 ** Destroy an existing tokenizer. The fts3 module calls this method | 83 ** Destroy an existing tokenizer. The fts3 module calls this method |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 ** nul-terminated. This should either be fixed, or pInput/nBytes | 126 ** nul-terminated. This should either be fixed, or pInput/nBytes |
127 ** should be converted to zInput. | 127 ** should be converted to zInput. |
128 */ | 128 */ |
129 int (*xNext)( | 129 int (*xNext)( |
130 sqlite3_tokenizer_cursor *pCursor, /* Tokenizer cursor */ | 130 sqlite3_tokenizer_cursor *pCursor, /* Tokenizer cursor */ |
131 const char **ppToken, int *pnBytes, /* OUT: Normalized text for token */ | 131 const char **ppToken, int *pnBytes, /* OUT: Normalized text for token */ |
132 int *piStartOffset, /* OUT: Byte offset of token in input buffer */ | 132 int *piStartOffset, /* OUT: Byte offset of token in input buffer */ |
133 int *piEndOffset, /* OUT: Byte offset of end of token in input buffer */ | 133 int *piEndOffset, /* OUT: Byte offset of end of token in input buffer */ |
134 int *piPosition /* OUT: Number of tokens returned before this one */ | 134 int *piPosition /* OUT: Number of tokens returned before this one */ |
135 ); | 135 ); |
| 136 |
| 137 /*********************************************************************** |
| 138 ** Methods below this point are only available if iVersion>=1. |
| 139 */ |
| 140 |
| 141 /* |
| 142 ** Configure the language id of a tokenizer cursor. |
| 143 */ |
| 144 int (*xLanguageid)(sqlite3_tokenizer_cursor *pCsr, int iLangid); |
136 }; | 145 }; |
137 | 146 |
138 struct sqlite3_tokenizer { | 147 struct sqlite3_tokenizer { |
139 const sqlite3_tokenizer_module *pModule; /* The module for this tokenizer */ | 148 const sqlite3_tokenizer_module *pModule; /* The module for this tokenizer */ |
140 /* Tokenizer implementations will typically add additional fields */ | 149 /* Tokenizer implementations will typically add additional fields */ |
141 }; | 150 }; |
142 | 151 |
143 struct sqlite3_tokenizer_cursor { | 152 struct sqlite3_tokenizer_cursor { |
144 sqlite3_tokenizer *pTokenizer; /* Tokenizer for this cursor. */ | 153 sqlite3_tokenizer *pTokenizer; /* Tokenizer for this cursor. */ |
145 /* Tokenizer implementations will typically add additional fields */ | 154 /* Tokenizer implementations will typically add additional fields */ |
146 }; | 155 }; |
147 | 156 |
148 int fts3_global_term_cnt(int iTerm, int iCol); | 157 int fts3_global_term_cnt(int iTerm, int iCol); |
149 int fts3_term_cnt(int iTerm, int iCol); | 158 int fts3_term_cnt(int iTerm, int iCol); |
150 | 159 |
151 | 160 |
152 #endif /* _FTS3_TOKENIZER_H_ */ | 161 #endif /* _FTS3_TOKENIZER_H_ */ |
OLD | NEW |