alphanum_lc grammar
Collects a connected string of up to 20 digits and alphabetic characters.
For example, this grammar could be used to recognize a product code or order number.
Non-alphanumeric characters such as hyphens (-), dots (.), and underscores (_) are not recognized; if spoken they reduce recognition accuracy.
See the Language Supplement for details about character and digit pronunciations.
Return keys/values
Key |
Value |
---|---|
MEANING |
Contains a string of ISO-8859-1 digits and lowercase letters, with no embedded spaces. |
SWI_literal |
Contains the exact text that was recognized. |
Properties
Property |
Description |
---|---|
entries |
URI specifying a file that lists allowed entries, one per line (see below). |
You must specify an "entries" property. The entries file (encoded as UTF-8) consists of alphanumeric strings that are allowed to be recognized. The file can have over one million entries with one entry per line and no quotation marks. Use lowercase alphabetic characters. (Uppercase entries are rejected. Non-alphanumeric characters, such as dashes or spaces, are ignored.)
By default, each constraint has no spaces between the elements. You can add an optional header at the top to specify additional directives. The header consists of a series of lines beginning with a double colon (::) followed by a directive (with no intervening space). The directives:
Directive |
Description |
---|---|
::DELIMITED |
Indicates there are spaces between each element in each constraint. The spaces are ignored. This directive is useful when two characters are needed to represent a single alphabetic character; for example, the Spanish "ch" letter. |
::WEIGHTED max |
Indicates that a weight value follows each constraint entry. The max specifies the maximum absolute value used for a weight in the entries file. Weights allow you to specify the expected frequency of constraints relative to each other. For example, in English "12a4" and "1284" sound very similar; but if you know that one is more probable, you can assign a higher weight; and the Recognizer favors your choice during computation. (Higher numbers increase the chance of recognition.) When this directive is present, every constraint must be followed by a space and a real number, where the number is a weight to be associated with the constraint. (The space is required even if ::DELIMITED is not used.) If any weight is non-numeric, the entries file fails to load. If any weight has an absolute value greater than max, the value of max is used and a warning is generated. |
::LENGTH len |
Indicates that all constraints in this file are the same length and that they are len characters long. By using this directive, you improve recognition accuracy. |
::NUM n |
Indicates that this file contains n number of constraints (or fewer). By using this directive, you can speed the loading of the entries file. No more than n constraints are loaded. |
Example
The URI for the entries property can be a local file or an http location. Here is an example of each:
builtin:grammar/alphanum_lc?language=en-US;entries=file:
//entrylist.txt
builtin:grammar/alphanum_lc?language=en-US;entries=http:
//myserver/constraints/constraint1.txt
Above, the path to entrylist.txt is relative to the directory of the containing XML file. In this case, entrylist.txt must be in the same directory.
The file containing the entries (alpha.entries.txt) might look like this:
wovfb
wa1x
7ymn7
d08ya
jvgrfd
l76c0
7983
78zehnf
w5506
znz4xd
v4tq
The list of constraints can be limited to numbers. For example:
1564
2345
8642
1119999911
The next example specifies a list of constraining entries that resides on the web. Note that the language is not defined, this means that the language is determined by the setting of the swirec_language property:
builtin:grammar/alphanum_lc?entries=http://www.builtin.com/
alpha.entries.txt