Skip to content

⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI 智能筛选新闻 + AI 翻译 + AI 分析简报直推手机,也支持接入 MCP 架构,赋能 AI 自然语言对话分析、情感洞察与趋势预测等。支持 Docker ,数据本地/云端自持。集成微信/飞书/钉钉/Telegram/邮件/ntfy/bark/slack 等渠道智能推送。

1.1 KB
Raw Blame
import tempfile
import unittest
from pathlib import Path

from trendradar.core.frequency import load_frequency_words, matches_word_groups


class GlobalFilterTests(unittest.TestCase):
    def test_global_filter_supports_regular_expressions(self):
        config = """[GLOBAL_FILTER]
/spam|clickbait/

[WORD_GROUPS]
news
"""

        with tempfile.TemporaryDirectory() as temp_dir:
            config_path = Path(temp_dir) / "frequency_words.txt"
            config_path.write_text(config, encoding="utf-8")
            word_groups, filter_words, global_filters = load_frequency_words(
                str(config_path)
            )

        self.assertFalse(
            matches_word_groups(
                "Breaking news: spam", word_groups, filter_words, global_filters
            )
        )
        self.assertFalse(
            matches_word_groups(
                "Clickbait news", word_groups, filter_words, global_filters
            )
        )
        self.assertTrue(
            matches_word_groups(
                "Breaking news", word_groups, filter_words, global_filters
            )
        )


if __name__ == "__main__":
    unittest.main()