Closed DrN8r closed 4 months ago
Hey @DrN8r !
Wasn't it working for you? I just tested those chars that you mentioned, and it seems to work fine.
Just a detail: when you change the parameters for the add-on, you need to restart Anki to take effect
What i mean is that when i type in the answer without these chars the feedback shows incorrect answer (red).....it doesn't ignore them.
For example....the word in blank is ,, știință "... i want the feedback to say correct (green) if i type in both [ stiinta ] and [ știință ].
I tried other chars like é and ù, from french and i have the same problem...feedback is red if i type in e and u. Ignore accents is set on true.
Updated to version 24.04.01, this problem still persists. Couldn't find a way to ignore chars like ș,ț,â,ă,î in blanks.
here s an example with the char ă
Also tried rewriting the code in fill-blanks.js file using chatgpt, but no luck so far.
Finally figured it out with chat gpt, i modified the handler.py file, adding extra line of code. Feels so good!
import os import re from bs4 import BeautifulSoup import html import unicodedata
def normalize_text(text): """Normalize the text by removing diacritics.""" return ''.join( c for c in unicodedata.normalize('NFD', text) if unicodedata.category(c) != 'Mn' )
class TypeClozeHandler:
def format_field_result(self, given: str, expected: str):
given = given.strip()
expected = expected.strip()
# Normalize the given and expected answers to ignore diacritics
normalized_given = normalize_text(given)
normalized_expected = normalize_text(expected)
if normalized_given == normalized_expected:
return "<span class='cloze st-ok'>%s</span>" % html.escape(expected)
if self.isIgnoreCase and normalized_given.lower() == normalized_expected.lower():
return "<span class='cloze st-ok'>%s</span>" % html.escape(expected)
return "<span class='cloze st-expected'>%s</span> <span class='cloze st-error'>(%s)</span>" % (html.escape(expected), html.escape(given))
# ... (other methods)
Hey, that's great! Really! Especially as I'm not having the time for it currently.
I'll try to integrate that and release a new version later. But oc, great that it works for you already!
Hello Ricardo, i'm noob in coding and couldn't find a solution to this. The romanian language uses this diacritics (ș, ț, â, ă, î) in its alphabet which are very common in words and it would be very usefull to ignore them when typing the answer. Setting the option in config "feedback-ignore-accents": true didn't work with these characters. I also searched in the add on files in order to find something to modify, but it's over my head. If you ever have the time to take a look into this matter it will help me a lot with my work. Thank you !