Skip to content

Conversation

@CodingSelim
Copy link

Summary

Implements real trend calculation and weighting for get_trending_topics in the MCP data service, replacing the previous placeholder logic.

Changes Made

  • Keyword Statistics: Build detailed stats including frequency, best rank, and matched news items
  • Trend Labeling: Compare current vs historical frequencies to label keywords as "rising", "falling", "new", or "stable"
  • Weight Scoring: Compute normalized weight scores using configurable weights from config/config.yaml (rank: 60%, frequency: 30%, hotness: 10%)
  • Helper Methods: Added 5 internal methods to support the new logic:
    • _calculate_keyword_stats() - Computes keyword statistics from titles
    • _get_historical_keyword_frequency() - Fetches historical data for trend comparison
    • _calculate_trend() - Determines trend labels based on frequency changes
    • _calculate_weight_score() - Calculates normalized weight scores
    • _get_weight_config() - Reads weight configuration from YAML

Bug Fix

  • 🐛 Fixed NameError in get_trending_topics: Changed word_frequency to word_groups on line 398

Testing

  • Manual verification with actual historical data (2025-11-15)
  • Validated weight calculation with config/config.yaml settings
  • Confirmed trend detection logic with various frequency scenarios
  • Python compilation and import checks passed

File Changes

  • mcp_server/services/data_service.py: +167 insertions, -45 deletions

sansan0 and others added 30 commits June 13, 2025 19:20
sansan0 and others added 28 commits November 8, 2025 20:27
@CodingSelim CodingSelim changed the title feat: Implement real trend calculation and weighting logic real trend calculation and weighting logic Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants