extract-human-name

中文文档
1.0.14发布于 2026/11/03rights.institute/PROSPERTypeScriptESM + CJS零依赖构建来源已验证

Extracts, characterizes, and structures human author names from arbitrary text: tells a person ("Dr. John Doe") from an organization ("The New York Times"), parses name parts (title, first, middle, last, honorific), splits multi-author bylines, and format

原始使用文档
文档目录9 节
  1. API
  2. extractHumanName(author, options?)
  3. extractHumanNameParts(input)
  4. cleanProfessionalQualifications(authorName)
  5. splitMultipleAuthors(authorString)
  6. isOrganization(nameString)
  7. The names database: slim default vs. /full
  8. Demo
  9. Tests

extract-human-name

Extracts, characterizes, and structures human author names from arbitrary text. Tells a person ("Dr. John Doe") from an organization ("The New York Times"), parses a name into its parts, splits multi-author bylines, and formats APA-style citations — no network, no model, no browser.

bun add extract-human-name
import { extractHumanName } from "extract-human-name";

extractHumanName("by: Dr. John Q. Public Jr.");
// {
//   author_cite: "Public, John Q., Jr.",
//   author_short: "Public",
//   author_type: 1
// }

extractHumanName("John Doe and Jane Smith");
// { author_cite: "Doe, John & Smith, Jane", author_short: "Doe & Smith", author_type: 2 }

extractHumanName("The New York Times");
// { author_cite: "The New York Times", author_short: "The New York Times", author_type: 4 }

API

extractHumanName(author, options?)

The main entry. Sanitizes the input (strips by: prefixes, collapses whitespace), splits a byline into individual authors, classifies each one as a person or an organization, and compiles citation forms.

OptionDefault
formatCiteShortenAuthorfalseAbbreviate given names to initials: "John Quincy Doe" → "Doe, J. Q."
maxAuthorsBeforeEtAl2List this many authors in full before collapsing to "First et al."

author_type values:

ValueMeaning
0Empty or unparseable input
1A single person
2Exactly two authors
3Three or more authors
4A single organization

extractHumanNameParts(input)

Parses one name into { title, firstname, middle, lastname, honorific }. Handles "Last, First" inversion, multi-word family prefixes (Ludwig van Beethoven → lastname "van Beethoven"), quoted aliases (John "The Rocket" Doe), and fixes the case of all-upper/all-lower input.

cleanProfessionalQualifications(authorName)

Strips honorifics, titles, and professional qualifications ("Dr. John Smith, Professor" → "John Smith").

splitMultipleAuthors(authorString)

Partitions a byline into individual names. Handles "Last, First & Last, First", comma series with a trailing and, &/and/semicolon separators, and drops et al..

isOrganization(nameString)

The person-vs-organization heuristic: rigid acronyms (WHO), an organization dictionary (decisive terms, or ambiguous terms in pairs like Morgan Stanley), qualification counter-terms (Professor …), "Last, First" inversion, organizational phrases, word count, and the names database.

The names database: slim default vs. /full

The default entry is slim: it does not bundle the 92k-entry names JSON (human-names-92k.json, ~1.1 MB). Person-vs-organization detection runs on a compact built-in list of ~5,000 given names and 5,000 common surnames plus word heuristics. The full database is loaded only when needed, one of two ways:

// Lazy-load it from the jsDelivr CDN (one shared request, cached;
// resolves null on failure, so a CDN outage never breaks extraction)
import { extractHumanName, loadHumanNamesDB } from "extract-human-name";
await loadHumanNamesDB(); // or { url, fetch } to self-host

// Or bundle it: same API, names database registered on import
import { extractHumanName } from "extract-human-name/full";

setHumanNamesDB(db) registers a copy you already hold, and getHumanNamesDB() reads the current one. Both entries share one database, so importing extract-human-name/full once enables it for the slim import too.

With the database loaded, a name whose words are outside the compact list is still recognized as a person:

await loadHumanNamesDB();
extractHumanName("Zephyr Quill Xylo").author_type; // 1 (person), not 4 (organization)

Demo

The Citation tab of the extract-pdf site (/demo#cite) runs name recognition against news, journal, organization and blog URLs.

Tests

cd packages/extract-human-name && bun run test

Covers name parsing, byline splitting, organization detection (with and without the database), the extractHumanName citation forms, and the lazy loader (single shared request, failure fallback, retry, /full registration).

版本与发布记录

extract-human-name 共发布 16 个版本,首次发布于 2026/10/09;过去 12 个月发布了 16 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.14latest2026/11/03今天
1.0.132026/11/03今天
1.0.122026/11/03今天
1.0.112026/11/03今天
1.0.102026/11/03今天
1.0.92026/11/03今天

关于 extract-human-name 的常见问题

extract-human-name 是什么?

从任意文本中提取、描述和构建人类作者的姓名:从组织(“The New York Times”)中识别一个人(“Dr. John Doe”),解析姓名部分(标题、第一、中间、最后、敬语),拆分多作者署名和格式

如何安装 extract-human-name?

在项目目录运行 npm install extract-human-name,或使用 pnpm add / yarn add / bun add。

extract-human-name 支持 TypeScript 吗?

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

extract-human-name 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

extract-human-name 可以商用吗?

extract-human-name 使用 rights.institute/PROSPER 许可。声明的许可为 rights.institute/PROSPER,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

extract-human-name 还在维护吗?

最新版本 1.0.14 发布于 2026/11/03(今天);至今共发布 16 个版本,其中过去 12 个月发布了 16 个;首次发布于 2026/10/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。