From: dan Date: Fri, 19 Aug 2016 14:25:38 +0000 (+0000) Subject: Have the fts5 snippet() function avoid favouring snippets that begin with sentences... X-Git-Tag: version-3.15.0~123^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7ca1ea16ff99968db8994405c2d1c542e9a9d22f;p=thirdparty%2Fsqlite.git Have the fts5 snippet() function avoid favouring snippets that begin with sentences that do not contain search terms. Add an extra bias in favour of the first sentence in the document. FossilOrigin-Name: d8180af2adfc101dfce95a0498b5cd7b30643b30 --- diff --git a/ext/fts5/fts5_aux.c b/ext/fts5/fts5_aux.c index ca55fd6b01..8efe05968e 100644 --- a/ext/fts5/fts5_aux.c +++ b/ext/fts5/fts5_aux.c @@ -422,39 +422,46 @@ static void fts5SnippetFunction( rc = pApi->xColumnSize(pFts, i, &nDocsize); if( rc!=SQLITE_OK ) break; - for(ii=0; rc==SQLITE_OK && iinBestScore ){ - nBestScore = nScore; - iBestCol = i; - iBestStart = sFinder.aFirst[ii]; - nColSize = nDocsize; - } - } - for(ii=0; rc==SQLITE_OK && iixInst(pFts, ii, &ip, &ic, &io); if( ic!=i || rc!=SQLITE_OK ) continue; memset(aSeen, 0, nPhrase); rc = fts5SnippetScore(pApi, pFts, nDocsize, aSeen, i, - io, nToken, &nScore, &io + io, nToken, &nScore, &iAdj ); if( rc==SQLITE_OK && nScore>nBestScore ){ nBestScore = nScore; iBestCol = i; - iBestStart = io; + iBestStart = iAdj; nColSize = nDocsize; } + + if( rc==SQLITE_OK && sFinder.nFirst ){ + for(jj=0; jj<(sFinder.nFirst-1); jj++){ + if( sFinder.aFirst[jj+1]>io ) break; + } + + if( sFinder.aFirst[jj]nBestScore ){ + nBestScore = nScore; + iBestCol = i; + iBestStart = sFinder.aFirst[jj]; + nColSize = nDocsize; + } + } + } } } } diff --git a/manifest b/manifest index 9749b2bf53..f261342285 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjust\ssome\stests\sto\saccount\sfor\srecent\schanges\sto\sthe\sfts5\ssnippet\sfunction. -D 2016-08-18T14:47:48.448 +C Have\sthe\sfts5\ssnippet()\sfunction\savoid\sfavouring\ssnippets\sthat\sbegin\swith\ssentences\sthat\sdo\snot\scontain\ssearch\sterms.\sAdd\san\sextra\sbias\sin\sfavour\sof\sthe\sfirst\ssentence\sin\sthe\sdocument. +D 2016-08-19T14:25:38.928 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -99,7 +99,7 @@ F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95 F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0 F ext/fts5/fts5.h 62f3e33ceeb9a428db139f9c012186b371da1cc7 F ext/fts5/fts5Int.h b2eda36e0f224365c8e23dc8f559311834f1c13f -F ext/fts5/fts5_aux.c 5921bbef4c78b86159111335135837a867f1ff8a +F ext/fts5/fts5_aux.c 26a2b7e5f02cdc6b7322b85f473e488de452a5be F ext/fts5/fts5_buffer.c 4c1502d4c956cd092c89ce4480867f9d8bf325cd F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857 F ext/fts5/fts5_expr.c 1ee97156421919e497595bfa962bb88ad1665401 @@ -1510,7 +1510,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 60de159476edbd48dc363f7f77f09c32ea68422f -R 8546174dc7a44b2b80755efe3cb03b8a +P 184ecbe9c0c3280a22cdeda5c7836a7b280c3e1f +R 1ef5a5b8d26eab21fbb58bf0464e61ed U dan -Z b3f4b9f04ef4ae0622fcf2d28707aee5 +Z ed743fa5b6cead3848c470a1b5a47844 diff --git a/manifest.uuid b/manifest.uuid index eb9043217f..c3129c10b9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -184ecbe9c0c3280a22cdeda5c7836a7b280c3e1f \ No newline at end of file +d8180af2adfc101dfce95a0498b5cd7b30643b30 \ No newline at end of file