Convert JSGF Grammar to Dictionary

Home Forums OpenEars Convert JSGF Grammar to Dictionary

Viewing 2 posts - 1 through 2 (of 2 total)

  • Author
    Posts
  • #1024978
    benwirz
    Participant

    Hi Halle,

    I have OpenEars working really well with a JSGF grammar file. I’m interested in converting it into your new dictionary style input with the end goal of using RapidEars & RuleORama. I’m having trouble creating a dictionary that we accept more than one phrase format. Only the first phrase rule in the dictionary is recognized and the rest are ignored. I verified this by looking at the grammar file generated from the dictionary. Can you see where I’m going wrong?

    Thanks,
    Ben

    NSDictionary *grammar = @{
    OneOfTheseWillBeSaidOnce: @[
    @{ ThisWillBeSaidOnce : @[ // 8 O’Five, One O’ Nine
    @{ OneOfTheseWillBeSaidOnce : @[@”ONE”, @”TWO”, @”THREE”, @”FOUR”, @”FIVE”, @”SIX”, @”SEVEN”, @”EIGHT”, @”NINE”, @”TEN”, @”ELEVEN”, @”TWELVE”]},
    @{ ThisWillBeSaidOnce : @[@”O”]},
    @{ OneOfTheseWillBeSaidOnce : @[@”ONE”, @”TWO”, @”THREE”, @”FOUR”, @”FIVE”, @”SIX”, @”SEVEN”, @”EIGHT”]}
    ],

    ThisWillBeSaidOnce : @[ // 8 O’Clock, 12 O’Clock
    @{ OneOfTheseWillBeSaidOnce : @[@”ONE”, @”TWO”, @”THREE”, @”FOUR”, @”FIVE”, @”SIX”, @”SEVEN”, @”EIGHT”, @”NINE”, @”TEN”, @”ELEVEN”, @”TWELVE”]},
    @{ ThisWillBeSaidOnce : @[@”O’CLOCK”]}
    ],

    ThisWillBeSaidOnce : @[ // Four Fourteen, Five Twelve, Five Fifty
    @{ OneOfTheseWillBeSaidOnce : @[@”ONE”, @”TWO”, @”THREE”, @”FOUR”, @”FIVE”, @”SIX”, @”SEVEN”, @”EIGHT”, @”NINE”, @”TEN”, @”ELEVEN”, @”TWELVE”]},
    @{ OneOfTheseWillBeSaidOnce : @[@”TEN”,@”ELEVEN”, @”TWELVE”, @”THIRTEEN”, @”FOURTEEN”, @”FIFTEEN”, @”SIXTEEN”, @”SEVENTEEN”, @”EIGHTEEN”, @”NINETEEN”, @”TWENTY”, @”THIRTY”, @”FORTY”, @”FIFTY”]}
    ]
    }
    ]
    };

    This is my working JSGF file which I would like to convert.

    #JSGF V1.0;
    grammar PayDisplayEnglishJSGF;

    // Reusable rules
    <one_word_hour> = ( ONE | TWO | THREE | FOUR | FIVE | SIX | SEVEN | EIGHT | NINE | TEN | ELEVEN | TWELVE );
    <single_digit_no_zero> = ( ONE | TWO | THREE | FOUR | FIVE | SIX | SEVEN | EIGHT | NINE ); // zero not included
    <single_digit> = ( <single_digit_no_zero> | ZERO);
    <single_digit_tens> = ( ZERO | ONE | TWO | THREE | FOUR | FIVE );

    // FIVE O SIX, ONE O THREE, TWELVE O NINE
    <o_minute_rule> = [ <one_word_hour> O <single_digit_no_zero> ];

    // FIVE O’CLOCK ONE O’CLOCK
    <oclock_rule> = [ <one_word_hour> O’CLOCK ];

    // TEN FIFTEEN, ONE THIRTY, THREE FIFTY
    <single_word_min_minutes> = ( TEN | ELEVEN | TWELVE | THIRTEEN | FOURTEEN | FIFTEEN | SIXTEEN | SEVENTEEN | EIGHTEEN | NINETEEN | TWENTY | THIRTY| FORTY |FIFTY );
    <single_word_min_rule> = [ <one_word_hour> <single_word_min_minutes> ];

    // ONE THIRTY SIX, TWO FIFTY TWO, TWELVE TWENTY THREE
    <double_word_min_tens> = ( TWENTY | THIRTY| FORTY | FIFTY );
    <double_word_min_rule> = [ <one_word_hour> <double_word_min_tens> <single_digit_no_zero>];

    //ONE TWO THREE, FIVE FOUR NINE, ONE ZERO ZERO, FIVE FIVE SIX
    <three_digits_rule> = [ <one_word_hour> <single_digit_tens> <single_digit>];

    //ONE TWO THREE FOUR, ONE ONE FOUR NINE, ONE ZERO FIVE THREE
    <four_digits_hours> = ( TEN | ONE ZERO | ELEVEN | ONE ONE | TWELVE | ONE TWO);
    <four_digits_rule> = [ <four_digits_hours> <single_digit_tens> <single_digit>];

    public <combined_rule> = ( <o_minute_rule> | <oclock_rule> | <single_word_min_rule> | <double_word_min_rule> | <three_digits_rule> | <four_digits_rule>) [ AM | PM | TODAY |TOMORROW ];

    #1024994
    Halle Winkler
    Politepix

    Does this get you the intended result?

        @{ 
          OneOfTheseWillBeSaidOnce: 
              @[ 
                  @{ 
                      ThisWillBeSaidOnce:
                          
                          @[ // 8 O’Five, One O’ Nine
                              @{ 
                                  OneOfTheseWillBeSaidOnce : @[@"ONE", @"TWO", @"THREE", @"FOUR", @"FIVE", @"SIX", @"SEVEN", @"EIGHT", @"NINE", @"TEN", @"ELEVEN", @"TWELVE"]
                                  },
                              @{ 
                                  ThisWillBeSaidOnce : @[@"O"]
                                  },
                              @{ 
                                  OneOfTheseWillBeSaidOnce : @[@"ONE", @"TWO", @"THREE", @"FOUR", @"FIVE", @"SIX", @"SEVEN", @"EIGHT"]
                                  }
                              ]
                      },
                  @{ 
                      ThisWillBeSaidOnce:
                          
                          @[ // 8 O’Five, One O’ Nine
                              @{ 
                                  OneOfTheseWillBeSaidOnce : @[@"ONE", @"TWO", @"THREE", @"FOUR", @"FIVE", @"SIX", @"SEVEN", @"EIGHT", @"NINE", @"TEN", @"ELEVEN", @"TWELVE"]
                                  },
                              @{ 
                                  ThisWillBeSaidOnce : @[@"O’CLOCK"]
                                  }
                              ]
                      },
                  @{ 
                      ThisWillBeSaidOnce:
                          
                          @[ // 8 O’Five, One O’ Nine
                              @{ 
                                  OneOfTheseWillBeSaidOnce : @[@"ONE", @"TWO", @"THREE", @"FOUR", @"FIVE", @"SIX", @"SEVEN", @"EIGHT", @"NINE", @"TEN", @"ELEVEN", @"TWELVE"]
                                  },
                              @{ 
                                  OneOfTheseWillBeSaidOnce : @[@"TEN",@"ELEVEN", @"TWELVE", @"THIRTEEN", @"FOURTEEN", @"FIFTEEN", @"SIXTEEN", @"SEVENTEEN", @"EIGHTEEN", @"NINETEEN", @"TWENTY", @"THIRTY", @"FORTY", @"FIFTY"]
                                  }
                              ]
                      }
                  ]
          };
    
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.