Pybites Logo

Writing better spanish

Level: Intermediate (score: 3)

Bob is a lazy typer and often forgets to accentuate his Spanish πŸ˜…

For example instead of Cuando era pequenΜƒ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 πŸ’ͺ