/ Check-in [2d3f1f22]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:New test cases for the editdist3() function in the spellfix extension.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2d3f1f22d53034576a0ec8d9c360fb19efbb05b2e95ad1b09d120fb1b7da33fd
User & Date: drh 2018-02-14 15:30:48
Context
2018-02-14
20:25
Disable assert() in the spellfix extension if not compiled with SQLITE_DEBUG. check-in: 3c53ee0f user: drh tags: trunk
15:30
New test cases for the editdist3() function in the spellfix extension. check-in: 2d3f1f22 user: drh tags: trunk
14:13
Try to optimize spellfix1 by storing a NULL in the k1 column of %_vocab if it would otherwise have the same value as the word column. check-in: b76ec7cb user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added test/spellfix4.test.

            1  +# 2018-02-14
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            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.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +# Test cases for the editdist3() function in the spellfix extension.
           13  +#
           14  +
           15  +set testdir [file dirname $argv0]
           16  +source $testdir/tester.tcl
           17  +set testprefix spellfix4
           18  +
           19  +ifcapable !vtab { finish_test ; return }
           20  +
           21  +load_static_extension db spellfix
           22  +
           23  +do_execsql_test 100 {
           24  +  CREATE TABLE cost1(iLang, cFrom, cTo, iCost);
           25  +  INSERT INTO cost1 VALUES
           26  +    (0, '', '?',  97),
           27  +    (0, '?', '',  98),
           28  +    (0, '?', '?', 99),
           29  +    (0, 'm', 'n', 50),
           30  +    (0, 'n', 'm', 50)
           31  +  ;
           32  +  SELECT editdist3('cost1');
           33  +  SELECT editdist3('anchor','amchor');
           34  +} {{} 50}
           35  +do_execsql_test 110 {
           36  +  SELECT editdist3('anchor','anchoxr');
           37  +} {97}
           38  +do_execsql_test 111 {
           39  +  SELECT editdist3('anchor','xanchor');
           40  +} {97}
           41  +do_execsql_test 112 {
           42  +  SELECT editdist3('anchor','anchorx');
           43  +} {97}
           44  +do_execsql_test 120 {
           45  +  SELECT editdist3('anchor','anchr');
           46  +} {98}
           47  +do_execsql_test 121 {
           48  +  SELECT editdist3('anchor','ancho');
           49  +} {98}
           50  +do_execsql_test 122 {
           51  +  SELECT editdist3('anchor','nchor');
           52  +} {98}
           53  +do_execsql_test 130 {
           54  +  SELECT editdist3('anchor','anchur');
           55  +} {99}
           56  +do_execsql_test 131 {
           57  +  SELECT editdist3('anchor','onchor');
           58  +} {99}
           59  +do_execsql_test 132 {
           60  +  SELECT editdist3('anchor','anchot');
           61  +} {99}
           62  +do_execsql_test 140 {
           63  +  SELECT editdist3('anchor','omchor');
           64  +} {149}
           65  +
           66  +do_execsql_test 200 {
           67  +  INSERT INTO cost1 VALUES
           68  +    (0, 'a', 'ä', 5),
           69  +    (0, 'ss', 'ß', 8)
           70  +  ;
           71  +  SELECT editdist3('cost1');
           72  +  SELECT editdist3('strasse','straße');
           73  +  SELECT editdist3('straße','strasse');
           74  +} {{} 8 196}
           75  +do_execsql_test 210 {
           76  +  SELECT editdist3('baume','bäume');
           77  +} {5}
           78  +do_execsql_test 220 {
           79  +  SELECT editdist3('baum','bäume');
           80  +} {102}
           81  +do_execsql_test 230 {
           82  +  INSERT INTO cost1 VALUES
           83  +    (0, 'ä', 'a', 5),
           84  +    (0, 'ß', 'ss', 8)
           85  +  ;
           86  +  SELECT editdist3('cost1');
           87  +  SELECT editdist3('strasse','straße');
           88  +  SELECT editdist3('straße','strasse');
           89  +} {{} 8 8}
           90  +
           91  +do_execsql_test 300 {
           92  +  DELETE FROM cost1;
           93  +  INSERT INTO cost1 VALUES
           94  +    (0, '', '?',  97),
           95  +    (0, '?', '',  98),
           96  +    (0, '?', '?', 99),
           97  +    (0, 'a', 'e', 50),
           98  +    (0, 'a', 'i', 70),
           99  +    (0, 'a', 'o', 75),
          100  +    (0, 'a', 'u', 85),
          101  +    (0, 'e', 'a', 50),
          102  +    (0, 'e', 'i', 50),
          103  +    (0, 'e', 'o', 75),
          104  +    (0, 'e', 'u', 85),
          105  +    (0, 'i', 'a', 70),
          106  +    (0, 'i', 'e', 50),
          107  +    (0, 'i', 'o', 75),
          108  +    (0, 'i', 'u', 85),
          109  +    (0, 'o', 'a', 75),
          110  +    (0, 'o', 'e', 75),
          111  +    (0, 'o', 'i', 75),
          112  +    (0, 'o', 'u', 40),
          113  +    (0, 'u', 'a', 85),
          114  +    (0, 'u', 'e', 85),
          115  +    (0, 'u', 'i', 85),
          116  +    (0, 'u', 'o', 40),
          117  +    (0, 'm', 'n', 45),
          118  +    (0, 'n', 'm', 45)
          119  +  ;
          120  +  CREATE TABLE words(x TEXT);
          121  +  INSERT INTO words VALUES
          122  +   ('abraham'),
          123  +   ('action'),
          124  +   ('africa'),
          125  +   ('aladdin'),
          126  +   ('alert'),
          127  +   ('alien'),
          128  +   ('amazon'),
          129  +   ('analog'),
          130  +   ('animal'),
          131  +   ('apollo'),
          132  +   ('archive'),
          133  +   ('arnold'),
          134  +   ('aspirin'),
          135  +   ('august'),
          136  +   ('average'),
          137  +   ('bahama'),
          138  +   ('bambino'),
          139  +   ('barcode'),
          140  +   ('bazooka'),
          141  +   ('belgium'),
          142  +   ('between'),
          143  +   ('biology'),
          144  +   ('blonde'),
          145  +   ('border'),
          146  +   ('brave'),
          147  +   ('british'),
          148  +   ('bucket'),
          149  +   ('button'),
          150  +   ('caesar'),
          151  +   ('camilla'),
          152  +   ('cannon'),
          153  +   ('caramel'),
          154  +   ('carpet'),
          155  +   ('catalog'),
          156  +   ('century'),
          157  +   ('chaos'),
          158  +   ('chef'),
          159  +   ('china'),
          160  +   ('circus'),
          161  +   ('classic'),
          162  +   ('clinic'),
          163  +   ('coconut'),
          164  +   ('combine'),
          165  +   ('complex'),
          166  +   ('congo'),
          167  +   ('convert'),
          168  +   ('cosmos'),
          169  +   ('crack'),
          170  +   ('crown'),
          171  +   ('cyclone'),
          172  +   ('deal'),
          173  +   ('delete'),
          174  +   ('denver'),
          175  +   ('detail'),
          176  +   ('diana'),
          177  +   ('direct'),
          178  +   ('dolby'),
          179  +   ('double'),
          180  +   ('dublin'),
          181  +   ('echo'),
          182  +   ('edition'),
          183  +   ('electra'),
          184  +   ('emotion'),
          185  +   ('enjoy'),
          186  +   ('escape'),
          187  +   ('everest'),
          188  +   ('exile'),
          189  +   ('express'),
          190  +   ('family'),
          191  +   ('ferrari'),
          192  +   ('filter'),
          193  +   ('fish'),
          194  +   ('florida'),
          195  +   ('ford'),
          196  +   ('forum'),
          197  +   ('frank'),
          198  +   ('frozen'),
          199  +   ('gallery'),
          200  +   ('garlic'),
          201  +   ('geneva'),
          202  +   ('gibson'),
          203  +   ('gloria'),
          204  +   ('gordon'),
          205  +   ('gravity'),
          206  +   ('ground'),
          207  +   ('habitat'),
          208  +   ('harlem'),
          209  +   ('hazard'),
          210  +   ('herbert'),
          211  +   ('hobby'),
          212  +   ('house'),
          213  +   ('icon'),
          214  +   ('immune'),
          215  +   ('india'),
          216  +   ('inside'),
          217  +   ('isotope'),
          218  +   ('jamaica'),
          219  +   ('jazz'),
          220  +   ('joker'),
          221  +   ('juliet'),
          222  +   ('jupiter'),
          223  +   ('kevin'),
          224  +   ('korea'),
          225  +   ('latin'),
          226  +   ('legal'),
          227  +   ('lexicon'),
          228  +   ('limbo'),
          229  +   ('lithium'),
          230  +   ('logo'),
          231  +   ('lucas'),
          232  +   ('madrid'),
          233  +   ('major'),
          234  +   ('manual'),
          235  +   ('mars'),
          236  +   ('maximum'),
          237  +   ('medical'),
          238  +   ('mental'),
          239  +   ('meter'),
          240  +   ('miguel'),
          241  +   ('mimosa'),
          242  +   ('miranda'),
          243  +   ('modern'),
          244  +   ('money'),
          245  +   ('morgan'),
          246  +   ('motor'),
          247  +   ('mystic'),
          248  +   ('nebula'),
          249  +   ('network'),
          250  +   ('nice'),
          251  +   ('nitro'),
          252  +   ('norway'),
          253  +   ('nurse'),
          254  +   ('octavia'),
          255  +   ('olympic'),
          256  +   ('opus'),
          257  +   ('orient'),
          258  +   ('othello'),
          259  +   ('pacific'),
          260  +   ('panama'),
          261  +   ('paper'),
          262  +   ('parking'),
          263  +   ('pasta'),
          264  +   ('paul'),
          265  +   ('people'),
          266  +   ('permit'),
          267  +   ('phrase'),
          268  +   ('pilgrim'),
          269  +   ('planet'),
          270  +   ('pocket'),
          271  +   ('police'),
          272  +   ('popular'),
          273  +   ('prefer'),
          274  +   ('presto'),
          275  +   ('private'),
          276  +   ('project'),
          277  +   ('proxy'),
          278  +   ('python'),
          279  +   ('quota'),
          280  +   ('rainbow'),
          281  +   ('raymond'),
          282  +   ('region'),
          283  +   ('report'),
          284  +   ('reward'),
          285  +   ('risk'),
          286  +   ('robot'),
          287  +   ('rose'),
          288  +   ('russian'),
          289  +   ('sailor'),
          290  +   ('salt'),
          291  +   ('saturn'),
          292  +   ('scorpio'),
          293  +   ('second'),
          294  +   ('seminar'),
          295  +   ('shadow'),
          296  +   ('shave'),
          297  +   ('shock'),
          298  +   ('silence'),
          299  +   ('sinatra'),
          300  +   ('sleep'),
          301  +   ('social'),
          302  +   ('sonata'),
          303  +   ('spain'),
          304  +   ('sphere'),
          305  +   ('spray'),
          306  +   ('state'),
          307  +   ('stone'),
          308  +   ('strong'),
          309  +   ('sugar'),
          310  +   ('supreme'),
          311  +   ('swing'),
          312  +   ('talent'),
          313  +   ('telecom'),
          314  +   ('thermos'),
          315  +   ('tina'),
          316  +   ('tommy'),
          317  +   ('torso'),
          318  +   ('trade'),
          319  +   ('trick'),
          320  +   ('tropic'),
          321  +   ('turtle'),
          322  +   ('uniform'),
          323  +   ('user'),
          324  +   ('vega'),
          325  +   ('vertigo'),
          326  +   ('village'),
          327  +   ('visible'),
          328  +   ('vocal'),
          329  +   ('voyage'),
          330  +   ('weekend'),
          331  +   ('winter'),
          332  +   ('year'),
          333  +   ('zipper')
          334  +  ;
          335  +  SELECT editdist3('cost1');
          336  +} {{}}
          337  +do_execsql_test 310 {
          338  +  SELECT editdist3(a.x,b.x), a.x, b.x
          339  +    FROM words a, words b
          340  +   WHERE a.x<b.x
          341  +   ORDER BY 1, 2
          342  +   LIMIT 20
          343  +} {139 bucket pocket 149 manual mental 150 meter motor 169 crack trick 173 sinatra sonata 174 edition emotion 174 major motor 174 risk rose 174 state stone 194 deal detail 196 alert talent 196 analog catalog 196 deal legal 196 ford forum 196 risk trick 196 stone strong 197 china tina 197 congo logo 197 diana tina 197 florida gloria}
          344  +
          345  +
          346  +finish_test