Skip to content

Commit ecf668e

Browse files
committed
analyzer: Improve detection algorithms and refactor HTML rendering
Why: The analyzer previously treated all sentence differences as binary (missing or added), failing to capture how Grokipedia often rewords Wikipedia content rather than omitting or fabricating it entirely. This made it impossible to distinguish benign paraphrasing from misleading alterations. Additionally, HTML rendering logic was tightly coupled with command code, hindering maintainability, and the content hash calculation relied on a deprecated field. What: Algorithmic improvements: - Add detectRewordedSentences() with 65% similarity threshold - Add detectAgreedSentences() for exact sentence matching - Add detectFactualErrors() analyzing numeric/entity discrepancies - Enhance detectHallucinationEvents() with speculative keywords - Add reconstructTextFromStructured() to rebuild article text - Update confidence scoring to account for new metrics - Fix content hash to use reconstructed text instead of field UI/rendering improvements: - Extract HTML generation to html-renderer.ts - Create template-renderer.ts for variable substitution - Add report.html template with card-based layout - Refactor show.ts to use new rendering system - Update build script to copy templates to dist Data structure updates: - Add reworded_sentences, truly_missing_sentences, agreed_sentences - Add factual_errors to discrepancies - Remove deprecated text and media fields - Add analysis_window metadata
1 parent c5f0a3b commit ecf668e

15 files changed

Lines changed: 1547 additions & 571 deletions

data/grok/moon.parsed.json

Lines changed: 2 additions & 3 deletions
Large diffs are not rendered by default.

data/wiki/moon.parsed.json

Lines changed: 0 additions & 1 deletion
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"vitest": "^3.1.1"
9191
},
9292
"scripts": {
93-
"build": "npx tsc",
93+
"build": "npx tsc && cp -r src/templates dist/",
9494
"start": "node dist/cli.js",
9595
"test": "vitest run",
9696
"lint": "eslint . --ext .ts",

src/commands/analyse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const buildTopicContext = (topic: Topic): TopicContext => {
5555
const grokArticle = readStructuredArticle(paths.GROK_DIR, topic, 'grok');
5656
const wikiSource = prepareAnalyzerSource(wikiArticle);
5757
const grokSource = prepareAnalyzerSource(grokArticle);
58-
const contentHash = computeContentHash(wikiArticle.text, grokArticle.text);
58+
const contentHash = computeContentHash(wikiSource.text, grokSource.text);
5959
return {
6060
wikiSource,
6161
grokSource,

0 commit comments

Comments
 (0)