Pages

Saturday, 30 November 2024

Duplicate Sentence Checker and Remover Tool



Duplicate Sentence Checker and Remover

Duplicate Sentence Checker and Remover

Processed Text

/* General Styles */ body { font-family: 'Arial', sans-serif; background-color: #f4f7f6; margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; height: 100vh; } .container { background-color: #ffffff; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); padding: 20px; border-radius: 8px; width: 90%; max-width: 800px; } h1 { text-align: center; color: #4CAF50; margin-bottom: 20px; } textarea { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 5px; font-size: 16px; resize: none; } textarea:focus { border-color: #4CAF50; } .buttons { text-align: center; margin: 20px 0; } button { background-color: #4CAF50; color: white; border: none; padding: 10px 20px; margin: 5px; font-size: 16px; cursor: pointer; border-radius: 5px; transition: background-color 0.3s; } button:hover { background-color: #45a049; } button:disabled { background-color: #aaa; cursor: not-allowed; } .output h2 { color: #333; margin-bottom: 10px; } .output textarea { background-color: #f9f9f9; color: #555; } // Function to check for duplicate sentences function checkDuplicates() { let inputText = document.getElementById('inputText').value.trim(); let outputText = document.getElementById('outputText'); // Split the text into sentences by a period followed by a space or new line let sentences = inputText.split(/(?<=\.)\s+/); // Remove duplicates using Set let uniqueSentences = Array.from(new Set(sentences)); // Join sentences back together and display outputText.value = uniqueSentences.join(' '); } // Function to remove duplicate sentences function removeDuplicates() { let inputText = document.getElementById('inputText').value.trim(); let outputText = document.getElementById('outputText'); // Split the text into sentences by a period followed by a space or new line let sentences = inputText.split(/(?<=\.)\s+/); // Create an object to track sentence occurrences let sentenceTracker = {}; // Filter sentences to only include unique ones let uniqueSentences = sentences.filter(sentence => { let lowerSentence = sentence.toLowerCase().trim(); if (sentenceTracker[lowerSentence]) { return false; // Skip duplicates } else { sentenceTracker[lowerSentence] = true; return true; } }); // Join sentences back together and display outputText.value = uniqueSentences.join(' '); }