ssricardo / anki-plugins

Contains a set of addons for the open source application Anki Desktop
95 stars 20 forks source link

fill-the-blanks: Enhanced diffs for incorrect answer review #130

Open lightmotive opened 1 year ago

lightmotive commented 1 year ago

Hello @ssricardo,

What do you think about enhancing the diffs for wrong answers using Google's Diff-Match-Patch set of modules that are available for Python?

Output Example

Compare Expected content with Actual cnt plus...

...

lightmotive commented 1 year ago
<del style="background:#ffe6e6;">Expected</del>
<ins style="background:#e6ffe6;">Actual</ins>
<span> c</span>
<del style="background:#ffe6e6;">o</del>
<span>nt</span>
<del style="background:#ffe6e6;">ent</del>
<ins style="background:#e6ffe6;"> plus</ins>

I would be happy to collaborate with you through a patch branch when you have time, e.g.:

Thanks for your consideration!

lightmotive commented 1 year ago

Update: I have implemented a DMP-based diff solution that works well for the Multi-Line Type Answer Box add-on. Associated branch: README demonstrates the benefits, including Anki dual-diff vs DMP semantic diff (customized HTML) output comparisons.

Based on the comparisons in that README, would you consider DMP's semantic diff an improvement over Anki's dual-block output? How about semantic diff in this fill-the-blanks add-on in place of the current correct (typed)? This add-on would need to use inline formatting and, perhaps, a red/green bottom border. Using a bottom border indicator, we can also retain the original formatting when answered correctly.

Because I liked the approach with type multi-line cards so much, I decided to implement a prototype for fill-the-blanks. Here's a visual overview:

When answered incorrectly

image
Type Cloze Enhanced Diff Prototype: instead of <b><span style="color: rgb(255, 170, 0);">correct</span> <span style="color: rgb(255, 0, 0);"><strike>(typed)</strike></span></b>, how about <b>{{c1::correct}}</b>?
image

When answered correctly

image
Type Cloze Enhanced Diff Prototype: instead of always showing <span style="color: rgb(0, 170, 0);"><b>correct</b></span> answers as <span style="color: rgb(0, 170, 0);">green text</span>, how about using a green bottom border and retaining original formatting? E.g., <b>{{c1::<span style="background-color: rgb(255, 255, 10);">correct</span>}}</b>.
image

I'll await community feedback and a go-ahead from Ricardo before doing further work on this issue. In the meantime, the prototype code I'm currently using with my daily recall practice is available in my fork's patch-enhanced-diff branch: fill-the-blanks/src.

ssricardo commented 1 year ago

Hey Andre! Thanks for all this! I'm quite busy now, so I might take some days/weeks to check this, ok?! But I'll do it later...

lightmotive commented 1 year ago

Sure, Ricardo, no rush, and thanks for your consideration! I realize this would be a significant change that demands consideration and discussion before moving beyond the prototype. If accepted, significant unit test changes and additions will be necessary (I would help with that if you wish).

The delay will also give me more time to discover potential issues and minor enhancements 🧐