Lecture Summarizer

Lecture Summarizer

Paste your lecture transcript below to generate a concise summary.

Your summary will appear here.

${summary}

`; }, summarizeText(text) { // This is a simple extractive summarization algorithm. // It's not AI, but it creates a plausible summary for this tool. const stopWords = new Set(['a', 'about', 'above', 'after', 'again', 'against', 'all', 'am', 'an', 'and', 'any', 'are', 'as', 'at', 'be', 'because', 'been', 'before', 'being', 'below', 'between', 'both', 'but', 'by', 'can', 'did', 'do', 'does', 'doing', 'down', 'during', 'each', 'few', 'for', 'from', 'further', 'had', 'has', 'have', 'having', 'he', 'her', 'here', 'hers', 'herself', 'him', 'himself', 'his', 'how', 'i', 'if', 'in', 'into', 'is', 'it', 'its', 'itself', 'just', 'me', 'more', 'most', 'my', 'myself', 'no', 'nor', 'not', 'now', 'of', 'off', 'on', 'once', 'only', 'or', 'other', 'our', 'ours', 'ourselves', 'out', 'over', 'own', 's', 'same', 'she', 'should', 'so', 'some', 'such', 't', 'than', 'that', 'the', 'their', 'theirs', 'them', 'themselves', 'then', 'there', 'these', 'they', 'this', 'those', 'through', 'to', 'too', 'under', 'until', 'up', 'very', 'was', 'we', 'were', 'what', 'when', 'where', 'which', 'while', 'who', 'whom', 'why', 'will', 'with', 'you', 'your', 'yours', 'yourself', 'yourselves']); // 1. Split into sentences const sentences = text.match(/[^\.!\?]+[\.!\?]+/g) || []; if(sentences.length < 2) return text; // Not enough text to summarize // 2. Calculate word frequencies const wordFrequencies = {}; text.toLowerCase().replace(/[^a-z\s]/g, '').split(/\s+/).forEach(word => { if (!stopWords.has(word)) { wordFrequencies[word] = (wordFrequencies[word] || 0) + 1; } }); // 3. Score sentences const sentenceScores = sentences.map(sentence => { let score = 0; sentence.toLowerCase().replace(/[^a-z\s]/g, '').split(/\s+/).forEach(word => { score += wordFrequencies[word] || 0; }); return { sentence, score }; }); // 4. Sort sentences by score sentenceScores.sort((a, b) => b.score - a.score); // 5. Determine how many sentences to include const lengthOption = this.dom.lengthSelect.value; let ratio = 0.4; if (lengthOption === 'short') ratio = 0.2; if (lengthOption === 'long') ratio = 0.6; const summaryLength = Math.max(1, Math.round(sentences.length * ratio)); // 6. Get top sentences and re-order them const topSentences = sentenceScores.slice(0, summaryLength); const summarySentences = sentences.filter(sentence => topSentences.some(s => s.sentence === sentence) ); return summarySentences.join(' '); }, generatePdf() { const summaryText = this.dom.output.innerText; if (!summaryText || summaryText === "Your summary will appear here.") { alert("Please generate a summary first."); return; } const { jsPDF } = window.jspdf; const pdf = new jsPDF({ unit: 'pt', format: 'a4' }); pdf.setFontSize(18); pdf.text("Lecture Summary", 40, 60); pdf.setFontSize(11); pdf.setTextColor(100); const margin = 40; const textLines = pdf.splitTextToSize(summaryText, pdf.internal.pageSize.getWidth() - (2 * margin)); pdf.text(textLines, margin, 90); pdf.save('Lecture-Summary.pdf'); }, copyToClipboard() { const summaryText = this.dom.output.innerText; if (!summaryText || summaryText === "Your summary will appear here.") { alert("Nothing to copy."); return; } const tempTextArea = document.createElement('textarea'); tempTextArea.value = summaryText; document.body.appendChild(tempTextArea); tempTextArea.select(); try { document.execCommand('copy'); this.dom.copyBtn.textContent = 'Copied!'; setTimeout(() => { this.dom.copyBtn.textContent = 'Copy to Clipboard'; }, 2000); } catch (err) { alert('Failed to copy text.'); } document.body.removeChild(tempTextArea); } }; app.init(); });
Scroll to Top