RuleORama Dynamic Grammar Swift Example

Home Forums OpenEars plugins RuleORama Dynamic Grammar Swift Example

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

  • Author
    Posts
  • #1030603
    drollins
    Participant

    I’ve successfully got a word array ruleset working but am having issues getting a dynamic dictionary of phrases working using Swift.

    Is there a sample solution anyone has developed that illustrates how this could be done with Swift?

    #1030625
    drollins
    Participant

    I tried converting the dynamic grammar dictionary from the sample app to swift as follow but I get a duplicate key on the second “OneOfTheseWillBeSaidOnce” after “ThisWillBeSaidWithOptionalRepetitions”.

    public func Generate() -> NSDictionary {

    let grammar: NSDictionary = [
    “ThisWillBeSaidOnce”: [“HELLO COMPUTER”, “GREETINGS ROBOT”],
    “OneOfTheseWillBeSaidOnce”: [“DO THE FOLLOWING”, “INSTRUCTION”],
    “OneOfTheseWillBeSaidOnce”: [“GO”, “MOVE”],
    “ThisWIllBeSaidWithOptionalRepetitions”: [
    “OneOfTheseWillBeSaidOnce”: [“LEFT”,”RIGHT”,”FORWARD”],
    “OneOfTheseWillBeSaidOnce”: [“10″,”20″,”30”]
    ],
    “OneOfTheseWillBeSaidOnce”: [“EXECUTE”, “DO IT”],
    “ThisCanBeSaidOnce”: [“THANK YOU”]
    ]

    return grammar

    }

    #1030626
    Halle Winkler
    Politepix

    Welcome,

    Take a closer look at the example in the docs – it isn’t a single dictionary full of repeating keys (this would not be a dictionary, which must have unique keys), it is a dictionary with one key for an array containing several small individual dictionaries.

    #1031144
    Halle Winkler
    Politepix

    There is now a Swift 3 tutorial for RuleORama: https://politepix.com/openearsswift-tutorial/

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