The Sentence object represents data obtained through the development of Natural Language Understanding (NLU) technology.
intentReturns the name of the recognized intent.
Signature: intent string
Usage Example:
$sentence = nlu.parse("Hi John", "d926726a-5acb-4233-8c1e-ce4300921de0");
$intent = $sentence.intent; // $intent contains "greeting".
intentConfidenceDetermines the degree of confidence of the recognized intent (1 is the maximum confidence, 0 is the minimum).
Signature: Number of confidence in intention
Usage Example:
$sentence = nlu.parse("Hi John", "d926726a-5acb-4233-8c1e-ce4300921de0");
$confidence = $sentence.intentConfidence; // $confidence contains 0.98.
intentsReturns a list of all recognized intents. Each element is a tuple of two elements:
Signature: List of intents<tuple>
Usage Example:
$sentence = nlu.parse("Good morning John, time to wake up", "d926726a-5acb-4233-8c1e-ce4300921de0");
$intents = $sentence.intents; // $intents contains [("greetings", 0.97), ("wakeup", 0.88)].
$first = $intents.get(0); // $first contains ("greetings", 0.97).
$intent = $first.get(0); // $intent contains "greetings".
entitiesReturns a list of recognized entities. Each element is a tuple of three elements:
Signature: List of entities<tuple>
Usage Example:
$sentence = nlu.parse("Good morning John", "d926726a-5acb-4233-8c1e-ce4300921de0");
$entities = $sentence.entities; // $entities contains [("human-name", "John", 0.96), ("time", "2023-01-09 23:30:00", 0.87)].
$first = $entities.get(0); // $first contains ("human-name", "John", 0.96).
$type = $first.get(0); // $type contains "human-name".