3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #*************************************************************************
12 # Tests for the fts5 "trigram" tokenizer.
15 source [file join [file dirname [info script]] fts5_common.tcl]
16 ifcapable !fts5 { finish_test ; return }
17 set ::testprefix fts5trigram2
20 CREATE VIRTUAL TABLE t1 USING fts5(y, tokenize='trigram remove_diacritics 1');
21 INSERT INTO t1 VALUES('abc\u0303defghijklm');
22 INSERT INTO t1 VALUES('a\u0303b\u0303c\u0303defghijklm');
26 SELECT highlight(t1, 0, '(', ')') FROM t1('abc');
28 "(abc\u0303)defghijklm" \
29 "(a\u0303b\u0303c\u0303)defghijklm" \
33 SELECT highlight(t1, 0, '(', ')') FROM t1('bcde');
35 "a(bc\u0303de)fghijklm" \
36 "a\u0303(b\u0303c\u0303de)fghijklm" \
40 SELECT highlight(t1, 0, '(', ')') FROM t1('cdef');
42 "ab(c\u0303def)ghijklm" \
43 "a\u0303b\u0303(c\u0303def)ghijklm" \
47 SELECT highlight(t1, 0, '(', ')') FROM t1('def');
49 "abc\u0303(def)ghijklm" \
50 "a\u0303b\u0303c\u0303(def)ghijklm" \
54 #-------------------------------------------------------------------------
55 do_catchsql_test 2.0 {
56 CREATE VIRTUAL TABLE t2 USING fts5(
57 z, tokenize='trigram case_sensitive 1 remove_diacritics 1'
59 } {1 {error in tokenizer constructor}}
62 CREATE VIRTUAL TABLE t2 USING fts5(
63 z, tokenize='trigram case_sensitive 0 remove_diacritics 1'
67 INSERT INTO t2 VALUES('\u00E3bcdef');
68 INSERT INTO t2 VALUES('b\u00E3cdef');
69 INSERT INTO t2 VALUES('bc\u00E3def');
70 INSERT INTO t2 VALUES('bcd\u00E3ef');
74 SELECT highlight(t2, 0, '(', ')') FROM t2('abc');
77 SELECT highlight(t2, 0, '(', ')') FROM t2('bac');
80 SELECT highlight(t2, 0, '(', ')') FROM t2('bca');
83 SELECT highlight(t2, 0, '(', ')') FROM t2('\u00E3bc');
86 #-------------------------------------------------------------------------
88 CREATE VIRTUAL TABLE t3 USING fts5(
89 z, tokenize='trigram remove_diacritics 1'
93 INSERT INTO t3 VALUES ('\u0303abc\u0303');
96 SELECT highlight(t3, 0, '(', ')') FROM t3('abc');
99 #-------------------------------------------------------------------------
100 do_execsql_test 4.0 {
101 CREATE VIRTUAL TABLE t4 USING fts5(z, tokenize=trigram);
105 do_execsql_test 4.1 {
106 INSERT INTO t4 VALUES('ABCD');