Cloud Development Kit

Using "enableOutOfLexicon" with 'textInputType':'MULTI_LINE_TEXT'

In the existing CDK, we can use "enableOutOfLexicon=True" with 'textInputMode':'ISOLATED' and 'textInputType':'CHAR'.
Is there any provision where we can use "enableOutOfLexicon = True" with 'textInputMode':'MULTI_LINE_TEXT' and 'textInputType':'CURSIVE'?


Dear Abhishek,

thank you for contacting us.

Currently, what is the reason you are using the "enableOutOfLexicon=True" ? Are you using your own custom lexicons?

Indeed, if not, by default the "TEXT" resource is used, which already has an out of lexicon capability.

Otherwise, normally the "enableOutOfLexicon = True" can also be set with default mode on text CDK which is  'textInputMode':'MULTI_LINE_TEXT' and 'textInputType':'CURSIVE'.

Let us know if this is not the case.

Best regards,

Olivier

Hi Olivier,

    Yes we are using our own custom lexicon in which we have written some names like if it is "Abhishek Tiwari", it has been written in that Lexicon in a way that Abhishek and Tiwari are in different lines. We have followed the pattern of writing a single word in a single line in that Lexicon. So whenever we give strokes to the api in which Abhishek Tiwari is written along with the lexicon res file name, it only recognizes the result as Abhishek and not the whole "Abhishek Tiwari".

I had tried sending "TEXT" as resource in the array of userResources field, but here is the error:

{u'result': {u'status': u'error', u'resourceName': u'TEXT', u'email': u'abhishek.tiwari@informds.com', u'accountCreationDate': 1494831740531, u'error': u'UserResourceNotFoundException'}}

I was sending this json as a payload :

{

     'type':'start',

     'textParameter':{

        "textInputMode": "CURSIVE",

        'userResources': ["names_single_line"],

        'language':'en_US',

        "textProperties": {

          "textCandidateListSize": 3,

          'enableOutOfLexicon':True

        }

     },

     'inputUnits':[

        {

           'textInputType':'MULTI_LINE_TEXT',

           'components': paths

       }

     ],

     'containerId':'form1',

     'containerType':'FORM'

  }

and I got this error :

{u'result': {u'status': u'error', u'message': u'enableOutOfLexicon is only valid with ISOLATED mode', u'error': u'IllegalRecognizerParameterException'}}


Dear Abhishek,

thank you for the explanation.

First, let me explain how a lexicon works:
-When creating a lexicon, you have on entry per line.
-You can only recognize one entry at a time.
=> For this reason, when writing "Abhishek Tiwari", it will not find both terms bu only one, "Abhishek" in your case.

The solution consists in using a grm, which allows to "loop" over a lexicon.

This can be done as follows:
'textParameter':{

        "textInputMode": "CURSIVE",

        'userResources': ["names_single_line"],

        'language':'en_US',

...

contentTypes:["grm"]       


     },


Also, if you want to be able to recognize any other words belonging to our "text" resource, you can add it the same way:
contentTypes:["grm", "text"]

This way, you should not need using the enableOutOfLexicon property.

Let us know if this helps.

Best regards,

Olivier

Hi Olivier,

     I am sending this payload :

{

     'type':'start',

     'textParameter':{

        "textInputMode": "CURSIVE",

        'userResources': ["names_single_line"],

        'language':'en_US',

        "textProperties": {

          'contenttypes':["grm"],

          "textCandidateListSize": 3

        }

     },

     'inputUnits':[

        {

           'textInputType':'MULTI_LINE_TEXT',

           'components': paths

       }

     ],

     'containerId':'form1',

     'containerType':'FORM'

  }


and getting the following error:

{u'result': {u'status': u'error', u'message': u'Can not deserialize instance of java.lang.String out of START_ARRAY token\n at [Source: java.io.ByteArrayInputStream@7124ef39; line: 1, column: 11434] (through reference chain: com.myscript.backend.recognition.json.api.text.simple.SimpleInputTextWsBean["textParameter"]->com.myscript.backend.recognition.json.api.text.common.input.TextParameterWsBean["textProperties"]->java.util.LinkedHashMap["contenttypes"])', u'lineNumber': 1, u'colNumber': 11434, u'error': u'ApiJsonParsingException'}}



Dear Abhishek,


Currently, 'contenttypes':["grm"] should not be set inside textProperties but just inside textParameter.


Let us know if this doesn't work.


Best regards,


Olivier

Hi Olivier,

   I have done rhe changes and now I am sending this payload:

{

     'type':'start',

     'textParameter':{

        "contenttypes":['grm'],

        "textInputMode": "CURSIVE",

        'userResources': ["names_single_line"],

        'language':'en_US',

        "textProperties": {

          "textCandidateListSize": 3,

        }

     },

     'inputUnits':[

        {

           'textInputType':'MULTI_LINE_TEXT',

           'components': paths

       }

     ],

     'containerId':'form1',

     'containerType':'FORM'

  }


Still I am not getting the answer:

{u'result': {u'status': u'error', u'message': u'Unrecognized field "contenttypes" (class com.myscript.backend.recognition.json.api.text.common.input.TextParameterWsBean), not marked as ignorable (8 known properties: "textInputMode", "subsetKnowledges", "language", "userResources", "resultDetail", "userLkWords", "textProperties", "contentTypes"])\n at [Source: java.io.ByteArrayInputStream@336d1d86; line: 1, column: 11404] (through reference chain: com.myscript.backend.recognition.json.api.text.simple.SimpleInputTextWsBean["textParameter"]->com.myscript.backend.recognition.json.api.text.common.input.TextParameterWsBean["contenttypes"])', u'lineNumber': 1, u'colNumber': 11404, u'error': u'ApiJsonParsingException'}}

Dear Abhishek,


Currently, the error is the following: Unrecognized field "contenttypes".


You should then replace "contenttypes" by "contentTypes".


Best regards,


Olivier

Thank you Olivier. That fix works.

Login or Signup to post a comment