p85
This commit is contained in:
@@ -317,6 +317,12 @@ final class AgentRunnerConfig
|
||||
return $this->genreConfig?->getValueInt($path);
|
||||
}
|
||||
|
||||
/** @return array<int|string, mixed> */
|
||||
private function genreArray(string $path): array
|
||||
{
|
||||
return $this->genreConfig?->getValueArray($path) ?? [];
|
||||
}
|
||||
|
||||
private function getRequiredInt(string $key): int
|
||||
{
|
||||
$value = $this->requiredValue($key);
|
||||
@@ -1390,6 +1396,107 @@ final class AgentRunnerConfig
|
||||
return $this->genreStringList('shop_query_runtime.semantic_shop_search_tokens.terms');
|
||||
}
|
||||
|
||||
public function isGenericDeviceQueryAnchorEnabled(): bool
|
||||
{
|
||||
return $this->genreBool('shop_query_runtime.generic_device_anchor.enabled') ?? false;
|
||||
}
|
||||
|
||||
public function shouldGenericDeviceQueryAnchorRemoveGenericDeviceTerms(): bool
|
||||
{
|
||||
return $this->genreBool('shop_query_runtime.generic_device_anchor.remove_generic_device_terms') ?? false;
|
||||
}
|
||||
|
||||
public function getGenericDeviceQueryAnchorTemplate(): string
|
||||
{
|
||||
return $this->genreString('shop_query_runtime.generic_device_anchor.template');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getGenericDeviceQueryAnchorTriggerTerms(): array
|
||||
{
|
||||
return $this->genreStringList('shop_query_runtime.generic_device_anchor.trigger_terms');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getGenericDeviceQueryAnchorSuppressTerms(): array
|
||||
{
|
||||
return $this->genreStringList('shop_query_runtime.generic_device_anchor.suppress_if_terms');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array{anchor: string, match_terms: string[]}>
|
||||
*/
|
||||
public function getGenericDeviceQueryAnchorRules(): array
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
foreach ($this->genreArray('shop_query_runtime.generic_device_anchor.anchor_rules') as $rule) {
|
||||
if (!is_array($rule)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$anchor = $rule['anchor'] ?? '';
|
||||
if (!is_scalar($anchor)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$anchor = trim((string) $anchor);
|
||||
if ($anchor === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rawMatchTerms = $rule['match_terms'] ?? [];
|
||||
if (!is_array($rawMatchTerms)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$matchTerms = [];
|
||||
foreach ($rawMatchTerms as $term) {
|
||||
if (!is_scalar($term)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$term = trim((string) $term);
|
||||
if ($term !== '' && !in_array($term, $matchTerms, true)) {
|
||||
$matchTerms[] = $term;
|
||||
}
|
||||
}
|
||||
|
||||
if ($matchTerms === []) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rules[] = [
|
||||
'anchor' => $anchor,
|
||||
'match_terms' => $matchTerms,
|
||||
];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getGenericDeviceQueryAnchorPositiveFilterTerms(): array
|
||||
{
|
||||
$terms = [];
|
||||
|
||||
foreach ($this->getGenericDeviceQueryAnchorRules() as $rule) {
|
||||
$terms[] = $rule['anchor'];
|
||||
$terms = array_merge($terms, $rule['match_terms']);
|
||||
}
|
||||
|
||||
return array_values(array_unique(array_filter(
|
||||
array_map(static fn(string $term): string => trim($term), $terms),
|
||||
static fn(string $term): bool => $term !== ''
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user