V2.1: Kommunikation nach Medium, Absicht und Wirkung (Fälle E/F)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8442d0a3d8
commit
8026eceab4
13 files changed
+633
-2
No files matched your search
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Communication;
|
||||
|
||||
use App\Enums\MessageIntent;
|
||||
|
||||
/**
|
||||
* Rule-based intent of a message (V2.1). Deterministic and medium-independent; an AI classifier can later implement the
|
||||
* same interface of work (E-035). Whatever the rules do not clearly recognise is {@see MessageIntent::Unclear}.
|
||||
*/
|
||||
class IntentClassifier
|
||||
{
|
||||
public function classify(string $text, bool $assignedToCase): MessageIntent
|
||||
{
|
||||
$text = mb_strtolower($text);
|
||||
$has = fn (array $words): bool => (bool) preg_match('/('.implode('|', $words).')/u', $text);
|
||||
|
||||
if ($assignedToCase && $has(['umbuchen', 'verschieb', 'stornieren', 'stornierung', 'später anreisen', 'früher anreisen', 'ändern'])) {
|
||||
return MessageIntent::ChangeRequest;
|
||||
}
|
||||
if ($assignedToCase && $has(['ankunft', 'uhr', 'personen', 'kennzeichen', 'adresse', 'telefon', 'handynummer'])) {
|
||||
return MessageIntent::ProvideData;
|
||||
}
|
||||
if ($assignedToCase) {
|
||||
return MessageIntent::CaseReply;
|
||||
}
|
||||
if ($has(['frei', 'verfügbar', 'buchen', 'reservieren', 'anreise', 'zeitraum', 'vom \d'])) {
|
||||
return MessageIntent::StayInquiry;
|
||||
}
|
||||
if ($has(['\?', 'hund', 'haustier', 'parkplatz', 'wlan', 'preis', 'kosten', 'wie weit', 'strand', 'ausstattung'])) {
|
||||
return MessageIntent::GeneralQuestion;
|
||||
}
|
||||
|
||||
return MessageIntent::Unclear;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user