You are on page 1of 4

<html>

<head>

<meta charset="UTF-8">

<title>Custom Dictionary Spellchecker</title>

<style>

body {

font-family: Arial, sans-serif;

.container {

width: 80%;

margin: 0 auto;

h1 {

text-align: center;

textarea {

width: 100%;

height: 200px;

margin-bottom: 10px;

button {
padding: 10px;

border: none;

background-color: #4CAF50;

color: white;

font-weight: bold;

cursor: pointer;

button:hover {

background-color: #3E8E41;

#results {

margin-top: 20px;

#results p {

margin: 0;

#results strong { color: red;

</style>

</head>

<body>
<div class="container">

<h1>Sakatta'aa Qubee Galmee Jechoota Afaan Oromoo</h1>

<textarea id="text"></textarea>

<button onclick="checkSpelling()">Check Spelling</button>

<div id="results"></div>

</div>

<script>

const dictionary = ["maqaan", "maqaa", "kee", "koo", "eenyuu", "bulte", "oolte", "jirtaa", "eessa",
"deemi", "taa'i", "ka'i", "akkam", "nagaa", "koottu", "harka", "lama", "mana", "sa'a", "nama", "buna",
"muka", "lafa", "guddaa", "xiqqoo", "harma", "mucaa", "kufe", "gummii", "barnoota", "wal",
"madessaa", "lafa", "qabsiisuuni", "hojiile", "hojii", "irraa", "olchuun", "barumsa", "hawaata", "ta’e",
"uummu", "fi", "hawaasa", "mana", "barumsa"];

/* we use const dictionary as corpus/Corpora so words out of this one will outputed as
misspelled.

*/

function checkSpelling() {

const text = document.getElementById("text").value;

const words = text.split(" ");

let errors = [];

words.forEach((word) => {

if (!dictionary.includes(word.toLowerCase())) {

errors.push(word);

});

const resultsDiv = document.getElementById("results");

if (errors.length > 0) {

let message = "The following words are misspelled: ";


errors.forEach((error) => {

message += `<strong>${error}</strong> `;

});

resultsDiv.innerHTML = `<p>${message}</p>`;

} else {

resultsDiv.innerHTML = "<p>No misspelled words found!</p>";

</script>

</body>

</html>

You might also like