Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

ColorCodes: Triggers on any query ending in "color <name>" #3294

Closed
4 tasks
moollaza opened this issue Jun 22, 2016 · 12 comments
Closed
4 tasks

ColorCodes: Triggers on any query ending in "color <name>" #3294

moollaza opened this issue Jun 22, 2016 · 12 comments

Comments

@moollaza
Copy link
Member

moollaza commented Jun 22, 2016

Description

This IA is triggering for any query that ends in color <name> causing some irrelevant results.

e.g. https://duckduckgo.com/?q=symbolism+of+the+color+red&ia=answer

We need to verify that the query doesn't contain other words when the trigger is color

People to notify

/cc @mintsoft

Get Started

Resources


IA Page: http://duck.co/ia/view/color_codes
Maintainer: @Mailkov

@Mailkov
Copy link
Contributor

Mailkov commented Jun 22, 2016

@moollaza Ok, I'm working to solve it

@moollaza
Copy link
Member Author

moollaza commented Jun 22, 2016

Here's a visualization of the regex:

debuggex__online_visual_regex_tester__javascript__python__and_pcre_

source: https://www.debuggex.com/r/nAmQuV7VMZBpqOKF

You can see that it's possible to have any string before "color red" because of the (.*?) in the regex...

@Mailkov
Copy link
Contributor

Mailkov commented Jun 22, 2016

@moollaza In this moment IA ColorCodes is supporting the queries "rgb color code for red" and "red color code for html" etc.
So I'm not sure I will change the regex ...

@gaulrobe
Copy link
Collaborator

Maybe we need to be tighter with the regex and enforce "color code" being in the query, code not being optional?

@moollaza
Copy link
Member Author

moollaza commented Jun 23, 2016

@Mailkov I think we should break apart that big regex so it's easier to understand and then replace the (.*?) with words we actually expect to see.

Or maybe as a heuristic if the string doesn't contain "color code", but contains a named colour and other words, we should bail out?

@gaulrobe I'm not sure we want to be so strict as to require "color code" just yet. The IA is just a little too flexible with it's triggering right now.

@gaulrobe
Copy link
Collaborator

@moollaza it might help to require it in cases where "color" is in the query, since that is gonna be very ambiguous. "color code" at least is explicit in what is being asked. But either way, maybe too early to go that far. 😄

@moollaza
Copy link
Member Author

@gaulrobe ah sorry I misunderstood you!

It looks like there are a few common search forms that just contain color though...
drake_at_duckduckgo

hex_color_dark_brown_at_duckduckgo

An alternative approach is to remove words and phrases we expect to be in the query and if the result is a valid colour name or code then we could trigger.

Ultimately I think we need to break up the logic we use to evaluate the query so it's easier to reason about, and then add more tests!

@moollaza
Copy link
Member Author

moollaza commented Jul 7, 2016

BTW I just noticed that "#E0E0E0 color" and "#E0E0E0 css color" don't trigger this Instant Answer -- they definitely should!

@mintsoft
Copy link
Collaborator

mintsoft commented Jul 8, 2016

@moollaza good catch

@Mailkov Have you got a fork in progress somewhere? I don't mind picking this up if you don't have time

@GuiltyDolphin
Copy link
Member

@mintsoft If you do, some of the test queries from #3346 might be useful to ensure it isn't over-triggering.

@moollaza
Copy link
Member Author

moollaza commented Oct 5, 2016

Ping! I'm just checking in to see if anyone is still interested in finishing this one up?

@abijithka
Copy link

color: "your color";
or
backgroundbg color: " your color";

darsnack pushed a commit to darsnack/zeroclickinfo-goodies that referenced this issue May 20, 2017
- Added logic to prevent triggering when excess words are involved in
  the sentence that are not expected

Fixes duckduckgo#3294
moollaza pushed a commit that referenced this issue Jul 12, 2017
* ColorCodes: Triggers on any query ending in "color <name>"

- Added logic to prevent triggering when excess words are involved in
  the sentence that are not expected

Fixes #3294

* - Fixed regex for filler words to be simpler
- Fixed filler count return statement by removing the double negative

* Simplified regex to catch filler words

* Fixed whitespace changes

* Added more tests for when the IA should not trigger. Existing tests already sufficiently cover when the IA should trigger.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants