Skip to content

Commit

Permalink
initial api playground
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigmakib2 committed Mar 6, 2024
1 parent 92d0393 commit 3976564
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,39 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bad Word Checker</title>
<title>Nirmol: Bangla Offensive Language Detection API and Dataset</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
/* Additional custom CSS */
.container {
max-width: 500px;
margin-top: 50px;
}
</style>
</head>
<body>
<h1>Bad Word Checker</h1>
<input type="text" id="textInput" placeholder="Enter your text here">
<button onclick="checkBadWords()">Check</button>
<div id="result"></div>
<div class="container">
<h1 class="text-center">Nirmol</h1>
<p class="text-center">Nirmol (নির্মল) is a Bangla Offensive Language Detection API and Dataset</p>
<div class="input-group mb-3">
<input type="text" class="form-control" id="textInput" placeholder="Enter your text here" oninput="toggleButton()">
<button class="btn btn-primary" id="checkButton" onclick="checkBadWords()" disabled>Check</button>
</div>
<div id="result"></div>
<img class="img-thumbnail img-fluid" src="/nirmol.png" alt="" srcset="">
</div>

<!-- Bootstrap JS (optional if you're not using JS features from Bootstrap) -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>

<script>
function toggleButton() {
const inputText = document.getElementById('textInput').value.trim();
const checkButton = document.getElementById('checkButton');
checkButton.disabled = inputText === '';
}

function checkBadWords() {
const inputText = document.getElementById('textInput').value;
fetch(`https://nirmol.cyclic.app/${encodeURIComponent(inputText)}`)
Expand All @@ -21,17 +45,17 @@ <h1>Bad Word Checker</h1>
resultDiv.innerHTML = '';

if (data.bad_sentence) {
resultDiv.innerHTML += '<p>This sentence contains bad words:</p>';
resultDiv.innerHTML += '<div class="alert alert-danger" role="alert">This sentence contains bad words:</div>';
resultDiv.innerHTML += `<p>Bad words: ${data.bad_word_list.join(', ')}</p>`;
resultDiv.innerHTML += `<p>Normal words: ${data.normal_words.join(', ')}</p>`;
resultDiv.innerHTML += `<p>Badness: ${data.badness}</p>`;
} else {
resultDiv.innerHTML = '<p>No bad words found in the sentence.</p>';
resultDiv.innerHTML = '<div class="alert alert-success" role="alert">No bad words found in the sentence.</div>';
}
})
.catch(error => {
console.error('Error:', error);
document.getElementById('result').innerHTML = '<p>An error occurred. Please try again later.</p>';
document.getElementById('result').innerHTML = '<div class="alert alert-danger" role="alert">An error occurred. Please try again later.</div>';
});
}
</script>
Expand Down
Binary file added nirmol.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3976564

Please sign in to comment.