<commit_before>package DDG::Goodie::CallingCodes;
# ABSTRACT: Matches country names to calling codes

use DDG::Goodie;
use Locale::Country qw/country2code code2country/;
use Telephony::CountryDialingCodes;

zci answer_type => "calling_codes";

name        "CallingCodes";
description "Matches country names to international calling codes";
source      "https://en.wikipedia.org/wiki/List_of_country_calling_codes#Alphabetical_listing_by_country_or_region";
code_url    "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Goodie/CallingCodes.pm";
category    "geography";
topics      "travel", "geography";

primary_example_queries   "country code 55", "country code brazil";
secondary_example_queries "dialing code +55", "country calling code 55";

attribution github  => ["kablamo",            "<NAME>"],
            web     => ["http://kablamo.org", "<NAME>"];

triggers startend => 
    "calling code",
    "calling codes",
    "country calling code", 
    "country code", 
    "country dialing code", 
    "dial in code",
    "dialing code", 
    "international calling code", 
    "international dial in code",
    "international dialing code"; 

Locale::Country::rename_country('ae' => 'the United Arab Emirates');
Locale::Country::rename_country('do' => 'the Dominican Republic');
Locale::Country::rename_country('gb' => 'the United Kingdom');
Locale::Country::rename_country('kp' => "the Republic of Korea");
Locale::Country::rename_country('kr' => "the Democratic People's Republic of Korea");
Locale::Country::rename_country('ky' => 'the Cayman Islands');
Locale::Country::rename_country('mp' => 'the Northern Mariana Islands');
Locale::Country::rename_country('nl' => 'the Netherlands');
Locale::Country::rename_country('ph' => 'the Philippines');
Locale::Country::rename_country('ru' => 'the Russian Federation');
Locale::Country::rename_country('tw' => 'Taiwan');
Locale::Country::rename_country('us' => 'the United States');
Locale::Country::rename_country('vg' => 'the British Virgin Islands');
Locale::Country::rename_country('vi' => 'the US Virgin Islands');

# These are the only 2 countries which officially have 'The' in their name
# Source: http://www.bbc.co.uk/news/magazine-18233844
Locale::Country::rename_country('gm' => 'The Gambia');
Locale::Country::rename_country('bs' => 'The Bahamas');

Locale::Country::add_country_alias('Russian Federation'   => 'Russia');
Locale::Country::add_country_alias('Virgin Islands, U.S.' => 'US Virgin Islands');

# Source: http://www.bbc.co.uk/news/magazine-18233844
Locale::Country::add_country_alias('Argentina'     => 'the Argentine');
Locale::Country::add_country_alias('Congo'         => 'the Congo');<commit_msg>Trigger on queries mention calling "codes" plural.<commit_after>package DDG::Goodie::CallingCodes;
# ABSTRACT: Matches country names to calling codes

use DDG::Goodie;
use Locale::Country qw/country2code code2country/;
use Telephony::CountryDialingCodes;

zci answer_type => "calling_codes";

name        "CallingCodes";
description "Matches country names to international calling codes";
source      "https://en.wikipedia.org/wiki/List_of_country_calling_codes#Alphabetical_listing_by_country_or_region";
code_url    "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Goodie/CallingCodes.pm";
category    "geography";
topics      "travel", "geography";

primary_example_queries   "country code 55", "country code brazil";
secondary_example_queries "dialing code +55", "country calling code 55";

attribution github  => ["kablamo",            "<NAME>"],
            web     => ["http://kablamo.org", "<NAME>"];

triggers startend => 
    "calling code",
    "calling codes",
    "country calling code", 
    "country calling codes", 
    "country code", 
    "country dialing code", 
    "country dialing codes", 
    "dial in code",
    "dial in codes",
    "dialing code", 
    "dialing codes", 
    "international calling code", 
    "international calling codes", 
    "international dial in code",
    "international dial in codes",
    "international dialing code"; 
    "international dialing codes"; 

Locale::Country::rename_country('ae' => 'the United Arab Emirates');
Locale::Country::rename_country('do' => 'the Dominican Republic');
Locale::Country::rename_country('gb' => 'the United Kingdom');
Locale::Country::rename_country('kp' => "the Republic of Korea");
Locale::Country::rename_country('kr' => "the Democratic People's Republic of Korea");
Locale::Country::rename_country('ky' => 'the Cayman Islands');
Locale::Country::rename_country('mp' => 'the Northern Mariana Islands');
Locale::Country::rename_country('nl' => 'the Netherlands');
Locale::Country::rename_country('ph' => 'the Philippines');
Locale::Country::rename_country('ru' => 'the Russian Federation');
Locale::Country::rename_country('tw' => 'Taiwan');
Locale::Country::rename_country('us' => 'the United States');
Locale::Country::rename_country('vg' => 'the British Virgin Islands');
Locale::Country::rename_country('vi' => 'the US Virgin Islands');

# These are the only 2 countries which officially have 'The' in their name
# Source: http://www.bbc.co.uk/news/magazine-18233844
Locale::Country::rename_country('gm' => 'The Gambia');
Locale::Country::rename_country('bs' => 'The Bahamas');

Locale::Country::add_country_alias('Russian Federation'   => 'Russia');
Locale::Country::add_country_alias('Virgin Islands, U.S.' => 'US Virgin Islands');

# Source: http://www.bbc.co.uk/news/magazine-18233844
Locale::Country::add_country_alias('Argentina'     => 'the Argentine');
Locale::Country::add_country_alias('Congo'         => 'the Congo');
{'fraction_non_alphanumeric': 0.1570086833244728, 'fraction_numerical': 0.00886053517632465, 'mean_word_length': 5.849514563106796, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 55, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7462135', 'n_tokens_mistral': 1759, 'n_tokens_neox': 1688, 'n_words': 402}