# InfoReleaseResearch **Repository Path**: mackliu007/info-release-research ## Basic Information - **Project Name**: InfoReleaseResearch - **Description**: 官方发布灾情信息反馈分析与研究 - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-07-21 - **Last Updated**: 2026-01-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # PODAS(全称:Public Opinion Detection and Analysis System) #### 介绍 舆情检测与分析系统 #### 软件架构 软件架构说明: 1.爬虫根据关键字爬取数据----》2.处理数据-----》3.大模型BERT分析生成目标数据-----》4.根据模型生成可执行参考报告。 #### main 启用方式 ##### 1.灵活的数据源支持: 可以从JSON文件读取数据 可以从Redis队列获取实时数据 易于扩展新的数据源类型 ##### 2.命令行参数配置: ###### 使用JSON文件作为数据源: python main.py --source json --json-file data_collection/result_fuzhou_disaster.json ###### 使用Redis队列作为数据源: python main.py --source redis --redis-queue weibo:disaster:queue --redis-host localhost --redis-port 6379 ## 运行与测试 (Run & Test) 下面是一些在 Windows PowerShell 环境下的快速上手命令,包含依赖安装、生成报告(不使用/使用 LLM),以及 Redis 推送测试示例。 ### 1) 环境准备 & 依赖安装 推荐使用虚拟环境(可选)并安装项目依赖: ```powershell # 在项目根目录创建并激活虚拟环境(可选) python -m venv .venv .\.venv\Scripts\Activate.ps1 # 安装依赖 python -m pip install -r requirements.txt ``` ### 2) 从 JSON 生成 HTML 报告(不使用 LLM) ```powershell python .\scripts\generate_report.py --source json --json-file .\data_collection\result_fuzhou_disaster.json --output .\index.html ``` 生成后会在当前目录写入 `index.html`,用浏览器打开查看。 ### 3) 使用 LLM(Deepseek / OpenAI / Anthropic)生成官方建议文本 脚本支持通过环境变量或 CLI 参数指定 LLM 提供商与 API key。 示例(Deepseek,通过环境变量配置): ```powershell $env:DEEPSEEK_API_URL = 'https://api.deepseek.example/v1/generate' $env:DEEPSEEK_API_KEY = '' $env:DEEPSEEK_MODEL = 'deepseek-model-name' python .\scripts\generate_report.py --source json --json-file .\data_collection\result_fuzhou_disaster.json --output .\index.html --llm-provider deepseek ``` 示例(OpenAI): ```powershell $env:OPENAI_API_KEY = '' $env:OPENAI_MODEL = 'gpt-4' python .\scripts\generate_report.py --source json --json-file .\data_collection\result_fuzhou_disaster.json --output .\index.html --llm-provider openai ``` 示例(Anthropic): ```powershell $env:ANTHROPIC_API_KEY = '' $env:ANTHROPIC_MODEL = 'claude-2' python .\scripts\generate_report.py --source json --json-file .\data_collection\result_fuzhou_disaster.json --output .\index.html --llm-provider anthropic ``` 如果你不想设置环境变量,也可以通过 CLI 直接传入: ```powershell python .\scripts\generate_report.py --source json --json-file .\data_collection\result_fuzhou_disaster.json --output .\index.html --llm-provider deepseek --llm-api-url 'https://api.deepseek.example/v1/generate' --llm-api-key 'xxx' --llm-model 'deepseek-model' ``` > 注意:为安全起见建议使用环境变量存储 API Key,避免在命令行中明文传递密钥。 ### 4) Redis 推送测试(将示例消息加入队列-待实现) 仓库提供了 `scripts/push_sample_to_redis.py` 用于推送一个测试条目到默认队列 `weibo:disaster:queue`。 ```powershell # 确保 Redis 在 localhost:6379 可用,或在脚本中修改 host/port python .\scripts\push_sample_to_redis.py ``` 脚本运行后会向 Redis 队列中推送示例键(或示例 JSON),消费者侧的 `RedisQueueSource` 已支持解析指针键(GET / HGETALL)。 ### 5) 使用 Redis 作为数据源运行主程序(待实现) ```powershell python main.py --source redis --redis-queue weibo:disaster:queue --redis-host localhost --redis-port 6379 ``` 该命令会启动实时分析器并从 `weibo:disaster:queue` 消费数据(支持队列条目为 JSON 或指向 Redis key 的字符串)。 --- 如果你需要我把 README 中的命令改为 Linux / macOS shell 格式(bash),或希望我把示例 Deepseek 响应解析规则调整为你实际的 Deepseek API 返回格式,告诉我样例响应体我来定制解析器。 ### 6) 生成舆情处置方案(deterministic,非 LLM) 仓库包含一个不调用外部 LLM 的确定性脚本 `scripts/generate_action_plan.py`,它会根据分析结果(例如 BERT 输出的 JSON)生成一个完整的舆情处置方案 JSON(包含事件定性、处置策略、执行时间表、各部门协同等)。用法示例: ```powershell python .\scripts\generate_action_plan.py --input .\data_collection\result_fuzhou_disaster.json --output .\plan.json venv\Scripts\python .\scripts\generate_plan_report.py --plan-file plan.json --output index-plan.html ``` 运行后会在当前目录写入 `plan.json`,文件包含字段如 `事件定性`、`处置策略`、`执行时间表`、`各部门协同清单` 等。该脚本使用启发式规则推断严重程度与策略(可直接用于初步应对或作为人工决策参考)。 ### 7) 通过大模型生成分析数据与报告(演示): ```powershell 生成数据: python .\main.py --source json --json-file .\data_collection\result_fuzhou38_disaster.json #生成执行报告: python .\scripts\new_generate_plan_report.py --plan-file plan.json --output index-plan.html