public final class DigitsParser extends Object implements SlotParser
Only positive values are recognized.
These may include hyphenated or unhyphenated numbers from twenty through ninety-nine. Unhyphenated numbers are automatically joined.
Allowing unhyphenated double-digit numbers creates an ambiguity that limits some representations, for example "sixty five thousand" could be parsed as either 65000 or 605000. For this reason, 2- and 3-digit numbers are restricted to even hundreds/thousands. In this model, the above number would always be parsed as "65000" -- in other words, "sixty five thousand one" would be parsed as "650001". This limitation should be acceptable for most multi-digit requirements (telephone numbers, social security numbers, etc.)
Constructor and Description |
---|
DigitsParser()
Create a new digit parser.
|
Modifier and Type | Method and Description |
---|---|
Object |
parse(Map<String,Object> metadata,
String rawValue)
Parse a raw string value from an utterance into a typed value for a
concrete slot.
|
public Object parse(Map<String,Object> metadata, String rawValue)
SlotParser
Implementers should throw an exception if the parsed value is invalid according to the supplied metadata.
parse
in interface SlotParser
metadata
- A map representing metadata for the particular slot being
parsed.rawValue
- The string from a user utterance that represents a slot
value.value
.Copyright © 2020. All rights reserved.