CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
spellfix4.test354 linesDownload Raw Back to test
1# 2018-02-142#3# The author disclaims copyright to this source code.  In place of4# 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 15set testdir [file dirname $argv0]16source $testdir/tester.tcl17set testprefix spellfix418 19ifcapable !vtab { finish_test ; return }20 21load_static_extension db spellfix22 23do_execsql_test 100 {24  CREATE TABLE cost1(iLang, cFrom, cTo, iCost);25  INSERT INTO cost1 VALUES26    (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}35do_execsql_test 110 {36  SELECT editdist3('anchor','anchoxr');37} {97}38do_execsql_test 111 {39  SELECT editdist3('anchor','xanchor');40} {97}41do_execsql_test 112 {42  SELECT editdist3('anchor','anchorx');43} {97}44do_execsql_test 120 {45  SELECT editdist3('anchor','anchr');46} {98}47do_execsql_test 121 {48  SELECT editdist3('anchor','ancho');49} {98}50do_execsql_test 122 {51  SELECT editdist3('anchor','nchor');52} {98}53do_execsql_test 130 {54  SELECT editdist3('anchor','anchur');55} {99}56do_execsql_test 131 {57  SELECT editdist3('anchor','onchor');58} {99}59do_execsql_test 132 {60  SELECT editdist3('anchor','anchot');61} {99}62do_execsql_test 140 {63  SELECT editdist3('anchor','omchor');64} {149}65 66do_execsql_test 200 {67  INSERT INTO cost1 VALUES68    (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}75do_execsql_test 210 {76  SELECT editdist3('baume','bäume');77} {5}78do_execsql_test 220 {79  SELECT editdist3('baum','bäume');80} {102}81do_execsql_test 230 {82  INSERT INTO cost1 VALUES83    (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 91do_execsql_test 300 {92  DELETE FROM cost1;93  INSERT INTO cost1 VALUES94    (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', 81),101    (0, 'e', 'a', 50),102    (0, 'e', 'i', 52),103    (0, 'e', 'o', 72),104    (0, 'e', 'u', 82),105    (0, 'i', 'a', 70),106    (0, 'i', 'e', 52),107    (0, 'i', 'o', 75),108    (0, 'i', 'u', 83),109    (0, 'o', 'a', 75),110    (0, 'o', 'e', 72),111    (0, 'o', 'i', 75),112    (0, 'o', 'u', 40),113    (0, 'u', 'a', 81),114    (0, 'u', 'e', 82),115    (0, 'u', 'i', 83),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 VALUES122   ('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} {{}}337do_execsql_test 310 {338  SELECT editdist3(a.x,b.x), a.x, b.x339    FROM words a, words b340   WHERE a.x<b.x341   ORDER BY 1, 2342   LIMIT 20343} {139 bucket pocket 144 meter motor 149 manual mental 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}344do_execsql_test 320 {345  SELECT md5sum(ed||'/'||sx||'/'||sy||',') FROM (346      SELECT editdist3(a.x,b.x) AS ed, a.x AS sx, b.x AS sy347        FROM words a, words b348       WHERE a.x<b.x349       ORDER BY 1, 2350  )351} {69d0a31872203a775e19325ea98cd053}352 353finish_test354