Closed hold7door closed 2 years ago
Good job @hold7door! Your implementation is neat. I'd been thinking of adding a dictionary service, but with WordNet though.
I think that would be a better approach as it would just need a local WordNet installation to get the data from. Depending on an external HTTP API for what is essentially static data doesn't seem ideal. The service can get the data by:
wn
command and caching the results in-memory. Not great, but works.To play around with WordNet: online demo or a local installation (eg: apt install wordnet
):
$ wn apple -over
Overview of noun apple
The noun apple has 2 senses (first 1 from tagged texts)
1. (1) apple -- (fruit with red or yellow or green skin and sweet to tart crisp whitish flesh)
2. apple, orchard apple tree, Malus pumila -- (native Eurasian tree widely cultivated in many varieties for its firm rounded edible fruits)
Maybe you'd be interested in implementing this?
WordNet looks great. This way we won't have to be dependent on availability of the external service.
Will work on the implementation, using the wnram parser library.
Hi @knadh ,
Implemented it using WordNet and wnram as the parser. You can check the forked repo at - dictionary-v2.
Output is almost the same as before. Additionally, one example will also be shown.
dig play.dictionary @dns.toys
play. 1 IN TXT "verb:" "contend against an opponent in a sport, game, or battle" "Princeton plays Yale this weekend"
play. 1 IN TXT "verb:" "put (a card or piece) into play during a game, or act strategically as if in a card game" "He is playing his cards close to his chest"
play. 1 IN TXT "noun:" "gay or light-hearted recreational activity for diversion or amusement" "it was all done in play"
play. 1 IN TXT "noun:" "the act of playing for stakes in the hope of winning (including the payment of a price for a chance to win a prize)" "his gambling cost him a fortune"
This is excellent @hold7door! There are are couple cosmetic fixes I'd like to make, if you don't mind. Please go ahead and send a PR. Thanks again.
Yes, Of course ! Thanks !
Thanks for this. Recently started learning GO. Thought this might be a good exercise.
I worked on adding support for a dictionary service. So you can find definition of a word in different parts of speech like this -
Internally, it uses the API from https://dictionaryapi.dev/. Response from the API can be large with multiple meanings, and DNS packet size has limits, so the result from service is trimmed a bit to fetch one definition per part of speech.
A lot of reference for implementation was taken from the weather service.
It's on my forked repo at - https://github.com/hold7door/dns.toys/tree/dictionary.
If you are okay with it, I'll submit a PR.