文本统计分析(本地版)

GETPOST 文本处理

对文本进行全面统计分析,包括字数、词频、标点符号、段落、句子等维度,支持中英文混合文本

GET https://api.tinyaii.cn/v1/text/analyze

请求参数

参数名类型必填说明示例
textstring必填待分析的文本内容今天天气不错,我们出去走走吧!

返回字段

字段类型说明
characters.totalint总字符数
characters.bytesint总字节数
characters.chineseint中文字符数
characters.englishint英文字母数
characters.digitsint数字个数
characters.spacesint空格数
words.totalint总词数(中文按字+英文按词)
sentences.countint句子数
sentences.avg_lengthint平均句长
sentences.longeststring最长句子
sentences.shorteststring最短句子
paragraphs.countint段落数
paragraphs.linesint总行数
punctuation.totalint标点符号总数
punctuation.chineseint中文标点数
punctuation.englishint英文标点数
punctuation.toparray高频标点Top15
reading.estimated_minutesint预计阅读时间(分钟)
top_wordsarray高频词语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 换成你的密钥即可直接运行。密钥只保存在你自己的设备上。