Closed moollaza closed 7 years ago
@ManrajGrover were you still interested in working on this?
If not, would any of our awesome @duckduckgo/duckduckhack-contributors be interested?
This will require some Perl work to verify the query is valid for this Instant Answer
@moollaza I'll take this one up. Would love some pointers and links to similar Spice
to this. :smile:
@ManrajGrover the Color Codes IA is somewhat similar, but it uses a regular expression trigger.
Currently this IA is doing no relevancy checking against the query so I think we should start simple.
return;
and not show a result.Most IA's do some form of relevancy checking like this so there should be plenty of examples in the repo.
For the HTML colour names, we can use a list like this: http://www.w3schools.com/colors/colors_names.asp -- I would put them into a YAML file and load it into a hash, then check if the remainder exists in that hash. We may need to normalize the remainder a bit. If we handle remainder_lc =>
then eerything will be forced to lowercase which makes it a little easier.
Example of loading a YAML file can be seen in several IAs as well: https://github.com/duckduckgo/zeroclickinfo-spice/search?utf8=%E2%9C%93&q=LoadFile
Feel free to break this up into a few consecutive PR's if you'd like 👍
@moollaza @ManrajGrover It's probably worth checking out Color::Library
(Perl package) for checking names and getting Hex values.
use Color::Library;
my @colors = Color::Library->HTML->names;
...
handle remainder_lc => sub {
my $remainder = shift;
return unless any { $_ eq $remainder } @colors; # You'd want other checks for Hex
my $color = Color::Library->HTML->color($remainder);
my $hex = $color->hex();
...
}
@GuiltyDolphin I just checked and found that Color::Library
doesn't have many color names as link shared by @moollaza has. I feel we should go with that link.
@ManrajGrover Color::Library
has over 10,000 (named) colors - pretty comprehensive :wink:
Even Color::Library::WWW
alone has 148 - more than the 140 on that site.
@GuiltyDolphin I had tried your code. I guess HTML
has doesn't have that many. :worried: Should I revert the colors.yml
and add check for colors mentioned in Color::Library
including sub-modules?
@ManrajGrover Oh, sorry, my bad - that was just an example of how you might use it.
You'll probably want to use Color::Library::SVG
for starters (same as Color::Library::WWW
) which has 148 colors; it combines some of the common sets w/ some extra.
If there's some positive response for duckduckgo/zeroclickinfo-goodies#3371 then I'll put some work into a Role for various color-related functionality that is shared across color Goodies (including retrieving all colors). So we could perhaps expand the supported colors then?
@GuiltyDolphin Sounds like a plan! (Counter Strike reference, sorry :wink: ) I'll delete the YML file and add Color::Library::SVG
support for now. :smile: Also, if you could share some pointers on writing test files, that will help a lot! :smile:
@ManrajGrover Check out perldoc Test::Tutorial
for a basic overview of testing in Perl; then we use Test::Deep
for more advanced testing of structures. We have a few conventions and utility routines for writing ZCI tests - (using a build_test
routine, the test_zci
routine etc.) which should be present in a fair amount of existing test files.
@GuiltyDolphin Thank you once again! :smile: I'll check them out.
@ManrajGrover thanks a lot for converting this to a Goodie!
Now that it has been converted, we still need to fix the triggering, are you still interested in doing that part?
@moollaza I guess previous PR also fixed the triggering, if triggering means extracting remainder color from query and matching it with ones in Color::Library
. Please confirm. :smile:
This still seems to be an issue, e.g. https://duckduckgo.com/?q=colour+picker+tutorials shouldn't show the colour picker.
@tagawa @moollaza The metadata for this IA is wrong; I don't think chrisharrill is the maintainer (IIRC he's not committed into this at all) and the backend files are NoteFrequency?
Also it's now moved to goodies: https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/ColorPicker.pm
@tagawa I'll fix this; it's really quick to knock out
Thank you for the PR and move to Goodies @mintsoft. Chrisharrill is the maintainer because he created the original version, but we could change that if somebody else wants to take over.
@MariagraziaAlastra Would you be able to remove the two NoteFrequency files from the backend metadata please? https://duck.co/ia/view/color_picker
@tagawa I can take up the maintaining work.
That's very kind @ManrajGrover - thank you. I've made you the maintainer.
E.g. https://duckduckgo.com/?q=color+picker+download
We should verify any remainders match the name of a color, or the pattern of a color (e.g. #e0e0e0)
If the remainder is a colour, then we should definitely set the color picker to that colour. Right now we pick a random colour so you get funny results like this:
IA Page: http://duck.co/ia/view/color_picker Maintainer: @chrisharrill