Files
sese-engine-go/README.md
T
2026-04-20 18:26:54 +08:00

66 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# sese-engine Go 重构版
Python 原版的 Go 语言重构,使用标准英文命名,单二进制部署。
## 目录结构
```
sese-engine-go/
├── main.go # 主入口,goroutine 启动所有模块
├── go.mod
├── config/
│ └── config.go # 全局配置参数
├── storage/
│ ├── types.go # 核心数据类型定义
│ └── store.go # Redis + MySQL 存储层
├── crawler/
│ ├── crawler.go # BFS 爬虫调度
│ └── fetcher.go # HTTP 获取 + robots.txt + 限流
├── parser/
│ └── parser.go # HTML 解析
├── analyzer/
│ └── analyzer.go # 分词 + 关键词权重 + 语言检测
├── search/
│ └── server.go # 搜索 API + 收获服务
├── backlink/
│ └── backlink.go # 反向链接计算
└── info/
└── info.go # 繁荣表 / 调整表 / 屏蔽词
```
## 依赖项
| Go 包 | 用途 |
|-------|------|
| `github.com/yanyiwu/gojieba` | 中文分词 |
| `github.com/pemistahl/lingua-go` | 语言检测(内置模型) |
| `github.com/redis/go-redis/v9` | Redis 客户端(高性能内存存储) |
| `github.com/go-sql-driver/mysql` | MySQL 驱动(持久化存储) |
| `github.com/andybalholm/brotli` | Brotli 压缩 |
| `golang.org/x/net/html` | HTML 解析 |
## 构建与运行
```bash
# 下载依赖(需要 CGo 编译器,用于 gojieba
go mod tidy
# 构建
go build -o sese-engine .
# 运行
./sese-engine --storage ./savedata --entry https://zh.wikipedia.org/
```
## 架构说明
- **Redis**:高性能内存存储,用于实时索引读写
- **MySQL**:持久化存储,用于数据备份和复杂查询
- **内存聚合**:写入先到 Redis,定期合并到 MySQL
## 注意事项
1. **CGo 依赖**gojieba 需要 C/C++ 编译器(gcc/clang)。
2. **Redis + MySQL**:需要提前部署并配置连接参数。
3. **配置文件**`config/config.yml` 中配置数据库连接信息。