Results 1 to 3 of 3

Thread: [RESOLVED] Load grammar from project reference

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2015
    Posts
    2

    Resolved [RESOLVED] Load grammar from project reference

    I’m currently loading a grammar file using a static filename. This works but I need to start loading the file as a project resource. I can add the file as a project resource but can’t figure out how the load the resource string to the grammar. Any suggestions are greatly appreciated.

    Code:
    'Current load grammar line
    reco.LoadGrammar(New Recognition.Grammar("C:\Users\jc11834\Desktop\TV Grammar.xml"))

  2. #2
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,232

    Re: Load grammar from project reference

    Hi and Welcome to the Forum,

    When you add a file as a Resource in your project then the way to read is back is to just assign the file to basic string variable, such as:-

    vb.net Code:
    1. Dim fileContents As String = My.Resources.YourXMLFileName

    However, it’s your Grammar Class that needs the most work. At the moment you are passing a Filename through the Classes Constructor which then reads the file and returns an object of type Grammer which is then used in your LoadGrammer Method. What you will need to do here is to add an Overload to your existing Constructor which accepts a String Variable, processes the contents of that String and finally returns an object of Type Grammer. Once done you could then use your LoadGrammer Method in the following manner:-

    vb.net Code:
    1. reco.LoadGrammar(New Recognition.Grammar(My.Resourses.YourXMLFileName))

    Hope that helps.

    Cheers,

    Ian

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2015
    Posts
    2

    Re: Load grammar from project reference

    Perfect! Thank you Ian!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width