文本统计分析(本地版)
对文本进行全面统计分析,包括字数、词频、标点符号、段落、句子等维度,支持中英文混合文本
GET
https://api.tinyaii.cn/v1/text/analyze
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| text | string | 必填 | 待分析的文本内容 | 今天天气不错,我们出去走走吧! |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| characters.total | int | 总字符数 |
| characters.bytes | int | 总字节数 |
| characters.chinese | int | 中文字符数 |
| characters.english | int | 英文字母数 |
| characters.digits | int | 数字个数 |
| characters.spaces | int | 空格数 |
| words.total | int | 总词数(中文按字+英文按词) |
| sentences.count | int | 句子数 |
| sentences.avg_length | int | 平均句长 |
| sentences.longest | string | 最长句子 |
| sentences.shortest | string | 最短句子 |
| paragraphs.count | int | 段落数 |
| paragraphs.lines | int | 总行数 |
| punctuation.total | int | 标点符号总数 |
| punctuation.chinese | int | 中文标点数 |
| punctuation.english | int | 英文标点数 |
| punctuation.top | array | 高频标点Top15 |
| reading.estimated_minutes | int | 预计阅读时间(分钟) |
| top_words | array | 高频词语Top10 |
返回示例
{
"code": 200,
"message": "success",
"data": {
"characters": {
"total": 88,
"bytes": 238,
"chinese": 64,
"english": 10,
"digits": 3,
"spaces": 0,
"other": 0
},
"words": {
"total": 66,
"chinese_words": 64,
"english_words": 2
},
"sentences": {
"count": 6,
"avg_length": 11,
"longest": "TinyAPI提供免费的API接口服务,已经运行了200多天。",
"shortest": "外面的阳光很好。"
},
"paragraphs": {
"count": 1,
"lines": 1,
"blank_lines": 0
},
"punctuation": {
"total": 11,
"chinese": 11,
"english": 0,
"top": [
{
"punctuation": ",",
"count": 4
},
{
"punctuation": "。",
"count": 4
},
{
"punctuation": "!",
"count": 2
},
{
"punctuation": ":",
"count": 1
}
]
},
"reading": {
"estimated_minutes": 1
},
"top_words": [
{
"word": "天",
"count": 3
},
{
"word": "走",
"count": 2
},
{
"word": "接口",
"count": 1
},
{
"word": "运行",
"count": 1
},
{
"word": "免费",
"count": 1
}
]
}
}
调用示例
curl "https://api.tinyaii.cn/v1/text/analyze?text=今天天气不错,我们出去走走吧!" \
-H "Authorization: Bearer YOUR_API_KEY"const res = await fetch("https://api.tinyaii.cn/v1/text/analyze?text=今天天气不错,我们出去走走吧!", {
headers: { "Authorization": "Bearer YOUR_API_KEY" },
});
console.log(await res.json());import requests
resp = requests.get(
"https://api.tinyaii.cn/v1/text/analyze",
params={"text": "今天天气不错,我们出去走走吧!"},
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=10,
)
print(resp.json())把 YOUR_API_KEY 换成你的密钥即可直接运行。密钥只保存在你自己的设备上。