🎨 Cross-Field Highlighter addon - spotlight word in text [support thread]

Hello all, I’d introduce a new addon for language learners.

Please, share your feedback in this topic.


Introduction

Cross-Field Highlighter takes word or collocation from the source field and highlights it in the destination fields for better readability:


Features

Highlight
  1. CFH takes word from the source field and highlights it in the destination fields.
  2. Supported formats: Bold, Italic, Underlined, Yellow Background.
  3. Word endings can differ: e.g. source word study will be also highlighted in forms of studies, studied, studying, etc.
  4. Collocations are supported: if the source field contains several words (collocation), all these words will be highlighted excluding stop words.
  5. Stop words: given stop words will be excluded from the source field (e.g. stop words a from a cat will be treated as cat).
  6. Case-insensitive: the source collocation can be in any case.
  7. Non-space-delimited languages (Japanese, Chinese, Thai, etc.) are supported.
  8. Idempotence: repeating highlighting the same notes doesn’t duplicate highlighting.
  9. HTML tags are skipped from highlighting.
  10. Highlighting notes selected in Browser or current note in Editor.
  11. Shortcut support (“Ctrl+Shift+H” by default)
Erase
  1. CFH removes previously added highlightings from fields.
  2. CFH marks its own formatting, so it can erase exactly only its formatting and preserve other formatting.
  3. Erasing notes selected in Browser or current note in Editor.
  4. Shortcut support (not set by default)
Show in Browser
  1. Show all highlighted notes
  2. Show notes modified by the latest run

Remarks

  • Current version is tested mostly for English and little for Japanese. If it doesn’t work correctly for your language, leave a comment.
  • If you’re going to use this addon, please consider rating it on the addon page. It shows that it’s worth continuing to improve it.

Screenshots

Browser menu

Buttons in Editor

Highlight dialog

Supported formats

Languages without spaces (Japanese, Chinese, Thai, etc.)


Highlighting progress

Highlighting statistics

Erase dialog (removes previously added highlighting)

Addon configuration

About addon

Test cases


Links

Unit-tests Quality Gate Status Coverage

4 Likes

New release of Cross-Field Highlighter addon (v0.2.1):

  1. Support of languages without spaces (Japanese, Chinese, etc.)

1 Like

New release of Cross-Field Highlighter addon (v0.4.0):

  1. Add “Highlight” and “Erase” buttons to Editor. These buttons open the highlight/erase dialog for current note only.

1 Like

New release of Cross-Field Highlighter addon (v0.5.0):

  1. Support of furigana
  2. Show number of selected notes in Highlight and Erase dialog
  3. Show number of processed notes in progress dialog

Example of using furigana

Original text:

Highlight dialog:

Highlighted text:

2 Likes

Great work! I’m not sure it works for me personally though, as I use brackets to show furigana with this addon: https://ankiweb.net/shared/info/678316993.

So the raw text would look like this: “屋台[やたい]” (always with a space in front of every word with a kanji).

The weird thing is that if I highlight a word manually, it works just fine. But if I use your addon to do the exact same thing it doesn’t work right. The word does get highlighted, but the furigana won’t show correctly. It will still look like this. “屋台[やたい]”

Another problem I have is that all other brackets used for other words in the sentence get highlighted too.

1 Like

New release of Cross-Field Highlighter addon (v0.6.0):

  1. Improved processing of punctuation marks

@Xirai , thank you for reporting!
In this update I fixed some issues related to processing punctuation marks (including square brackets in furigana). Please, check that it works for you.

Another problem I have is that all other brackets used for other words in the sentence get highlighted too.

This problem was fixed also.

(always with a space in front of every word with a kanji)

Are there any problems with spaces?

No, I just thought it might be relevant :slight_smile:

Still doesn’t work right :sweat_smile: example:

I think the brackets for the target word also need to be highlighted.

here’s the raw text for this card if it’s any help:
夏[なつ]祭[まつ]りね 花火[はなび]を 見[み]たりね 屋台[やたい]でたこ 焼[や]きを
And target word:
屋台[やたい]

1 Like

New release of Cross-Field Highlighter addon (v0.7.0):

  1. Highlight entire collocation (target word) first

@Xirai, that’s a good point. I updated the addon, so it tries to highlight entire target word first. It covers the case with furigana brackets:

1 Like

Thank you for all the updates! I noticed a couple of things after the new update.

  1. Sometimes other parts of the sentence get highlighted too. I see this can be useful for English but I don’t see the use for it for Japanese personally.
    example:


    raw sentence: 新[あら]たな 能力[のうりょく]を 生[う]み 出[だ]した!
    Target word: 新[あら]た

  2. It doesn’t work right when the word in the sentence use a different form. Here, the target word is “沸かす”. But in the sentence it’s written like this: “沸いてる”. I’m not sure if you can do anything about that though.
    example:


    Raw sentence: お 風呂[ふろ]も 沸[わ]いてるよ
    Target word: 沸[わ]かす

1 Like

Hi @Xirai , thanks for mentioning these cases!


  1. Sometimes other parts of the sentence get highlighted too.

The target word 新[あら]た is broke down (tokenized) by punctuation marks (square brackets in this case) into tokens:

  • 新[あら]た
  • あら

Then each token is highlighted in the text individually.
There is no special logic for furigana.
Unfortunately, in this case, I can’t see an ability to distinguish the 2nd to skip it. Language processing is a complex task where false-positive and false-negative matches sometimes happen. No magic :slightly_smiling_face:


  1. It doesn’t work right when the word in the sentence use a different form.

It requires using morphological analysis (word dictionaries) to support word forms for Japanese language. Current addon version relies on regular expressions only.

For English, word forms are handled by replacing 2 last characters (for words longer 3 symbols). E.g. studystu* which matches study, studies, studying, studied, etc. But it doesn’t work for Japanese.

Maybe I’ll add morphological analysis in future versions, but in v1 I can provide only regular expressions.


Despite I can’t fix these 2 cases, please, proceed reporting any anomalies in highlighting or user interface. They allows me to fix issues I can’t mention with my dataset.

1 Like

If you like this addon, please, like it on the addon page.

New release of Cross-Field Highlighter addon (v0.8.0):

  1. Show notes modified by the latest run

During highlighting or erasing, CFH addon marks modified notes with tag cross-field-highlighter::modified-by-latest-run.
Then you can see modified notes in Browser:

If you want to turn off this feature or rename the tag, you can do it in the addon configuration:

If you like this addon, please, like it on the addon page.

New release of Cross-Field Highlighter addon (v0.9.0):

  1. Add hotkeys for buttons in Editor

You can change or disable hotkeys in addon configuration:

1 Like

This is a fascinating and useful add-on.

Q: Does this allow for more than one highlighting rule in the same card type?

The use case is a vocabulary card with 2 sources (L1 and L2) and supporting sentences in both L1 and L2. For example:

Lex1: house
Lex2: casa
S1: My house is your house.
S2: Mi casa es su casa.

Thanks.

2 Likes

@dpgrant , thank you!

I’m afraid this use-case can’t work in current addon version (v1).

However, in version v2, I think to implement so-called “presets” where user can configure settings (one or several) for each note type and then the addon will be able to highlight notes automatically after editing note. This feature can cover your case.
Existing Browser menu will be preserved also.
Unfortunately, I can’t give any v2 release dates for now.

Thank you Alex. Looking forward to it.

1 Like

If you like this addon, please, like it on the addon page.

New release of Cross-Field Highlighter addon (v0.10.0):

  1. Add “Configuration…” menu item
  2. Minor fixes in highlighting algorithm

1 Like

If you use this addon, please, rate it on the addon page.

New release of Cross-Field Highlighter addon (v0.11.0):

  1. Always read configuration from the config file.
    Don’t need to restart Anki if configuration was changed. Some settings (like hotkeys) require just to close and open the Browser.
  2. Add “About…” menu item

1 Like

If you use this addon, please, rate it on the addon page.

New release of Cross-Field Highlighter addon (v0.12.0):

  1. Publish test cases for highlighting algorithm: link
  2. Fix bug: note type combo box was empty sometimes
  3. Adjust the highlighting algorithm

If you use this addon, please, rate it on the addon page.

New release of Cross-Field Highlighter addon (v1.0.1):

  1. The 1st stable release (the beta warning was removed)
  2. Shortcuts work not only in Editor, but in Browser also
Shortcuts in Browser

Shortcuts in Editor

You can change or disable shortcuts in Configuration

If you use this addon, please, rate it on the addon page.

New release of Cross-Field Highlighter addon (v1.1.0):

1. Add 'Select all' and 'Select none` buttons

2. Disable 'Start' button if no destination fields are selected

  1. Align UI elements
  2. Fix error when no notes are selected in Browser