Interactive Ink

Answered

Creating lexicon files from iOS app.

Is there a way to create lexicon files from the app itself? Platform: iOS

Best Answer

Dear Sourav,


We just released the 1.3 version of the iink, which now allows on-device resources compilation: https://developer.myscript.com/docs/interactive-ink/1.3/android/advanced/build-custom-resources/#on-device


We then recommend you upgrade to this latter one.


Best regards,


Olivier


Dear Sourav,


currently, we though of the following 2 possibilities:

-At startup, you deploy the conf file and default resources in the application support directory. You save your resource in the latter. All you need is to adapt the AddResource lines of the conf file.

-When saving your custom resource, you get the path of the application support using the iOS api (e.g. https://stackoverflow.com/questions/8430777/programmatically-get-path-to-application-support-folder/34207269) ;  you then update your conf file adding a line with the path of your custom resource.


Best regards,


Olivier

Sorry I didn't provide enough context.

I am using the iOS SDK. I am saving the res file in Application Support Directory which resides in the app container of the iOS Device. The app container id is randomly generated on every new device. So, the problem here is that I can't mention a static path in my conf file.

The exact piece of swift code is this:

 

guard let filePath = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).first else { return }

try! assetBuilder.store(filePath + "my-resource.res")

Dear Sourav,


Please find an explanation.


Let's say you stored your resource "myResource.res" into the "/sdcard/MyScript/MyResources/" directory, and you stored the other MyScript resources and conf files as follows:


/sdcard/MyScript/conf/en_US.conf

/sdcard/MyScript/en_US/en_US-ak-cur.res

/sdcard/MyScript/en_US/en_US-lk-text.res

/sdcard/MyScript/MyResources/myResource.res


You can then set the configuration-manager.search-path as follows: "/sdcard/MyScript/conf/"


in your conf file, you can add the textwithMyResource configuration as follows:

Bundle-Version: 1.0

Bundle-Name: en_US

Configuration-Script:

 AddResDir ../resources/


Name: text

Type: Text

Configuration-Script:

 AddResource en_US/en_US-ak-cur.res

 AddResource en_US/en_US-lk-text.res

 EnableAlienCharacters

 SetTextListSize 1

 SetWordListSize 5

 SetCharListSize 1


Name: textwithMyResource

Type: Text

Configuration-Script:

 AddResource en_US/en_US-ak-cur.res

 AddResource en_US/en_US-lk-text.res

 AddResource MyResources/myResource.res

 EnableAlienCharacters

 SetTextListSize 1

 SetWordListSize 5

 SetCharListSize 1

 

In order to call the "textwithMyResource" configuration, just set it as follows: conf.setString("text.configuration.name","textwithMyResource");


Best regards,


Olivier

I was able to store it now. Using a path in my application support directory. 

I am not able to figure out a way to load the stored res file from the application support directory.

Hey Oliver,

Compiling was a success. It's just the storing line which is throwing exception. I just call this line of code after compilation try assetBuilder.store("my-lexicons.res")

Do I need to provide a complete path?

How will I load this `.res` file later in my configuration using the same path?

Dear Sourav,


Thank you for the update.


I just tried to compile and store your lexicon and it worked out of the box! I could compile and store it without any difficulty.


First, did you compile it as follows: recognitionAssetsBuilder.compile("Text Lexicon", lexicon);


Then, when storing it, which path do you provide? Do you have the necessary rights to store on it?


Indeed, the io error is a system error to indicate the file cannot be stored. It is then more you are trying to save the file in a directory where you do not have the rights or something this way. You should start investigating this way.


Best regards,


Olivier


Hi, 

I am getting this error when I try to store a compiled lexicon

Error Domain=Interactive Ink SDK Error Domain Code=1 "Error, -[IINKRecognitionAssetsBuilder store:error:]::94 io error" UserInfo={NSLocalizedFailureReason=Error, -[IINKRecognitionAssetsBuilder store:error:]::94 io error}

My lexicons string for compilation:

"-\n--\nA\nA-\nA01\nA1\nA10\nA11\nA2\nA3\nA4\nA43\nA5\nA5555566\nA6\nA7\nA8\nA9\nAcne\nAlltta\nAngiogram\nAngiogram 6.5\nAnuj John Cena\nAnything\nAsh\nB\nBuddy\nCF 01\nChief complaint Edit 1\nChief complaints 2\nCough\nCrocin\nE\nJohn Bradshaw\nJohn Bradshaw Layfield\nJohn n Niko\nI\nKjhkhkjh\nKufkufkukuligljgkjflfiyu was saturated \nNew Complaint\nNewer Complaint\nPimples\nPlaster\nRavi\nSave me!\nTab. Crocin I-o-I X29\nTemp 01 01\nTim Paine\nType 1\nYay Yay Yay-I\nchief complaints\ndoctor\near pain\nh\nheadache 40\nhello\nin\nlatest complaint\nm\nn\nnell\nnose block\nor\nrash\nstarts writing\nte yo\ntest\ntest1\nw\n~"


The error fails to describe the root cause. Can you help me with this?

Answer

Dear Sourav,


We just released the 1.3 version of the iink, which now allows on-device resources compilation: https://developer.myscript.com/docs/interactive-ink/1.3/android/advanced/build-custom-resources/#on-device


We then recommend you upgrade to this latter one.


Best regards,


Olivier

Dear Sourav,


thank you for your question.


At present, it is not possible to compile a lexicon on the device. This will be available in the coming version, planning in the coming weeks.


Anyway, I keep you updated when it is available.


Best regards,


Olivier