Automatic text completion for online study

Hi everyone,

So this is probably very complicated but I’m asking anyway: I’m planning to run an online experiment where subjects would type words in response to visual stimuli. To make trials shorter, I would like to suggest words based on the letters subjects are typing (e.g. in a lighter shade and subjects can press enter to accept the suggestion; using machine learning performed on large text corpora). Obviously, I would need to edit the javascript code. I’ve done some minor modifications to the JS code for a previous experiment, but I’m still very much of a beginner and barely understand javascript logic. I have found a JS tool (https://github.com/starlordvk/Typing-Assistant) that seems to be able to do this. However I’m a bit lost at how I would implement this in the PsychoJS code, if at all possible? Can anyone point me in the direction, e.g. where I would put the different code parts?

Thank you!!

Laurent

Hi Laurent,

I took a quick peek at the tool you mentioned. To be honest, it will be quite challenging to implement, since you not only need to incorporate the JS in PsychoJS, but also set up your on Python server. Making that even more challenging is that the code inside of this repo isn’t “production-ready” as we call it; it’s more of a prototype.

I’d recommend not using it as is, or at the least, don’t bet too much on it. There is one venue I can suggest: get in touch with the developer to ask if he would like to guide you through the process. Often developers love to guide people through adopting their pet projects. But even then, beware, could be quite a rough ride that requires a lot of work.

Best, Thomas

Hmm yeah ok. I’ll get in touch with him or try to find another tool…

Thank you!

Laurent

I have a suggestion for you. I’ll make some assumptions here, so I might miss the mark though. If you’ll score the words on some set of dimensions, you could look into norm studies. For instance, imagine you’d rate the words on valence, arousal, and dominance. You could take a collection of words from a study such as this one. The moment a series of letters typed by the participant matches the beginning of a single word of the collection, offer that word as autocomplete.

Thank you for your suggestion. I’m thinking of something similar, but using all English words. I found another tool that seems more promising (https://github.com/asterics/predictionary) and an associated list of English words with their frequencies. When letters are typed, I could collect them in the trial routine that’s run every frame and feed it to the algorithm to find the most probable word and show this on the next frame… Or something like that!

Predictionary looks packaged and production-ready, so yeah, this could work. Here are two more pointers:

  • This library would run completely on the computers of your participants, if you put a lot of words in it, that might be a bit too heavy. I recommend piloting a bit on the types of devices you’d like to include.
  • See the loading part in my eye-tracking demo for how to include a JS library in a PsychoJS experiment. https://gitlab.pavlovia.org/tpronk/demo_eye_tracking
1 Like

Great thank you!

1 Like