Text

Answered

Custom resources

Hi , 

I have custom resources in my account but I use custom resources I am getting following response :

{'instanceId': '3d67f2aa-4100-45f1-a923-3eb0cbbb6f1f',
 'result': {'textSegmentResult': {'selectedCandidateIdx': -1}},
 'type': 'textResult'}

Following are my request parameter .

{'textParameter': {'textProperties': {'wordCandidateListSize': 3, 'characterCandidateListSize': 1, 'textCandidateListSize': 3}, 'resultDetail': 'CHARACTER', 'userResources': ['swiss'], 'textInputMode': 'CURSIVE', 'language': 'en_US'}, 'containerId': 'form1', 'inputUnits': [{'textInputType': 'MULTI_LINE_TEXT', 'components': [{'type': 'stroke', 'y':................

But when I request without resources then I am getting correct response . 

Please let me know if I am doing some thing wrong or even if request format has changed .

Thanks and regards 

Mukesh Kumar


 


Best Answer

Dear Mukesh Kumar,


Thank you for your update.


The returned result is empty because the recognition engine tries to find recognition candidates from your custom ressource 'swiss' lexicon only. 

I guess you used our ready-to-use swiss example, so as your ink seems to consist in two letters 'p' and 'D'  and as there is no candidate from the swiss lexicon matching this input, the returned result is empty.


In you first test, as you don't specify any resource, the engine uses the default text lexicon to perform the recognition, therefore the recognition output is not empty.


If you want to add the 'swiss' lexicon to the default text lexicon, you must specify that your data is a text content type by adding the following textParameter

"contentTypes": ["text"], so your request data would look like:

 {'textParameter': {'textProperties': {'wordCandidateListSize': 3, 'characterCandidateListSize': 1, 'textCandidateListSize': 3}, 'resultDetail': 'CHARACTER', "contentTypes": ["text"], 'userResources': ['swiss'], 'textInputMode': 'CURSIVE', 'language': 'en_US'}, 'containerId': 'form1', 'inputUnits': [{'textInputType': 'MULTI_LINE_TEXT', 'components': [{'type': 'stroke', ... ]}]}], 'type': 'start', 'containerType': 'FORM'}

This way the recognition engine will use both lexicons: default text one and you custom 'swiss' one.


Also, we notice that you are using the V3 WebSocket API which is now deprecated. 

So we strongly recommand you to use the V4 API, specially if you are starting a new project. Please, check this section of the documentation for V4 API:

https://developer.myscript.com/docs/interactive-ink/1.3/web/websockets/messages/


Best regards,


Gwenaëlle









Dear Mukesh Kumar,


Thank you for your request.


In order to provide you with a better support, can you share with us your complete request (without the application key)  and indicate which API your are using?


Best regards,


Gwenaëlle



Hi , 

Complete request data:

{'textParameter': {'textProperties': {'wordCandidateListSize': 3, 'characterCandidateListSize': 1, 'textCandidateListSize': 3}, 'resultDetail': 'CHARACTER', 'userResources': ['swiss'], 'textInputMode': 'CURSIVE', 'language': 'en_US'}, 'containerId': 'form1', 'inputUnits': [{'textInputType': 'MULTI_LINE_TEXT', 'components': [{'type': 'stroke', 'y': [51.2, 51.1, 51.0, 51.0, 51.1, 51.1, 51.2, 51.4, 51.7, 52.0, 52.3, 52.3, 52.4, 52.3, 52.2, 51.9, 51.6, 51.5, 51.1, 50.9, 50.8, 50.8, 50.8, 50.8, 50.8, 50.9, 51.0, 51.1, 51.2, 51.3, 51.4, 51.6, 51.8, 51.8, 51.8, 51.7, 51.7, 51.7, 51.6, 51.6], 'x': [61.9, 61.9, 61.9, 62.0, 62.0, 61.9, 61.9, 61.9, 61.8, 61.7, 61.6, 61.6, 61.6, 61.6, 61.6, 61.7, 61.7, 61.8, 62.0, 62.1, 62.2, 62.3, 62.4, 62.6, 62.7, 62.8, 62.9, 62.9, 62.9, 62.9, 62.8, 62.6, 62.2, 62.2, 62.1, 62.1, 62.1, 62.1, 62.1, 62.1]}]}], 'type': 'start', 'containerType': 'FORM'} 

I am using web-socket for request .

Thanks 



Answer

Dear Mukesh Kumar,


Thank you for your update.


The returned result is empty because the recognition engine tries to find recognition candidates from your custom ressource 'swiss' lexicon only. 

I guess you used our ready-to-use swiss example, so as your ink seems to consist in two letters 'p' and 'D'  and as there is no candidate from the swiss lexicon matching this input, the returned result is empty.


In you first test, as you don't specify any resource, the engine uses the default text lexicon to perform the recognition, therefore the recognition output is not empty.


If you want to add the 'swiss' lexicon to the default text lexicon, you must specify that your data is a text content type by adding the following textParameter

"contentTypes": ["text"], so your request data would look like:

 {'textParameter': {'textProperties': {'wordCandidateListSize': 3, 'characterCandidateListSize': 1, 'textCandidateListSize': 3}, 'resultDetail': 'CHARACTER', "contentTypes": ["text"], 'userResources': ['swiss'], 'textInputMode': 'CURSIVE', 'language': 'en_US'}, 'containerId': 'form1', 'inputUnits': [{'textInputType': 'MULTI_LINE_TEXT', 'components': [{'type': 'stroke', ... ]}]}], 'type': 'start', 'containerType': 'FORM'}

This way the recognition engine will use both lexicons: default text one and you custom 'swiss' one.


Also, we notice that you are using the V3 WebSocket API which is now deprecated. 

So we strongly recommand you to use the V4 API, specially if you are starting a new project. Please, check this section of the documentation for V4 API:

https://developer.myscript.com/docs/interactive-ink/1.3/web/websockets/messages/


Best regards,


Gwenaëlle









1 person likes this