A generator that runs through the classification results for a set of keywords.
public generator Result::yieldResults( void )
This function has no parameters
Returns a generator that yields each individual classification result with each iteration. This function handles page reloads in the background and returns each result in FIFO order so that each result lines up with the input. In the case that there is an error during classification, each item yielded will contain an empty response.
Typically, each item yielded from this generator should include the following items:
A list of flags that were found with this category
Note
This field will only be filled if the flags parameter was set.
Echo the eContext API Category name associated with each input keyword
$keywords = [
"hello world",
"breaking bad",
"ace hardware chicago",
"elle magazine covers",
"macbook pro laptops",
"chicago blackhawks",
"arsenal vs barcelona",
"javascript programming guides",
"programming games online",
"coding games online",
"chicago bears",
"chicago cubs"
];
$client = new eContext\Client(ECONTEXT_USERNAME, ECONTEXT_PASSWORD);
$classify = new eContext\Classify\Keywords($client, $keywords);
$results = $classify->classify();
$i = 0;
foreach($results->yieldResults() as $keywordResult) {
$categoryId = $keywordResult['category_id'];
echo "{$keywords[$i++]} --> " . $results->getCategory($categoryId)['name'] . PHP_EOL;
}
Should output the following:
hello world -->
breaking bad --> Breaking Bad
ace hardware chicago --> Ace Hardware Stores
elle magazine covers --> Elle Magazine
macbook pro laptops --> Apple MacBook Pro
chicago blackhawks --> Chicago Blackhawks
arsenal vs barcelona --> F.C. Barcelona
javascript programming guides --> JavaScript Tutorials
programming games online --> Online Gaming
coding games online --> Online Gaming
chicago bears --> Chicago Bears
chicago cubs --> Chicago Cubs