Constants: Update IA description
parent
7a28bc577d
commit
a027440d98
|
@ -7,23 +7,23 @@ zci answer_type => "constants";
|
||||||
zci is_cached => 1;
|
zci is_cached => 1;
|
||||||
|
|
||||||
name "Constants";
|
name "Constants";
|
||||||
description "Succinct explanation of what this instant answer does";
|
description "Provides the value, unit, symbol and other information for Mathematical and Scientific constants";
|
||||||
primary_example_queries "first example query", "second example query";
|
primary_example_queries "first example query", "second example query";
|
||||||
secondary_example_queries "optional -- demonstrate any additional triggers";
|
secondary_example_queries "optional -- demonstrate any additional triggers";
|
||||||
category "formulas";
|
category "formulas";
|
||||||
topics "math";
|
topics "math";
|
||||||
code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Constants.pm";
|
code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Constants.pm";
|
||||||
attribution github => ["Roysten", "Roy van der Vegt"],
|
attribution github => ["Roysten", "Roy van der Vegt"],
|
||||||
github => ["hemanth", "Hemanth.HM"],
|
github => ["hemanth", "Hemanth.HM"],
|
||||||
twitter => "gnumanth";
|
twitter => "gnumanth";
|
||||||
|
|
||||||
my $constants = LoadFile(share("constants.yml"));
|
my $constants = LoadFile(share("constants.yml"));
|
||||||
|
|
||||||
#loop through constants
|
#loop through constants
|
||||||
foreach my $name (keys %$constants) {
|
foreach my $name (keys %$constants) {
|
||||||
#obtain to constant with name $keyword
|
#obtain to constant with name $keyword
|
||||||
my $constant = $constants->{$name};
|
my $constant = $constants->{$name};
|
||||||
|
|
||||||
#add aliases as separate triggers
|
#add aliases as separate triggers
|
||||||
foreach my $alias (@{$constant->{'aliases'}}) {
|
foreach my $alias (@{$constant->{'aliases'}}) {
|
||||||
$constants->{$alias} = $constant;
|
$constants->{$alias} = $constant;
|
||||||
|
@ -37,7 +37,7 @@ triggers startend => @triggers;
|
||||||
handle query_lc => sub {
|
handle query_lc => sub {
|
||||||
my $constant = $constants->{$_};
|
my $constant = $constants->{$_};
|
||||||
return unless my $val = $constant->{'value'};
|
return unless my $val = $constant->{'value'};
|
||||||
|
|
||||||
#fallback to plain answer if html is not present
|
#fallback to plain answer if html is not present
|
||||||
my $result = $val->{'html'} ? $val->{'html'} : $val->{'plain'};
|
my $result = $val->{'html'} ? $val->{'html'} : $val->{'plain'};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue