诗泉:高性能中国古诗词 API 服务
?lang= 参数切换docker run -d -p 1279:1279 palemoky/chinese-poetry-api:latest完整配置参见 docker-compose.yml。
make help # 查看所有可用命令
make build # 构建项目
make process-data # 处理数据
make run-server # 启动服务本项目使用 Git Submodules 管理诗词数据,推荐使用以下命令快速克隆:
# 完整克隆(包含 submodules)
git clone --recurse-submodules --depth=1 https://github.com/palemoky/chinese-poetry-api.git如果已经克隆了仓库,可以单独更新 submodules:
git submodule update --init --depth 1所有接口支持 lang 参数切换简繁体:
| 参数值 | 说明 |
|---|---|
zh-Hans |
简体中文(默认) |
zh-Hant |
繁体中文 |
…端点:http://localhost:1279/graphql
# 繁体中文查询
query {
poems(lang: ZH_HANT, pageSize: 10) {
edges {
node {
title
content
author {
name
}
}
}
totalCount
}
}
# 搜索诗词
query {
searchPoems(query: "静夜思", searchType: TITLE) {
edges {
node {
title
author {
name
}
}
}
}
}
# 统计信息
query {
statistics {
totalPoems
totalAuthors
poemsByDynasty {
dynasty {
name
}
count
}
}
}| 类型 | 说明 | 示例 |
|---|---|---|
all |
全文搜索(默认) | ?q=月 |
title |
标题搜索 | ?q=静夜思&type=title |
content |
内容搜索 | ?q=床前明月光&type=content |
author |
作者搜索 | ?q=李白&type=author |
本项目基于 chinese-poetry 数据集,包含:
| 分类 | 数量 | 分类 | 数量 | 分类 | 数量 | 分类 | 数量 |
|---|---|---|---|---|---|---|---|
| 五言绝句 | 18,895 | 七言绝句 | 85,032 | 五言律诗 | 71,400 | 七言律诗 | 69,028 |
| 乐府诗 | 9,315 | 五代词 | 543 | 宋词 | 21,369 | 元曲 | 10,905 |
| 诗经 | 305 | 楚辞 | 65 | 论语 | 20 | 四书五经 | 14 |
| 其他 | 96,232 |
pie title 收录数据分布概览 (忽略极小值)
"七绝/七律" : 154060
"五绝/五律" : 90295
"宋词/五代词" : 21912
"元曲" : 10905
"乐府诗" : 9315
"其他" : 96232No open issues yet, or sync has not completed.