- COPYRIGHT AND LICENSE
DDG::Request - A request to DuckDuckGo itself, so the query itself and parameter around the query defining him
my $req = DDG::Request->new( query_raw => "Peter PAUL AND MARY!" ); print $req->query_clean; # "peter paul and mary"
This is the main request class which reflects a query and all parameter that are relevant for plugins to work with the request. It does not reflect a web request itself to DuckDuckGo, for this we have internal classes. The request class is the abstracted level all services can independently work with, on any medium, so also on the API, or via console based tests without web environment. This class is also base for run on a DDG::Block.
Beside the information of the query itself, a DDG::Request can also contain the language, the region and the geo location (which is calculated out of the IP).
This is the only required attribute. It is the query in the most raw form. If the query is given over special ways (like coming out of a hard url like https://duckduckgo.com/Star_Trek_Voyager), then those most get converted to the text that is normally shown on the query line then, before given to "query_raw".
This attribute gets generated out of the "query_raw", which gets split into all whitespace and non-whitespace content. For example the query:
DDG::Request->new( query_raw => "A++ B++" );
would give you the following arrayref on "query_raw_parts":
[ 'A++', ' ', 'B++', ]
It preserves the exactly content of the query also the current amount of whitespaces. Always the even index positions of the arrayref is the non whitespace content. So if you have the query:
DDG::Request->new( query_raw => " A++ B++ " );
leads to this "query_raw_parts" to fulfill this:
[ '', ' ' 'A++', ' ', 'B++', ' ', ]
This functions filters out the whitespace parts and empty parts of "query_raw_parts".
This takes the arrayref of "query_parts" and makes a lowercase arrayref version of it.
Triggers generate a hashref construction which makes it very easy to parse a query very effective through the accessing it word by word and so just analyzing against as less combinations as possible.
Takes "query_parts" and join them with one space.
Takes "query" and lowercases it.
Takes "query" and removes all whitespaces.
Takes "query" and removes all whitespaces and dashes.
Takes "query_lc" and removes all whitespaces and all non alphanumeric ascii.
Takes "query_clean" and generates an arrayref of the non-whitespace parts.
Is the count of the elements in "words"
This array contains all the plugins which already worked with this request. This means all the plugins which are triggered. If they gave back a result or not, doesn't matter here. This list is used by "allow_duplicate" in DDG::Block.
This function takes a part of "query_raw_parts" and generates all possible variants of it, also doing some magic with dash given words to give both single or combined without dash or only with space. For specific analyze what triggers are generated out of a part please read the function.
The method takes 2 index positions of "query_raw_parts" to give out the other parts of the query which is ot between them, so removes those parts and generates out of the rest again a string which can be given to a plugin for example.
It doesnt check which one is bigger, the first one must always be lower then the second one given. You can also just give one index position.
When called will set the remainder attribute for later use, e.g. "matched_trigger".
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