Application Tool Kit

Acquisition of recognition candidates when a pseudo stroke is input from a program

I am developing an Android application using MyScript ATK 2.2.

I want to pass stroke information from the program to MyScript's widget in a pseudo manner and obtain recognition candidates.


Compared with passing strokes in real time, I feel that accuracy of recognition candidates that can be acquired is low.

Is there a way to input a stroke in a pseudo manner from a program so that it can obtain equivalent recognition candidates?



public CandidateInfo getCandidateInfo(List<MotionEvent> events) throws InterruptedException {


    for (MotionEvent event : events) {

        CaptureInfo captureInfo = new CaptureInfo();



        if (event.getAction() == MotionEvent.ACTION_DOWN) {


        } else if (event.getAction() == MotionEvent.ACTION_MOE) {


        } else if (event.getAction() == MotionEvent.ACTION_UP) {







    return this.api.getWordCandidates(0);


1 person has this question

Dear Takuya Okamato San,

Thank you for contacting us.

Currently, can you also try to provide with the time information in your captureInfo variable. This may also have an impact.

Best regards,

Is there some documentation for the com.myscript.atk.text package or at least for the CandidateInfo class?


Dear Axel,

thank you for contacting us.

Indeed, the CandidateInfoclass is not documented in the ATK documentation:

let us know which information you need regarding it.

Best regards,

Hello Olivier,

If I got it right, the CandidateInfo object returned by the SingleLineWidgetApi#getWordCandidates(i) method holds possible recognition results for the i-th word input into the widget. I've already set the word candidate list size to a maximum of three by calling SingleLineWidgetApi#setWordCandidateListSize(3) so that the engine will always suggest a maximum of three candidates for each word. Is this correct so far?

So for example, if I write "Hello World", I'd like to show two more possible recognition results for the latest word (maybe something like "WorID" or "worried" or whatever the engine thinks the user could have meant to write instead of world).

What I already tried: I took the text returned by SingleLineWidgetApi#getText() and split it by the Java String.slpit(regex) method to determine the number of words currently held by the widget. Then I called getWordCandidates(noOfWords) but from there on didn't get any further. My problems are:
- The selectedLabel (CandidateInfo#getSelectedLabel()) always seems to hold the  same word (the first one, if I remember correctly) even if I continue writing
 in the widget and noOfWords changes accordingly.
- All other fields (selectedCompletion, selectedInputLabel, completions, inputLabels, labels) seem to be empty all the time.

So how do I receive the Strings representing the two other recognition candidates for the last word in the widget? Is there any ranking of the candidates, like some probability value or similar?

Tanks for your help! Kind regards


 Dear Axel,

thank you for the update.

To  answer your questions:

-so that the engine will always suggest a maximum of three candidates for each word. Is this correct so far?

>>Currently, this the maximum candidates our solution is likely to return. You may have less candidates (even zero), if the widget is not able to find out any other (for example, if using very constrained lexicons).

- All other fields (selectedCompletion, selectedInputLabel, completions, inputLabels, labels) seem to be empty all the time.

>>Currently, all "completions" are returned when setting our completion and predicition options. Setting these, you should get such candidates.

-Regarding the candidates, the order is normally based on the most "probable" candidate.

Otherwise, please find the below code sample (I just developped it, so it may still contain bugs), which should normally help you get all the word segment and all candidates per segment. Let me know if it helps.

int nbWords = mWidget.getWordCandidateListSize();

for(int i=0;i<nbWords;i++)
CandidateInfo cdinf = mWidget.getWordCandidates(i);
List<String> labels = cdinf.getLabels();
String selectedLabel = cdinf.getSelectedLabel();
Log.d(TAG, "selected label" +selectedLabel);
int nbLabels = labels.size();

for(int j=0;j<nbLabels;j++)
Log.d(TAG, "label: " +i +" is " +labels.get(j));

Best regards,


Hi Olivier,
thanks for these answers and the code example. I'm starting to get it, but still have some questions.

Currently, all "completions" are returned when setting our completion and predicition options. Setting these, you should get such candidates.

How to apply these settings? As I found out, they need to be put into the connffile.conf under the item selected with

widget.configure("conffile", "item");

 How is the correct syntax for setting completion and prediction? I didn't find anything about this in the configuration reference.

I tried the code you posted by writing "Anfang ist schwer" into the widget. While writing "Anfang", the output changes as I write new characters. From the moment I finish writing "Anfang" the following text is output again and again:

Selected Label: Anfang
label: 0 is Anfang
label: 0 is Anfange
label: 0 is Ahfang
Selected Label: Anfang
label: 1 is Anfang
label: 1 is Anfange
label: 1 is Ahfang
Selected Label: Anfang
label: 2 is Anfang
label: 2 is Anfange
label: 2 is Ahfang

So, as far as I understand, the labels returned by CandidateInfo#getLabels() represent the different possible recognition results for one word. What I don't understand yet is:

- How to retrieve CandidateInfo for words other than the first one I wrote?

- What is the index passed with SingeLineWidgetApi#getWordCandidates(index) supposed to do? For me, the output seems to be the same all the time independently of what index value I pass...

Thank you for your help!

Kind regards

Dear Axel,

My apologies, as I did not provide with an accurate answer.

Fist, completion and prediction are not available with the ATK (i.e. Single Char and Single Line). ATK is fairly old, and does not have such features.

Regarding getting word candidates, forget my code sample. Instead, you should refer to the updateCandidateBar function, which for the latest word, displays all the candidates:

  private void updateCandidateBar() {
    int index = mWidget.getCursorIndex() - 1;
    if (index < 0) {
      index = 0;

    CandidateInfo info = mWidget.getWordCandidates(index);

    int start = info.getStart();
    int end = info.getEnd();
    List<String> labels = info.getLabels();
    List<String> completions = info.getCompletions();

    for (int i=0; i<3; i++) {
      Button b = (Button) mCandidateBar.getChildAt(i);

      CandidateTag tag = new CandidateTag();
      if (i < labels.size()) {
        tag.start = start;
        tag.end = end;
        tag.text = labels.get(i) + completions.get(i);
      } else {
        tag = null;


      if (tag != null) {
        b.setText(tag.text.replace("\n", "\u21B2"));
      } else {

    if (info.isEmpty()) {
    } else {
  Let us know if this helps.
  Best regards,
Dear Olivier,
thanks for your help! I got it working with the help of that. The problem was, that I had to pass the position of some character of a word as index to getWordCandidates(index) to receive CandidateInfo for exactly that word.
Kind regards,


Login or Signup to post a comment