Bookmarklet to extend LLN/LLY - custom sentence tokenization and analysis

I was looking for a way to extend LLN/LLY plugin functionality so that I can use an external website to analyze the structure of a Thai subtitle.

I finally ended up just creating a very simple bookmarklet which takes the selected subtitle text and then sends it as an input to another website (via URL and query parameter). The result/response opens up in a separate tab.

I am sharing my bookmarklet, as it might be useful to other people. I think the same approach would also work for other languages such as Chinese, Japanese and Korean.

In order to use this bookmarklet, you just need to create a shortcut in your browser (ideally in the shortcut bar at the top). You then just need to copy the following text and replace to replace the URL portion of the bookmark.

Here is my very simple bookmarklet:

javascript:void(window.open("https://www.thai2english.com/search?q="+document.getSelection(),%20%20’My_Window_Id’ ))

In my case, I am sending the selected input to the website “www.thai2english.com”. You can replace this website with whatever website you want to use in order to do external/additional processing on the selected text.

In my case (Thai sentence context), the external processing does the following:

  • Breaks down the sentence into component words (Thai tokenization)
  • Provides definition(s) of each of the words
  • Provides IPA transliteration of each word (and of the whole sentence).

I have found this add-on very useful when the default tokenization provided by LLN/LLY is faulty (happens only in a minority of cases) and/or when I want to look up alternative definitions for one of the words in the sentence.

Its also possible to force the results to be opened in a new browser (rather than a tab), by slightly modifying the bookmarklet:

javascript:void(window.open("https://www.thai2english.com/search?q="+document.getSelection(),%20%20’My_Window_Id’,%20%20"height=500,width=500"))

In the future, it would also be great to be able to associate such a custom action to a “button” next to each subtitle (in the subtitle table view).

1 Like

Nice. I wonder if it would be possible to use thai-language.com, but I am not sure they provide anything other than POST requests.