Module PhraseUtils
Collection of reusable phrase components.
How to use:
1. Append a phrase returned by getPhrase to your PhraseBuilder. The element needs to be bound to a named property.
2. Retrieve the result using getPhraseResult, passing to it the path to the property.
These are the available phrases:
digit
A single digit from 0-9
spelledNumber
Arguments: number of digits
phoneticLetter
ICAOairportCode
runwayId
local proposeRoute = VoiceCommand:new { confidence = 0.9, phrase = PhraseBuilder.new() :append "let's fly from" :append(PhraseUtils.getPhrase "ICAOairportCode", "from") :append "to" :append { propName = "to", choices = { "amsterdam", "oslo", "zurich", { propVal = "ICAO", choice = PhraseUtils.getPhrase "ICAOairportCode" } } } :build() } copilot.addCoroutine(function() proposeRoute:activate() local res = Event.waitForEvent(proposeRoute) local from = PhraseUtils.getPhraseResult("ICAOairportCode", res, "from") local to = res:getProp "to" if to == "ICAO" then to = PhraseUtils.getPhraseResult("ICAOairportCode", res, "to") end print("From: " .. from .. ", to: " .. to) end)
Functions
getPhrase(phraseName[, ...]) | Gets a component by its name. |
getPhraseResult(phraseName, res, ...) | Retrieves the value from the phrase's properties. |
Functions
Methods- getPhrase(phraseName[, ...])
-
Gets a component by its name.
Parameters:
- phraseName string
- ... arguments (optional)
Returns:
-
A Phrase object
- getPhraseResult(phraseName, res, ...)
-
Retrieves the value from the phrase's properties.
Parameters:
- phraseName string
- res A RecoResult object
- ... path The path to the property. Same as the parameters of RecoResult:getProp
Returns:
-
string
Phrase-specific result