Phrase & PhraseSet


level_1


Phrase

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 javadoc: Phrase.

PhraseSet

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

See also javadoc: 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");

Say say = SayBuilder.with(qiContext)
                    .withPhrase(phrase)
                    .build();

say.run();

With Listen

Use a PhraseSet to build a Listen:

PhraseSet phraseSet = PhraseSetBuilder.with(qiContext)
                                      .withTexts("Hello", "Hi")
                                      .build();

Listen listen = ListenBuilder.with(qiContext)
                             .withPhraseSet(phraseSet)
                             .build();

listen.run();

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

ListenResult listenResult = ...;

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

See also javadoc: ListenResult.

More