<commit_before>package DDG::Goodie::RoyalMail;

use DDG::Goodie;

zci is_cached   => 1;
zci answer_type => "royal_mail";

primary_example_queries 'royal mail RU401513974GB';
description 'Track a Royal Mail / Parcelforce parcel';
icon_url "/i/www.royalmail.com.ico";
name '<NAME>';
code_url
    'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/RoyalMail.pm';
category 'ids';
topics 'special_interest';
attribution
    github  => [ 'https://github.com/TopHattedCoder', '<NAME>' ],
    twitter => [ 'http://twitter.com/TopHattedCoder', '@Tom Bebbington' ];

# Regex for royal mail.
my $rm_qr = qr/royalmail|parcelforce/io;

my $tracking_qr = qr/package|parcel|track(?:ing|)|num(?:ber|)|\#/i;

# note: parcelforce format listed at http://www.parcelforce.com/help-information/frequently-asked-questions/track-parcel#2
my $parcel
    = qr/[A-Z]{2}[0-9]{7}|[A-Z]{4}[0-9]{10}|[A-Z]{2}[0-9]{9}GB|[0-9]{12}|[A-Z]{2}[0-9]{9}[A-Z]{2}/i;
triggers query_nowhitespace_nodash => qr/
                                        ^$rm_qr.*?(?<parcel_number>$parcel)$|
                                        ^(?<parcel_number>$parcel).*?$rm_qr$|
                                        ^(?:$tracking_qr|$rm_qr|)*(?<parcel_number>$parcel)(?:$tracking_qr|$rm_qr|)*$
                                        /xo;

handle query_nowhitespace_nodash => sub {
    my $parcel_number = $+{parcel_number};
    return $parcel_number,
        heading => 'Royal Mail / Parcelforce Tracking',
        html =>
        qq(Track this parcel at <a href="http://www.royalmail.com/portal/rm/track?trackNumber=$parcel_number">Royal Mail</a> or <a href="http://www.parcelforce.com/track-trace?trackNumber=$parcel_number">Parcelforce</a>.);
};

1;<commit_msg>Royal Mail IA: Correct twitter attribution<commit_after>package DDG::Goodie::RoyalMail;

use DDG::Goodie;

zci is_cached   => 1;
zci answer_type => "royal_mail";

primary_example_queries 'royal mail RU401513974GB';
description 'Track a Royal Mail / Parcelforce parcel';
icon_url "/i/www.royalmail.com.ico";
name '<NAME>';
code_url
    'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/RoyalMail.pm';
category 'ids';
topics 'special_interest';
attribution
    github  => [ 'https://github.com/TopHattedCoder', '<NAME>' ],
    twitter => [ 'http://twitter.com/TopHattedCoder', '@TopHattedCoder' ];

# Regex for royal mail.
my $rm_qr = qr/royalmail|parcelforce/io;

my $tracking_qr = qr/package|parcel|track(?:ing|)|num(?:ber|)|\#/i;

# note: parcelforce format listed at http://www.parcelforce.com/help-information/frequently-asked-questions/track-parcel#2
my $parcel
    = qr/[A-Z]{2}[0-9]{7}|[A-Z]{4}[0-9]{10}|[A-Z]{2}[0-9]{9}GB|[0-9]{12}|[A-Z]{2}[0-9]{9}[A-Z]{2}/i;
triggers query_nowhitespace_nodash => qr/
                                        ^$rm_qr.*?(?<parcel_number>$parcel)$|
                                        ^(?<parcel_number>$parcel).*?$rm_qr$|
                                        ^(?:$tracking_qr|$rm_qr|)*(?<parcel_number>$parcel)(?:$tracking_qr|$rm_qr|)*$
                                        /xo;

handle query_nowhitespace_nodash => sub {
    my $parcel_number = $+{parcel_number};
    return $parcel_number,
        heading => 'Royal Mail / Parcelforce Tracking',
        html =>
        qq(Track this parcel at <a href="http://www.royalmail.com/portal/rm/track?trackNumber=$parcel_number">Royal Mail</a> or <a href="http://www.parcelforce.com/track-trace?trackNumber=$parcel_number">Parcelforce</a>.);
};

1;
{'fraction_non_alphanumeric': 0.1817923186344239, 'fraction_numerical': 0.01934566145092461, 'mean_word_length': 3.293040293040293, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 37, 'https://': 4, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6858237', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1272, 'n_words': 183}