Phrase & PhraseSet



A Phrase contains a chunk of text intended to be said or listened by the robot. Unlike in English grammar, this sequence of words does not necessarily need to have a meaning by itself.

See also API doc: Phrase.


A PhraseSet contains several Phrases. It is usually used to group variants and synonyms.

See also API doc: PhraseSet.

How to use it

With Say

Create a Phrase with a String and use it to build a Say:

Phrase phrase = new Phrase("Hello")

val say: Say = SayBuilder.with(qiContext)
Phrase phrase = new Phrase("Hello");

Say say = SayBuilder.with(qiContext)

With Listen

Use a PhraseSet to build a Listen:

val phraseSet: PhraseSet = PhraseSetBuilder.with(qiContext)
                                    .withTexts("Hello", "Hi")

val listen: Listen = ListenBuilder.with(qiContext)
PhraseSet phraseSet = PhraseSetBuilder.with(qiContext)
                                      .withTexts("Hello", "Hi")

Listen listen = ListenBuilder.with(qiContext)

Retrieve the heard Phrase and the corresponding PhraseSet from a ListenResult:

val listenResult: ListenResult = ...

val heardPhrase: Phrase = listenResult.heardPhrase
val matchedPhraseSet: PhraseSet = listenResult.matchedPhraseSet
ListenResult listenResult = ...;

Phrase heardPhrase = listenResult.getHeardPhrase();
PhraseSet matchedPhraseSet = listenResult.getMatchedPhraseSet();

See also API doc: ListenResult.