RuleORama grammer structure

Home Forums OpenEars plugins RuleORama grammer structure

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

  • Author
    Posts
  • #1031693

    kdsaft
    Participant

    Hi, I’m quite new to OpenEars. I have been experimenting RuleORama. I have two questions:
    Here is the grammar structure:
    let grammar = [
    ThisWillBeSaidOnce : [
    [ OneOfTheseWillBeSaidOnce : ["HELLO", "GREETINGS"]],
    [ OneOfTheseCanBeSaidOnce : ["COMPUTER", "ROBOT"]],
    [ OneOfTheseWillBeSaidOnce : ["GO", "MOVE"]],
    [ThisWillBeSaidWithOptionalRepetitions : [
    [ OneOfTheseWillBeSaidOnce : ["10", "20","30"]],
    [ OneOfTheseWillBeSaidOnce : ["LEFT", "RIGHT", "FORWARD"]]
    ]],
    [ ThisCanBeSaidOnce : ["THANK YOU"]]
    ]
    ]

    (1) I built (Swift 3) the project onto by iPhone and said: “Hello go 20 left, 30 right”

    Here is the response: “HELLO ROBOT GO 20 LEFT HELLO GO 30 RIGHT” with a score of (-60563) and an utterance ID of 2.

    It picked up an extra ‘ROBOT,’ but my question is how did pick up the second ‘GO’? Did I make a mistake in the structure above?

    (2) Just to confirm I get this: If there 5 distinct statements a user could make (where the above was 1 of them), to do this I would change at the ThisWillBeSaidOnce at the top level to OneOfTheseWillBeSaidOnce with five sets of [].

    Thanks for any help!
    Keith

    • This topic was modified 1 year, 8 months ago by  kdsaft.
    #1031696

    Halle Winkler
    Politepix

    Welcome Keith,

    The hypothesis is actually two complete recognitions according to your ruleset (RuleORama can return more than one complete rule-conforming utterances in a single hypothesis if they were uttered). The reason that it doesn’t correspond to your real utterance is because for performance reasons, RuleORama doesn’t support optional repetitions, so it reduces them to a single repetition. This is mentioned in the docs and the verbose logging, but it’s the kind of small detail it’s easy to accidentally overlook when you’re first getting started. So, the answer is that there is nothing wrong with your ruleset, but your optionals are silently turning into single repetitions only.

    #1031698

    kdsaft
    Participant

    Ah, got it! Thank-you!!

    I tried this:

            let grammar = [
                OneOfTheseWillBeSaidOnce : [
                    [ ThisWillBeSaidOnce : [
                        [ ThisWillBeSaidOnce : ["HOW MUCH"]],
                        [ OneOfTheseWillBeSaidOnce : ["FLOUR", "SUGAR", "BUTTER"]]]],
                    [ ThisWillBeSaidOnce : [
                        [ ThisWillBeSaidOnce : ["HOW MANY"]],
                        [ OneOfTheseWillBeSaidOnce : ["EGGS", "APPLES", "PEARS"]]]]
            ]]

    with my expectation that the user could say either “How much flour/sugar/butter” OR “How many eggs/apples/pears”. However from the log it generated:

    HOW MUCH BUTTER HOW MANY APPLES
    HOW MUCH BUTTER HOW MANY EGGS
    HOW MUCH BUTTER HOW MANY PEARS
    HOW MUCH FLOUR HOW MANY APPLES
    HOW MUCH FLOUR HOW MANY EGGS
    HOW MUCH FLOUR HOW MANY PEARS
    HOW MUCH SUGAR HOW MANY APPLES
    HOW MUCH SUGAR HOW MANY EGGS
    HOW MUCH SUGAR HOW MANY PEARS

    What did I do wrong?
    thanks!
    Keith

    #1031701

    Halle Winkler
    Politepix

    Hi Keith,

    The outermost rule needs to be a ThisWillBeSaidOnce enclosing the rest of your grammar; otherwise it ought to work.

    #1031702

    kdsaft
    Participant

    Cool! That worked! Thank-you!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.