The task is to to compete for the shortest regex (in bytes) in your preferred programming language which can distinguish between English and Spanish with minimum 60%
90%
accuracy.
Silvio Mayolo's submission (pinned as Best Answer
) has secured his spot as the winner of original contest against any chance of being contested. In order to provide room for further submissions, he has generously allowed the scoring requirement to be pushed to 90% accuracy.
Links to wordlists have been replaced due to concerns voiced in the comments.
The following word lists (based on these) must be used: English, Spanish
The Spanish wordlist is already transliterated into ASCII, and there is no word present in either which is also present in the other.
A naive approach to distinguishing Spanish from English might be to match if the word ends in a vowel:
[aeiou]$
i
9 bytes
Here's a live example, where 6
of 8
words are successfully identified, for 75%
accuracy:
const regex = /[aeiou]$/i;
const words = [
'hello',
'hola',
'world',
'mundo',
'foo',
'tonto',
'bar',
'barra'
];
words.forEach(word => {
const match = word.match(regex);
const langs = ['English', 'Spanish'];
const lang = langs[+!!match];
console.log(word, lang);
});