Using BNF with Concept/Phrase Grammars

Note that the text on this page is intended for concept/phrase grammars. LumenVox recommends using SRGS grammars instead of concept/phrase grammars, as SRGS provides a more robust and standard method of writing grammars. For information about writing SRGS grammars, see our SRGS tutorial.

When using AddPhrase(LV_SRE_AddPhrase or LVSpeechPort::AddPhrase) you may use the Backus-Naur Form for entering multiple words. This allows for a significant level of control over how phrases are entered.

A phrase may be entered simply as one or more words, such as "California" or "how do I".

The BNF format allows for several operators. Optional words may be enclosed in square brackets (the [ ] characters). A pipe (the | character) denotes a logical "or" statement, and parentheses clarify order of operation and control nesting.

For instance, the phrase:

[that's] (right | correct)

Would be matched to any of the following: "that's right", "that's correct", "right" or "correct".

You may also add in raw phonemes by surrounding them in curly braces (the { } characters). Phonemes represent the basic units of sound in a language; see Using Phonetic Spellings for more information.

For example, the phrase:

{Y EH S P L IY Z}  

Would be matched to "yes please".

You may also combine any of these formats:

is that ( correct | {R AY T} )

The above phrase would be matched to either "is that correct" or "is that right".

The engine has an internal dictionary of approximately 120,000 words, which it uses to know how words should be pronounced. There is also a robust phonetic speller for words not found in the  dictionary. The only valid punctuation marks are the apostrophe (the ' character) and the hyphen (the - character).

Hyphens should be used for multiple words that should be looked up in the internal dictionary as a single word, e.g. new-orleans. If the multiple words do not exist in the dictionary  the hyphens will be replaced by spaces and the words will be looked up in the dictionary separately.  

BNF Refresher

Below are two sentences entered in with BNF, followed by the various phrases that would match those concepts:

    1. I WANT TO KNOW THE DIRECTIONS TO

    2. I NEED TO KNOW THE DIRECTIONS TO

    3. I WANT TO HEAR THE DIRECTIONS TO

    4. I NEED TO HEAR THE DIRECTIONS TO

    5. I WANT THE DIRECTIONS TO

    6. I NEED THE DIRECTIONS TO

    7. I WANT TO KNOW DIRECTIONS TO

    8. I NEED TO KNOW DIRECTIONS TO

    9. I WANT TO HEAR DIRECTIONS TO

    10. I NEED TO HEAR DIRECTIONS TO

    11. I WANT DIRECTIONS TO

    12. I NEED DIRECTIONS TO

    13. I WANT TO KNOW THE DIRECTIONS

    14. I NEED TO KNOW THE DIRECTIONS

    15. I WANT TO HEAR THE DIRECTIONS

    16. I NEED TO HEAR THE DIRECTIONS

    17. I WANT THE DIRECTIONS

    18. I NEED THE DIRECTIONS

    19. I WANT TO KNOW DIRECTIONS

    20. I NEED TO KNOW DIRECTIONS

    21. I WANT TO HEAR DIRECTIONS

    22. I NEED TO HEAR DIRECTIONS

    23. I WANT DIRECTIONS

    24. I NEED DIRECTIONS


Complete Help Topic List | Speech Engine Product Information