I'm writing yet another shopping list app, just for fun and personal purposes.
I'd like to automatically group items by their type without hardcoding all possible items and categories. I'm looking for a public API that could tell for example that "cucumber" is a "vegetable" and "food" or that "toothpaste" is a "Hygiene product" or "apple" is "fruit".
CodePudding user response:
You could have a look at WordNet, a lexical database which also contains lexical relations. So it will tell you that apple is a hyponym of fruit.
CodePudding user response:
I came across two REST APIs:
- BabelNet
- Google Knowledge base
I found BabelNet better suited to my needs. It is better structured and has a vast range of supported languages.
// search for the word (aka sense)
curl "https://babelnet.io/v6/getSynsetIds?lemma=jabłka&searchLang=PL&key=API-KEY&pos=NOUN" | jq
// search for descriptions/relations
curl "https://babelnet.io/v6/getOutgoingEdges?key=API-KEY&id=bn:00005054n&targetLang=PL" | jq | grep "is-a" -a5
// get relation details
curl "https://babelnet.io/v6/getSynset?id=bn:00029758n&targetLang=PL&key=API-KEY&" | jq