# @desert-ant-labs/tongue 中文文档

规范地址：https://npmcn.com/package/%40desert-ant-labs/tongue/

版本：4\.3\.0
npm 元数据更新时间：2026-11-05T21:25:33.642Z
中文译文更新时间：2026-11-12T01:12:28.548Z
软件包许可：SEE LICENSE IN LICENSE\.md

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40desert-ant-labs/tongue
原文对照：https://npmcn.com/package/%40desert-ant-labs/tongue/?lang=original
项目主页：https://desertant.com/models/tongue/
源码仓库：https://github.com/Desert-Ant-Labs/desert-ant-core

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：2.2 MB，25 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：\>=18
- 运行依赖：0 个
- 首次发布：2026-07-28T14:59:39.945Z
- 最新版本发布：2026-11-05T21:25:33.452Z
- 近 30 天下载量：8517（2026-10-12 至 2026-11-10，npm 官方下载统计）
- 已发布版本数：19（近 12 个月 19 个）

## 中文简介

短文本的在线语言识别,跨越84种语言. 纯JavaScript:没有被,没有推论运行时间.

## 安装

```sh
npm install @desert-ant-labs/tongue
```

也可以使用：`pnpm add @desert-ant-labs/tongue`、`yarn add @desert-ant-labs/tongue`、`bun add @desert-ant-labs/tongue`

## README

# 舌头 — JavaScript / TypeScript SDK

短文本的在线语言识别,跨越84种语言. 运行于 浏览器和一个导入的节点.

```ts
import { Tongue } from "@desert-ant-labs/tongue";

const tongue = await Tongue.load();
tongue.detect("kann ich das haben").language;   // "de"
tongue.detect("안녕하세요").language;             // "ko"
```

**没有原子弹 没有推断时间 没有依赖性.** 探测器是一英寸8 嵌入相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相相接相接相接相接相接相接相接相接相接相接相接相接相接相相相相接相相接相接相接相接相相相相相接相相相接相相接相相相接相相接相接相相相相相相相接相相相相相相接相相相相相 平原JavaScript中的乘法加法. 所以这个包就有一个单项 点 `emo-js` 需要单独的浏览器并构建节点:没有运行时间 互换,只有两种读取2MB重量的方法.

## 安装

```
npm i @desert-ant-labs/tongue
```

节点QQ18,或任何现代浏览器.

```ts
// Node: reads the bundled weights from the package directory.
const tongue = await Tongue.load();

// Browser: serve tongue_int8.bin and tongue_meta.json and point at them.
const tongue = await Tongue.load({ from: "/models/tongue" });

// Or supply the bytes yourself.
const tongue = Tongue.fromBytes(metadata, weightBytes);
```

## 说"我不知道"

简短的输入常常是无法确证的,SDK说不是 猜测。 可靠性按键关闭了证据——输入长度和顶部多远 候选人是领先者 而不是原始的软骨自信 情况很糟 两个字太自信了.

```ts
const detection = tongue.detect("la casa");
detection.isTooCloseToCall;   // true — equally Italian and Spanish
detection.reliability;        // "tentative"
detection.candidates;         // [it 0.31, es 0.29, …]
```

两人在 `isTooCloseToCall` 已经设定。 处理 `"tentative"` 作为"未知" 而不是作为答案, 并要求更多的文本 在产品允许的地方.

## API 密码

|  |  |
| --- | --- |
| `Tongue.load(options?)` | 装入模型; `options.from` 是目录或基准 URL |
| `Tongue.fromBytes(metadata, bytes)` | 从您已有的字节加载 |
| `detect(text, topK?)` | `Detection` |
| `Detection.language` | 高级候选人,或 `null` 空输入 |
| `Detection.candidates` | `Prediction[]` 有概率 |
| `Detection.reliability` | `"confident"` • 妇女 `"likely"` • 妇女 `"tentative"` • 妇女 `"empty"` |
| `Detection.isTooCloseToCall` | 在0.12范围内排名前2位 `topK` 实值 |
| `Detection.route.verdict` | `"decisive"` (单写下来) `"narrowing"` • 妇女 `"ambiguous"` |

`normalize`, (中文(简体) ), `route`, (中文(简体) ), `fnv1a` 财务报告和审定财务报表 `buckets` 也为任何人出口 复制特性管道.

## 常见JS 和类型脚本

一揽子措施仅限无害环境管理. `require()` 它在20.19+节点上本地工作 所以 CJS 服务器运行时不需要更改 。 CJS 项目中的脚本类型应设置 `"moduleResolution": "nodenext"` (TS 5.8+)——老年人 `node16` 设置拒绝 以 TS1479 导入,即使排放 `require()` 运行。 在旧节点上 ,使用动态 `import()`。 。 。 .

## 在浏览器中为模型服务

在节点上,没有配置的重量从包中卸出。 一个捆绑者 不服务文件来自 `node_modules`,所以在浏览器中,您服务两个模型文件 自己和指点 `load` 他们:

```ts
const tongue = await Tongue.load({ from: "/models/tongue" });
```

两个文件都导出,所以捆绑者可以指纹和散开它们而不是 需要复制步骤 :

```ts
import binUrl from "@desert-ant-labs/tongue/model/tongue_int8.bin?url";   // Vite
import metaUrl from "@desert-ant-labs/tongue/model/tongue_meta.json?url";
```

或复制 `node_modules/@desert-ant-labs/tongue/dist/tongue_{int8.bin,meta.json}` 作为构建步骤,输入您的静态目录.

通话 `Tongue.load()` 没有 `from` 在浏览器中根据页面 URL 解析, 在一个单页的应用程序上点击历史倒回并返回 `index.html`编辑 如果发生错误,那么错误是明确的.

## 跨平台合同

正常化者、散货商和路由商 **已冻结的规格** 与《京都议定书》 Python参考和斯威夫特和克特林 SDKs. `test/golden.test.js` 重放 同样的向量文件,所有它们都做,包括全包的散列平等:

```
npm test
```

重新生成 Unicode 表格而不是编辑它们:

```
python3 scripts/gen_ts_tables.py --reference ../tongue-training
```

## 型号

重量、基准和限制: [拥抱相貌.co/沙漠-ant-labs/通俗](https://huggingface.co/desert-ant-labs/tongue)。 。 。 . 现场演示 : [(原始内容存档于2012-10-12). desert-ant-labs-tongue-demo.static.hf.space](https://desert-ant-labs-tongue-demo.static.hf.space/)。 。 。 .

在部署前读取模式卡的失败模式: 一个或两个单词经常是 马来语和印度尼西亚语在这种大小上并不可靠, 蒙古文仅出自于传统剧本,并出自名牌和版本 字符串根本不是语言 .

## 许可证

[沙漠蚂蚁实验室 源头可破坏许可证](https://license.desertant.com/)。为大多数免费提供 应用软件和商务许可证必须规模化。 完整的术语在链接. 许可证发放: [许可@ desertant.com](mailto:licensing@desertant.com)。 。 。 .

SDK的第三方通知: [`THIRD_PARTY_NOTICES.md`](https://github.com/Desert-Ant-Labs/desert-ant-core/blob/main/THIRD_PARTY_NOTICES.md)。 。 。 .

权重第三方通知: [`THIRD_PARTY_NOTICES.md`](https://huggingface.co/desert-ant-labs/tongue/blob/main/THIRD_PARTY_NOTICES.md)。 。 。 .

## 常见问题

### @desert-ant-labs/tongue 是什么？

短文本的在线语言识别,跨越84种语言\. 纯JavaScript:没有被,没有推论运行时间\.

### 如何安装 @desert-ant-labs/tongue？

在项目目录运行 npm install @desert-ant-labs/tongue，或使用 pnpm add / yarn add / bun add。

### @desert-ant-labs/tongue 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @desert-ant-labs/tongue 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @desert-ant-labs/tongue 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=18。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @desert-ant-labs/tongue 可以商用吗？

@desert-ant-labs/tongue 使用 SEE LICENSE IN LICENSE\.md 许可。许可条款写在包内的独立文件中，请阅读该文件确认可否商用。以上为概括，不构成法律意见，请以许可原文为准。

### @desert-ant-labs/tongue 的下载量有多少？

根据 npm 官方下载统计，@desert-ant-labs/tongue 在 2026/10/12 – 2026/11/10 这 30 天内被下载 8,517 次，日均约 284 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @desert-ant-labs/tongue 还在维护吗？

最新版本 4\.3\.0 发布于 2026/11/06（6 天前）；至今共发布 19 个版本，其中过去 12 个月发布了 19 个；首次发布于 2026/07/28。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

