The Stylistic Analyzer (manuscript-check.html)
This code adds a “Word Counter” and a “Subsection Analyzer” that alerts the user if any one section is significantly longer than the others.
”<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<title>Manuscript Stylistic Analyzer</title>
<style>
body { font-family: sans-serif; padding: 20px; line-height: 1.5; }
.box { border: 1px solid #ccc; padding: 15px; margin-bottom: 20px; border-radius: 8px; }
.warning { color: red; font-weight: bold; }
</style>
</head>
<body>
<h2>Manuscript Stylistic Analyzer</h2>
<div class=”box”>
<h3>1. Analyze Manuscript Structure</h3>
<textarea id=”manuscript” rows=”10″ style=”width:100%” placeholder=”Paste your full manuscript here…”></textarea><br><br>
<button onclick=”analyzeManuscript()”>Analyze Style</button>
</div>
<div id=”analysis-results”></div>
<script>
function analyzeManuscript() {
const text = document.getElementById(“manuscript”).value;
const resultsDiv = document.getElementById(“analysis-results”);
// 1. Calculate Total Words
const totalWords = text.split(/\s+/).filter(word => word.length > 0).length;
// 2. Define Section Markers
const sections = {
“Introduction”: /introduction/i,
“Methods”: /methods|methodology/i,
“Results”: /results/i,
“Discussion”: /discussion/i
};
let report = `<h4>Total Word Count: ${totalWords}</h4>`;
report += “<ul>”;
// 3. Simple Section Length Estimator
const parts = text.split(/(?=Introduction|Methods|Results|Discussion)/i);
parts.forEach(part => {
const wordCount = part.split(/\s+/).length;
const sectionName = part.substring(0, 20).trim();
const isTooLong = wordCount > (totalWords * 0.4); // Warn if > 40% of total
report += `<li><strong>${sectionName}…</strong>: ${wordCount} words
${isTooLong ? ‘<span class=”warning”>(Too lengthy!)</span>’ : ”}</li>`;
});
report += “</ul>”;
resultsDiv.innerHTML = report;
}
</script>
</body>
</html>”
How this helps users understand “Stylistic” balance:
-
Distribution Analysis: The code calculates the percentage of the total manuscript each section takes up (
totalWords * 0.4). If one section is >40%, it flags it as “Too lengthy,” helping the author balance their writing. -
Visual Feedback: It uses Regex (
/introduction/i) to identify where sections begin, providing a “skeleton” view of the manuscript’s structure. -
Actionable Advice: Instead of just showing a word count, it tells the user which part of the paper is dominating the word limit.linkedin profile of the author:
More advanced version:
function analyzeManuscript() {
const text = document.getElementById(“manuscript”).value;
const resultsDiv = document.getElementById(“analysis-results”);
if (text.length < 200) {
resultsDiv.innerHTML = “<p>Please paste at least a few paragraphs for a comprehensive analysis.</p>”;
return;
}
const words = text.split(/\s+/).filter(w => w.length > 0);
const sentences = text.split(/[.!?]+/).filter(s => s.length > 0);
const totalWords = words.length;
// 1. Complexity Metric: Identify “Long-winded” sentences (> 25 words)
const longSentences = sentences.filter(s => s.trim().split(/\s+/).length > 25).length;
const complexityScore = ((longSentences / sentences.length) * 100).toFixed(1);
// 2. Academic Tone (Sentiment-lite)
// Checks for “Hedge words” common in scientific writing (often overused)
const hedges = [‘suggests’, ‘might’, ‘could’, ‘possibly’, ‘appears’, ‘seems’];
let hedgeCount = 0;
hedges.forEach(h => {
const regex = new RegExp(`\\b${h}\\b`, ‘gi’);
hedgeCount += (text.match(regex) || []).length;
});
// 3. Keyword Density (e.g., finding core topics)
// Counts occurrences of words > 5 letters to find “technical” focus
const technicalWords = words.filter(w => w.length > 6);
const topKeywords = technicalWords.slice(0, 10).join(‘, ‘);
resultsDiv.innerHTML = `
<div class=”box”>
<h4>📈 Advanced Stylistic Metrics</h4>
<ul>
<li><strong>Word Count:</strong> ${totalWords}</li>
<li><strong>Sentence Complexity:</strong> ${complexityScore}% of sentences are very long (>25 words).</li>
<li><strong>Academic Hedging:</strong> ${hedgeCount} instances of tentative language detected.</li>
<li><strong>Readability (ARI):</strong> Grade Level ~${(4.71 * (text.replace(/\s/g, ”).length / totalWords) + 0.5 * (totalWords / sentences.length) – 21.43).toFixed(1)}</li>
</ul>
<h4>🎯 Writing Tips</h4>
<ul>
${complexityScore > 30 ? ‘<li><strong>Warning:</strong> Too many long sentences. Consider breaking them up to improve clarity for reviewers.</li>’ : ‘<li>Sentence length is well-balanced.</li>’}
${hedgeCount > 15 ? ‘<li><strong>Tone Check:</strong> You use a lot of “hedging” language. Ensure your conclusions are as definitive as your data allows.</li>’ : ‘<li>Tone appears appropriately confident.</li>’}
</ul>
</div>
`;
}
link of program:
