Skip to content

JSGF Grammer not working as expected #53

@G10DRAS

Description

@G10DRAS

I have created a simple JSGF as follows and using it with PocketSphinx-5prealpha (Python API)

#JSGF V1.0; 
grammar testGrammar;
<unit>     = (METER|CENTIMETER|MILE);
<number>  = (ONE|TWO|THREE|FOUR|FIVE|SIX|SEVEN|EIGHT|NINE|TEN|HUNDRED|THOUSAND)+;
public <phrases> = (WHAT IS YOUR NAME)  |  (<number> <unit> (EQUAL TO) [HOW MANY] <unit>) ;

Output what I am expecting (always) out of above grammer:
either
WHAT IS YOUR NAME
or phrases like
"ONE THOUSAND FIVE HUNDRED TEN METER EQUAL TO MILE"
"ONE THOUSAND FIVE HUNDRED TEN METER EQUAL TO HOW MANY MILE"
"ONE MILE EQUAL TO METER"

Which I am getting most of the time,
but sometime I also get output like:
"ONE TWO WHAT IS YOUR NAME"
"THOUSAND WHAT IS YOUR NAME"

I don't want such phrases, How to avoid this ?

If I remove '+' (one-or-many) operator from below line in grammer file:
<number> = (ONE|TWO|THREE|FOUR|FIVE|SIX|SEVEN|EIGHT|NINE|TEN|HUNDRED|THOUSAND)+;
Grammer works as expected but then I cant repeat the numbers and able to use only one number at a time.
for example
"HUNDRED MILE EQUAL TO HOW MANY METER"
and not like
"FIVE HUNDRED MILE EQUAL TO HOW MANY METER"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions