[Userscript] Memrise Autocorrect (diacritics, punctuation, case)

It’s a great idea! Thank you very much for the script. :+1:

I tested on some of my courses and I ran into some issues with Turkish. There are some characters it changes but others it does not, and it can result in wrong answers. For example with “bekçi köpeği” if I just write in “bekci kopegi” it won’t be accepted, because the script changes the c to ç and the o to ö but not the g to ğ (=“bekçi köpegi”). “ı” and “ş” are also characters the scrip does not handle.

Another thing I experienced with some entries starting with a capital letter that it’s enough to write in the first letter and part of the word gets automatically written in. Like for example I only push the key ‘A’ and ‘Alma’ is already written in the answer field for ‘Almanya’ , or ‘Azerba’ for ‘Azerbaycan’. Can you look into this please?

Thanks for flagging up the two issues - I’ve addressed both of them in 0.0.2 :+1:

1 Like

Thank you, it works perfectly now!
(It even helps avoiding mistakes in some instances, like using the wrong synonym, when I see the characters don’t get altered by the script when they should - so I’m already loving this script!)

1 Like

Awesome! Since I dared to install some of your userscripts I enjoy this site even more. Thank you for that

1 Like

Your script is perfect for Portuguese Brasil DuoLingo course.

It uses the “strict typing” option.

Having not to use the mouse to select special characters helps me speed up 100-200 words review time.

And actually it helps quite much being able to see the “real word” when you type the text for non-strict checking courses and your answer is accepted like requested here: Show omitted accents after accepting answer

I do not really type in all the characters for the Portuguese BR Basic, PT1-7 courses on Memrise.

Thanks!

1 Like

I did a small update to get autocorrect working on alternate answers (v0.0.5)

1 Like

script has been fixed to work after a memrise update (0.0.7).

1 Like

I fixed a breaking memrise change in the latest update (0.0.10), PLUS I added something which I’ve been using for a while in my own local script but it might not be to everyone’s taste - autocorrect across spaces too! For example, I’ve been learning Spanish and the course has started having these super long sentences such as ¿qué te gusta hacer por la mañana?. With the script on I can type quetegustahacerporlamanana and the script will ‘autocorrect’ the punctuation/accents/spaces as I type.

2 Likes

Hi there, first of all thanks a lot for your work, you’re really helping lots of people !

I’m facing a problem with Russian, because lots of people have made courses with tiny " ’ " above characters to show where the stress is in the word, and it seems that auto-correct doesn’t handle any of that. So i’m pretty blocked with memrise all-typing and with auto-correct too.

Instead of writing 2 times the same stuff here you can read my 2 posts on your all-typing thread :

I tried doing the work myself but i’m really not qualified enough, so if you ever find some time to try and fix that that’s be supremely awesome. Thanks a lot ! :slight_smile:

As I mentioned in the other thread, you can try updating to the latest version (0.0.11) where the issue should be fixed.

Is there any issue with “,” or “-”?

Like “desculpar-se”

I can type “desculpar”, trying to type “-” is denied, even it is the next character in the solution, and when I type “se”, the word is finally displayed: “desculparse” but the -" never gets added or can be typed.

Same is true if I would like to type a “,” in a longer sentence.
However, when I type the next correct character of the new word behind the comma, then the “,” character is added to the sceen, like “…”.

Would have to re-test with your very latest version, as I am not sure when te autoupdate happend the last days.
My version is shown as 0.0.11, but I have no idea when it did update.

I know this “desculpar-se” thing was working before with an older version…maybe 0.1.10 or earlier broke it…not sure.

Do you have any “xxx-se” or similiar words in Spanish Cooljingle?

I haven’t come across the -se syntax in the courses I’m doing, but I tried having “desculpar-se” as a word in a private course and I was able to type the “desculpar-” without script removing that last dash which is what I think you’ve described the behaviour to be. This is using 0.0.11 which is still the latest version.

  • DuoLingo Portuguese BR by MartinPen is setup as strict-typing, if this does matter.

  • offical Memrise Portuguese PT 7: accepted non-strict-typing.

“ao meio-dia”

comma “-” still N O T working with version 0.0.11.

I have already disabled “Memrise turbo”, but now we have the Memrise “auto-accept” problem which may kick in.
But as said, the problem were before Memrise update “auto-accept” and activated “Memrise Turbo”, especially for MartinPen’s course where I recognized “desculpar-se” many times…

I might try further re-tests with ALL scripts disabled (besides “all-typing”…if the problem might come from somewhere else…who knows), e.g activated “Memrise wrong answer skips”, which probably does not work anymore anyways…

With most of the scripts on I get this when typing in the Memrise Portuguese 7 course:

autocorrect

which seems to be the correct behaviour.

Hi @cooljingle,

the last Memrise code update from Wesnesday 01/17/2018 crashed your auto correct script V0.0.11.
Tested with Firefox V52.5.3 esr with Greasemonkey V3.17.

TypeError: p is undefined[Weitere Informationen] Memrise_Autocorrect.user.js:141:1
	processInput file:///C:/MyFirefoxProfileDirectory/gm_scripts/Memrise_Autocorrect/Memrise_Autocorrect.user.js:141:1
	<anonym> file:///C:/MyFirefoxProfileDirectory/gm_scripts/Memrise_Autocorrect/Memrise_Autocorrect.user.js:130:13
	at.event.dispatch https://d2rhekw5qr4gcj.cloudfront.net/dist/js/libs-41c582fa7c13.js:1:48254
	at.event.add/m.handle https://d2rhekw5qr4gcj.cloudfront.net/dist/js/libs-41c582fa7c13.js:1:46300
	i https://d2rhekw5qr4gcj.cloudfront.net/dist/js/libs-41c582fa7c13.js:1:439737        

Tested with this course (strict-typing is forced):

Fixed: This script has also been fixed now (v.0.0.12): [Userscript] Memrise all typing

Guys please activate again, do the update check or manually re-install the latest script version (raw) from Cooljingle’s repository.


IMHO you definitely need the script for Portuguese BR 1-7 courses, as the “copy typing” screen is corrupted after the last Memrise update, does not show an on-screen clearfix keyboard anymore and Memrise does not accept the words without diacretics.

The whole sentence is marked as error / red - see pictures in “all typing” thread…

So you either need “Auto correct” or you need to configure a fully hardware Portuguese Brazil keyboard!!!

Hey man :slight_smile: May I ask that you please consider editing your post to not use the ‘f’ work?

@cooljingle

Hi,

it uses no levels:
https://www.memrise.com/course/702398/50-languages-brazilian-portuguese-no-typing

This course was - like most courses - not really designed for typing in “classic reviews” and for sure it will miss a lot of alternatives.

Nevertheless, I watered my first 50-100 words.

The original text script for Portuguese Brazil is here: https://www.50languages.com/phrasebook/en/px/

It quite often used the “/” separator between text parts.
“-” is later used in other sentences.

The above Memrise course requires that you type both parts in the input text field when the answer is checked so it is rated correctly.

I have to say that I am completely lost because not all sentences use the “/” and there is no way to really know or to remember which sentence requires the second part after the slash or that there even is a second part for the PT target.

Current stage: In the current version “Auto correct” does not automatically add the forward slash “/” when you typed the last letter followed by a blank.

Does it make any sense to have the “Auto correct” code support an auto-complete “/” when you typed the last character with or without a blank? (e.g add blank “/”)

Maybe make this configurable for a single course in the settings or directly as a hack in the code.

When you really want to avoid multiple-choice (with all the given hints) in “classic reviews” (as I usually do when I focus on RECALLING practice) it would be a great help that you see that there are more parts / alternatives to come after the first entered text part and when this is exactly expected.

It is okay for me that in the current code implementation other characters like “,” are only shown when you correctly entered the NEW letter of the next following word, before too many hints are given in the text field.

I would not mind if a comma (like a “/” forward slash) would be auto-added.
Maybe every user has different needs…

Not all English source sentences which include “/” on the English side expect the “/” for multiple parts for the Portuguese BR target, but some (several).

As there is a MP3 native recording file provided by “50 languages” which goes through multiple chapter the original text script is fixed.

Sorry Cooljingle, this is not my own course and I am not sure if editing it for any alternative field accepted words/phrases would be the better final solution.

There is not just one “50 languages” course but multiple.
All flagged as “non-typing”.
You can expect that you run into this problem even on several foreign language courses when the company uses this hardwired forward slash “/” concept.

What do you think?
Is it worth the efforts? (depending on how difficult this customization and code enhancement would be)

To be honest, so far I never have been too actively into learning this “50 language” Portuguese course on Memrise but it contains really some great phrases I am still very week in even after two years of learning on Duolingo, other Memrise courses and Mondly.

I am not sure how many learners are using your “Auto correct” userscript, but I think it may be important not to break existing functionality for those users who are used to it as it works right now.
I do not learn any Asia or harder languages with a foreign writing script than Latin, so I have no idea what the exact needs for those users will be who do.

Best regards / Viele Grüße

This kind of “type ahead” behaviour is something the script only does if the end of the answer is punctuation, e.g. ending questions with ?
One reservation I have with adding this behaviour is e.g. if the answer is a/b but a and b are individually are listed as alternatives, if I type a I may want the answer to be accepted rather than replaced with a/

Thank you for this script! If anyone is interested, I improved it a little in terms of events (compositionstart wasn’t working for example):

$(‘body’).on(’.typing input’, ‘input’, function() {
processInput();
});

$('body').on('select', function() {
    processInput();
});


function processInput () {
    var b = MEMRISE.garden.box,
        p = b.testData.correct,
        i = b.$input.input || b.$input,
        v = i.val(),
        sliceIndex = 0;

    for (let a of p) {
        if (a.indexOf(v) !== 0) {
            var aNoDiacritics = getNonDiacritics(a).toLowerCase();
            var aSimple = getNonPunctuation(aNoDiacritics);
            var vSimple = getNonPunctuation(getNonDiacritics(v)).toLowerCase();

            if (aSimple.indexOf(vSimple) === 0) {
                var noDiacriticSliceIndex = aNoDiacritics.match(new RegExp(`.*?${vSimple.split("").join(".*?")}((${punctuation.source}|\\s)+$){0,1}`))[0].length;
                var counter = 0;
                for (let i = 0; i < a.length; i++) {
                    counter += getNonDiacritics(a[i]).length;
                    if(counter <= noDiacriticSliceIndex) sliceIndex++;
                    else break;
                }
            }
        } else {
            try{
                sliceIndex = a.match(new RegExp(`${v}((${punctuation.source}|\\s)+$){0,1}`))[0].length;
            }catch(e){
                console.log(e);
                //break;
            }
        }

        if (sliceIndex) {
            var replacement = a.slice(0, sliceIndex);
            i.val(replacement);
            if(v !== replacement) {
                console.log(v);
                console.log(replacement);
                $('.typing-type-here').trigger('keydown');
            }
            break;
        }
    }
}
2 Likes