open-language / en-dictionary

En-Dictonary is a node.js module which makes works and their relations available as a package.
MIT License
10 stars 3 forks source link

[rektdeckard] ensure search results include all parts-of-speech #5

Closed rektdeckard closed 4 years ago

rektdeckard commented 4 years ago

This patch fixes a bug in which loading a lemma from the database would clobber any existing entries to the database from a different part of speech but with same lemma. For example, the adjective sense of the word "smart" ("showing mental alterness...") was overwritten by the noun sense ("a kind of pain such as that caused by a wound...") when the data.noun file was loaded on init().

The Database now stores lemmas as a Map<string, Map<string, Index>>, where the outer key is the lemma itself, pointing to a map of POS -> Index. In this way, you can access the requisite POS by calling indexLemmaIndex.get("smart")?.get("adjective");.

This affects the return signatures of searchFor() and searchSimpleFor(), and should be considered a major semver update.

rektdeckard commented 4 years ago

Fixing this to exclude ES2020 syntax...