You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
π§ Add comprehensive deduplication to AI news analysis
β Enhanced AI prompts with explicit deduplication instructions
β Added programmatic deduplication with keyword overlap detection (40% threshold)
β Updated both OpenAI and Anthropic prompts for consistency
β Improved fallback categorization with deduplication (50% threshold)
β Enhanced synthesis prompts to avoid repetitive content
π― FIXES: Multiple instances of same China stories and other duplicates
π€ AI Analysis: Now explicitly instructed to select best version of duplicate stories
π Safety Net: Programmatic overlap detection prevents AI misses
π° Result: Unique, distinct stories in each theme category
Example: Multiple 'China economy', 'China trade', 'China GDP' stories β One comprehensive China story
Reported-by: Molloy
2. Use only these themes: politics, economy, health, international, climate, technology, crime
192
-
3. Rate significance 1-10 based on coverage breadth
193
-
4. Focus on stories with cross-source coverage
189
+
DEDUPLICATION RULES (CRITICAL):
190
+
1. If multiple headlines cover the SAME story/event (e.g., multiple China stories, same political announcement), select ONLY the most comprehensive one
191
+
2. Look for similar keywords, names, locations, events - these indicate duplicate coverage
192
+
3. For example: If you see "China economy" and "China trade" and "China GDP" - these might be the same story, pick the best one
193
+
4. Prioritize headlines with more specific details over generic ones
194
+
5. Each theme should have UNIQUE, DISTINCT stories - no duplicates allowed
195
+
196
+
OTHER RULES:
197
+
6. Return ONLY the JSON object, no other text
198
+
7. Use only these themes: politics, economy, health, international, climate, technology, crime
199
+
8. Rate significance 1-10 based on coverage breadth and uniqueness
200
+
9. Focus on stories with cross-source coverage but avoid duplicates
{"role": "system", "content": "You are an expert news analyst categorizing UK headlines for accessibility services. Focus on accuracyand significance."},
207
+
{"role": "system", "content": "You are an expert news analyst categorizing UK headlines for accessibility services. CRITICAL: Eliminate duplicate stories about the same events. Focus on accuracy, significance, and uniqueness. Never include multiple stories about the same event or topic."},
{"role": "user", "content": f"You are an expert news analyst. {ai_prompt}"}
221
+
{"role": "user", "content": f"You are an expert news analyst. CRITICAL: Eliminate duplicate stories about the same events. Focus on uniqueness and avoid redundancy. {ai_prompt}"}
215
222
]
216
223
)
217
224
ai_analysis=json.loads(response.content[0].text)
218
225
219
-
# Apply AI analysis to stories
226
+
# Apply AI analysis to stories and add programmatic deduplication
220
227
themes= {}
221
228
fortheme, story_analysesinai_analysis.items():
222
229
theme_stories= []
230
+
seen_keywords=set() # Track keywords to prevent similar stories
231
+
223
232
foranalysisinstory_analyses:
224
233
story_idx=analysis['index'] -1# Convert to 0-based
{"role": "system", "content": "You are creating accessible news content for visually impaired users. Write clearly and conversationally for audio consumption. Never copy original text - always synthesize."},
358
+
{"role": "system", "content": "You are creating accessible news content for visually impaired users. Write clearly and conversationally for audio consumption. Never copy original text - always synthesize. Avoid repetitive content - combine similar stories into one coherent narrative."},
{"role": "user", "content": f"You are creating accessible news content. {ai_prompt}"}
372
+
{"role": "user", "content": f"You are creating accessible news content. Avoid repetitive content - synthesize similar stories into one narrative. {ai_prompt}"}
0 commit comments