Go to file
Aleksa Sarai 6d385221d0 lookup: return all matching entries found during lookup
Previously, we would just return the first entry we found that matched
the requested word. This causes issues with dictionaries that have lots
of entries which can be found using the same search string. In these
cases, the user got a completely arbitrary word returned to them rather
than the full set.

While this may seem strange, this is incredibly commonplace in Japanese
and likely several other languages. In Japanese:

 * When written using kanji, the same string of characters could refer
   to more than one word which may have a completely different meaning.
   Examples include 潜る (くぐる、もぐる) and 辛い (からい、つらい).

 * When written in kana, the same string of characters can also refer to
   more than one word which is written using completely different kanji,
   and has a completely different meaning. Examples include きく
   (聞く、効く、菊) and たつ (立つ、建つ、絶つ).

In both cases, these are different words in every sense of the word, and
have separate headwords for each in the dictionary. Thus in order to be
completely useful for such dictionaries, sdcv needs to be able to return
every matching word in the dictionary.

The solution is conceptually simple -- return a set containing the
indices rather than just a single index. Since every list we search is
sorted (to allow binary searching), once we find one match we can just
walk backwards and forwards from the match point to find the entire
block of matching terms and add them to the set in linear time. A
std::set is used so that we don't return duplicate results needlessly.

This solution was in practice a bit more complicated because .otf cache
files require a bit more fiddling, and also the ->lookup methods are
used by some callers to find the next entry if no entry was found. But
on the whole it's not too drastic of a change from the previous setup.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-11-14 22:38:26 +03:00
2020-07-04 12:30:25 +02:00
2020-08-14 13:01:18 +03:00
2016-06-02 14:18:09 +03:00
2007-08-14 18:18:20 +00:00
2020-08-14 13:06:51 +03:00
2013-07-06 20:04:22 +00:00
2017-07-26 22:39:28 +02:00
2020-08-14 13:06:51 +03:00
2020-08-14 13:01:18 +03:00

https://github.com/Dushistov/sdcv/workflows/CI/badge.svg https://img.shields.io/badge/license-GPL%202-brightgreen.svg

How to compile and install

mkdir /tmp/build-sdcv
cd /tmp/build-sdcv
cmake path/to/source/code/of/sdcv
make

if you enable nls then you should also type

make lang

to install type

make install

you can use "DESTDIR" variable to change installation path

Documentation

See sdcv man page for usage description.

Bugs

To report bugs use https://github.com/Dushistov/sdcv/issues , if it is not possible you can report it via email to dushistov at mail dot ru. Be sure to include the word "sdcv" somewhere in the "Subject:" field.

Notes to developer

make source code release

make package_source

update translation

cd po
xgettext -k_ ../src/*.cpp -o new.pot
msgmerge -U sdcv.pot new.pot
rm new.pot
for i in `ls *.po`; do msgmerge -U $i sdcv.pot; done
Description
Languages
C++ 78.1%
CMake 16.8%
Shell 5.1%