<commit_before>package DDG::Spice::Drinks;

use DDG::Spice;

triggers any => "drink", "drink mix", "drink recipe", "mixed drink", "drink ingredients";

spice to => 'http://www.drinkproject.com/api/?type=json&name=$1&callback=ddg_spice_drinks';

handle query_lc => sub {
    if (/^(mixed\s+)*drink(\s+recipe)*\s+([0-9a-z #]+)$) {
            return $3 if $3;
    }
    if (/^([0-9a-z #]+)\s+(drink|mixed) (drink|mix|recipe|ingredients)$) {
            return $1 if $1;
    }
    return;
};


1;

<commit_msg>more dynamic regex<commit_after>package DDG::Spice::Drinks;

use DDG::Spice;

triggers any => "drink", "mix", "recipe", "ingredients";

spice to => 'http://www.drinkproject.com/api/?type=json&name=$1&callback=ddg_spice_drinks';

handle query_lc => sub {
    if (/^((((making)+|(how\sto\s(make|mix)+)+)+(\s(a|an|the))*)|(mixed\s+)*drink(\s+(recipe|mix))*)+\s+([0-9a-z #]+)$) {
            return $12 if $12;
    }
    if (/^([0-9a-z #]+)\s+(drink|mixed)\s(drink|mix|recipe|ingredients)$) {
            return $1 if $1;
    }
    return;
};

1;
{'fraction_non_alphanumeric': 0.2430886558627264, 'fraction_numerical': 0.020972354623450904, 'mean_word_length': 3.646017699115044, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3707309', 'n_tokens_mistral': 465, 'n_tokens_neox': 438, 'n_words': 70}