optimize sale sintent
This commit is contained in:
@@ -13,10 +13,29 @@ final class SalesIntentLite
|
|||||||
public const IMPLEMENTATION = 'implementation';
|
public const IMPLEMENTATION = 'implementation';
|
||||||
public const ROI = 'roi';
|
public const ROI = 'roi';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mindestabstand zwischen Top1 und Top2,
|
||||||
|
* damit ein Intent wirklich dominant ist.
|
||||||
|
*/
|
||||||
|
private const DOMINANCE_DELTA = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mindestscore, damit überhaupt ein Nicht-Discovery-Intent
|
||||||
|
* akzeptiert wird.
|
||||||
|
*/
|
||||||
|
private const MIN_SCORE_THRESHOLD = 3;
|
||||||
|
|
||||||
public function detect(string $originalPrompt): array
|
public function detect(string $originalPrompt): array
|
||||||
{
|
{
|
||||||
$p = $this->normalize($originalPrompt);
|
$p = $this->normalize($originalPrompt);
|
||||||
|
|
||||||
|
if ($p === '') {
|
||||||
|
return [
|
||||||
|
'intent' => self::DISCOVERY,
|
||||||
|
'score' => 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
$scores = [
|
$scores = [
|
||||||
self::PRICING => 0,
|
self::PRICING => 0,
|
||||||
self::COMPARISON => 0,
|
self::COMPARISON => 0,
|
||||||
@@ -26,7 +45,7 @@ final class SalesIntentLite
|
|||||||
];
|
];
|
||||||
|
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
// PRICING (stark gewichten)
|
// PRICING
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
foreach ([
|
foreach ([
|
||||||
'preis','preise','kosten','lizenz','lizenzmodell',
|
'preis','preise','kosten','lizenz','lizenzmodell',
|
||||||
@@ -39,13 +58,12 @@ final class SalesIntentLite
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
// COMPARISON (wichtiger für Katalog-Block)
|
// COMPARISON
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
foreach ([
|
foreach ([
|
||||||
'/\bvergleich(en)?\b/u',
|
'/\bvergleich(en)?\b/u',
|
||||||
'/\bvs\b/u',
|
'/\bvs\b/u',
|
||||||
'/\bgegenueber\b/u',
|
'/\bgegenueber\b/u',
|
||||||
'/\boder\b/u',
|
|
||||||
'/\balternative(n)?\b/u',
|
'/\balternative(n)?\b/u',
|
||||||
'/\bunterschied(e)?\b/u',
|
'/\bunterschied(e)?\b/u',
|
||||||
'/\bbesser\b/u'
|
'/\bbesser\b/u'
|
||||||
@@ -69,7 +87,7 @@ final class SalesIntentLite
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
// IMPLEMENTATION (Intent-Verben stärker)
|
// IMPLEMENTATION
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
foreach ([
|
foreach ([
|
||||||
'implementierung','implementieren',
|
'implementierung','implementieren',
|
||||||
@@ -85,7 +103,7 @@ final class SalesIntentLite
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
// ROI (weniger generisch)
|
// ROI
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
foreach ([
|
foreach ([
|
||||||
'roi','rentabilitaet','rentabilität',
|
'roi','rentabilitaet','rentabilität',
|
||||||
@@ -98,18 +116,35 @@ final class SalesIntentLite
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------
|
||||||
|
// Entscheidung
|
||||||
|
// ------------------------------------------------------------
|
||||||
|
|
||||||
arsort($scores);
|
arsort($scores);
|
||||||
|
|
||||||
$topIntent = array_key_first($scores);
|
$intents = array_keys($scores);
|
||||||
$topScore = $scores[$topIntent] ?? 0;
|
$values = array_values($scores);
|
||||||
|
|
||||||
if ($topScore <= 0) {
|
$topIntent = $intents[0] ?? self::DISCOVERY;
|
||||||
|
$topScore = $values[0] ?? 0;
|
||||||
|
$secondScore = $values[1] ?? 0;
|
||||||
|
|
||||||
|
// Kein relevanter Score → Discovery
|
||||||
|
if ($topScore < self::MIN_SCORE_THRESHOLD) {
|
||||||
return [
|
return [
|
||||||
'intent' => self::DISCOVERY,
|
'intent' => self::DISCOVERY,
|
||||||
'score' => 0,
|
'score' => 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keine klare Dominanz → Discovery
|
||||||
|
if (($topScore - $secondScore) < self::DOMINANCE_DELTA) {
|
||||||
|
return [
|
||||||
|
'intent' => self::DISCOVERY,
|
||||||
|
'score' => $topScore,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'intent' => $topIntent,
|
'intent' => $topIntent,
|
||||||
'score' => $topScore,
|
'score' => $topScore,
|
||||||
@@ -124,7 +159,7 @@ final class SalesIntentLite
|
|||||||
'ä' => 'ae',
|
'ä' => 'ae',
|
||||||
'ö' => 'oe',
|
'ö' => 'oe',
|
||||||
'ü' => 'ue',
|
'ü' => 'ue',
|
||||||
'ß'=>'ss'
|
'ß' => 'ss',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user