avatar Bite 349. Writing better Spanish

Bob is a lazy typer and often forgets to accentuate his Spanish 😅

For example instead of Cuando era pequeño me gustaba jugar en la vía he would write: Cuando era pequeno me gustaba jugar en la via.

But Python to the rescue 🐍 ... help him out by finishing the get_accentuated_sentence() function that receives a text as input argument and accentuates it using the provided (downloaded) Spanish dictionary stored in the SPANISH_WORDS constant (a list of Spanish word strings).

Take a look at the unicodedata (Standard Library) module in order to make the link "accentuated -> not-accentuated" word (e.g. éxito -> exito), that should make it easier to complete this exercise 💡

By the way, note we kept the scope pretty simple here. Plural words nor verbs are expected to work. And there are some false positives, e.g. una (a) -> uña (nail). So the solution is not very real-world applicable. To meet that criteria we would have to implement stemming to recognize all forms of a word, even the conjugated ones.

However we think this is still a useful exercise to sharpen your coding skills, so good luck and keep calm and code in Python 💪

 

Login and get coding
go back Intermediate level
Bitecoin 3X

13 out of 15 users completed this Bite.
Will you be Pythonista #14 to crack this Bite?
Resolution time: ~91 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 5.0 on a 1-10 difficulty scale.
» Up for a challenge? 💪

Focus on this Bite hiding sidebars, turn on Focus Mode.
We use Python 3.8