word counter

version: 2 0 14 official


描述

Function Summary:

Get instant insights into your text content. This function scans your input to calculate exactly how long it is (characters and words), how complex it is (sentences), and how much it might cost to process with AI models (estimated tokens). Perfect for checking text limits before submission.

函数简介:

快速获取文本内容的统计洞察。此函数会扫描您的输入内容,精确计算文本长度(字符数和单词数)、结构复杂度(句子数),以及使用 AI 模型处理时的预估成本(Token 数)。非常适合在提交内容前检查是否符合长度限制。


关于

Text Analysis Function 文本分析函数介绍

Description

The analyzeText(input) function is a utility designed to process raw text strings and provide statistical metrics. It is particularly useful for content management systems, SEO tools, or LLM (Large Language Model) pre-processing checks.

Key Metrics Returned:

  • Character Count: Total number of characters, including spaces and punctuation.
  • Word Count: Number of words based on whitespace separation.
  • Sentence Count: Number of sentences detected by delimiters (e.g., ".", "!", "?").
  • Estimated Tokens: An approximation of token usage for common AI models (e.g., GPT-4), calculating English and Chinese characters differently.

功能说明

analyzeText(input) 是一个用于处理原始文本字符串并提供统计指标的工具函数。它特别适用于内容管理系统、SEO 优化工具或大语言模型(LLM)的预处理检查。

返回的关键指标:

  • 字符数 (Character Count): 所有字符的总数,包含空格和标点符号。
  • 单词数 (Word Count): 基于空白字符分割的单词数量统计。
  • 句子数 (Sentence Count): 基于常用结束符(如“。”、“!”、“?”)检测到的句子数量。
  • 预估 Token 数 (Estimated Tokens): 针对常用 AI 模型(如 GPT-4)的 Token 消耗估算,对中英文采用不同的加权算法以提高准确度。
function analyzeText(input): Object