DDG::Block::Words - Block implementation to handle words based plugins
version 1017
The BUILD function is used to build a hash which maps trigger positions (start, any, end) to trigger words to trigger phrase length to plugins.
Eg. Given triggers:
START: "khan", "khan academy"; ANY : "forecast", "weather forecast"; END : "video", "youtube videos";
This would produce the following hash:
_words_plugins = {
start => { 'khan' => { 1 => [ DDG::Spice::KhanAcademy ], 2 => { 'khan academy' => [ DDG::Spice::KhanAcademy ] } } }, any => { 'forecast' => { 1 => [ DDG::Spice::Forecast, DDG::Spice::Foo ] }, 'weather' => { 2 => { 'weather forecast' => [ DDG::Spice::Forecast ] } } }, end => { 'video' => { 1 => [ DDG::Spice::Video ] }, 'videos' => { 2 => { 'youtube videos' => [ DDG::Spice::Video ] } } } }
This private attribute is a cache for grouping the plugins into start, end and any based plugins.
Overloading this method from DDG::Block assures that we dont allow any plugin which as no triggers. Words plugins are all triggered via keywords against a hash, which means there is no order relevance, which makes a triggerless plugin just totally unclear, if it now needs to get started before the hash compare or after (or not).
DuckDuckGo <open@duckduckgo.com>
This software is Copyright (c) 2013 by DuckDuckGo, Inc. https://duckduckgo.com/.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
To install DDG, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DDG
CPAN shell
perl -MCPAN -e shell install DDG
For more information on module installation, please visit the detailed CPAN module installation guide.