Add -e for exact searches (no fuzzy matches).

Only exact matches (or synonyms) are returned for simple searches.
This commit is contained in:
Peter
2017-07-28 11:27:19 +02:00
parent 586215fda7
commit e85927e562
11 changed files with 43 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
StarDict's dict ifo file
version=2.4.2
bookname=Test synonyms
wordcount=1
wordcount=2
synwordcount=2
idxfilesize=13
idxfilesize=32
sametypesequence=m

View File

@@ -15,4 +15,9 @@
<![CDATA[result of test]]>
</definition>
</article>
<article><key>testawordy</key>
<definition type="m">
<![CDATA[word that ends in y to test with fuzzy search in -ied]]>
</definition>
</article>
</stardict>

24
tests/t_exact Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/sh
set -e
SDCV="$1"
TEST_DIR="$2"
unset SDCV_PAGER
test_word() {
WORD=$1
EXPECTED=$2
TAG=$3
RES=$($SDCV -e -n --data-dir "$TEST_DIR" -u "Test synonyms" $WORD | grep "$TAG")
if [ "$EXPECTED" != "$RES" ]; then
echo "synonym for $WORD should be '$EXPECTED' but was '$RES'"
exit 1
fi
}
test_word testawordies "Nothing similar to testawordies, sorry :(" "Nothing similar"
test_word testawordy "word that ends in y to test with fuzzy search in -ied" "fuzzy"
exit 0