duckduckgo / zeroclickinfo-spice

DuckDuckGo Instant Answers based on JavaScript (JSON) APIs
https://duckduckhack.com/
Other
549 stars 942 forks source link

Nutrition: Add lists and update triggering #3209

Closed pjhampton closed 7 years ago

pjhampton commented 7 years ago

Problem

The Nutrition Instant Answer doesn't trigger for single-word food item searches, such as avocado, beef, or steak:

screen shot 2017-03-24 at 7 28 58 pm

We should trigger on these queries and show an Instant Answer.

Solution

  1. Find one or more lists of popular food items
  2. Update the code to load in each food item as a trigger (see Currency IA for an example)
  3. Add tests to t/Nutrition.t to confirm changes work as expect

People to notify

@pjhampton

Get Started

Resources


Instant Answer Page: https://duck.co/ia/view/nutrition

fraed commented 7 years ago

I would love to claim this issue. After setting up the development environment i am ready to get instant answers but this doesn't work with the Nutrition API. Are there any restriction issues in a local environment or am i missing some docs or something else? Or am i just working against "duckpan query"?

Eg: chicken Taco (works) image

Eg: banana calories (throws error) image

If you help me out i can give it a try. Thanks.

moollaza commented 7 years ago

@fraed thanks for volunteering! We really appreciate it 😄

Unfortunately I'm unable to reproduce the failure you're seeing. Can you show me the output of the DuckPAN console? Can you also show me the network tab (specifically the JS content)

Also, have you modified any code yet?

I was able to recreate this on Codio 👍 Please see my comment below.

pjhampton commented 7 years ago

Could it be because the api keys @moollaza, @fraed?

moollaza commented 7 years ago

@pjhampton @fraed I see the issues now. Because @fraed doesn't have an API key installed, we fallback to using the API endpoint on beta.duckduckgo.com. Currently, that API endpoint has been modified by another Pull Request, so the api_result doesn't pass the first check in the Nutrition.js file.

@fraed are you able to signup for a free Nutritionix API key?

Once you have your own API Key you can add it to your shell environment (or via duckpan with duckpan add DDG_SPICE_NUTRITIONIX_APIKEY {val})

Then the API call will go straight the API instead of using the beta endpoint 👍

fraed commented 7 years ago

Thank you. My development environment works now 👍.

fraed commented 7 years ago

Hey @pjhampton, @moollaza, I figured out that this file https://github.com/fraed/zeroclickinfo-spice/blob/3209-nutrition-triggering/share/spice/nutrition/nutrition.js can't handle single word ia as it needs measurement infos. I solved it quick using a default value in line 38. Let me know if you have further instructions here or the using "calories" as a default value works for you. Thanks.

moollaza commented 7 years ago

Let me know if you have further instructions here or the using "calories" as a default value works for you. Thanks.

@fraed I'm not too sure what you mean, but it sounds Ok. Please open a PR and we can discuss further there 👍