跳到正文
Skillpedia
通用编程12k · #11472

compromise

它能做什么

它说明如何使用 compromise 的匹配语法、选择功能和插件来处理英文句子。适用于使用或修复 compromise 代码的开发者。

适用场景

  • ✓当你使用 compromise 库,需要为某项任务找到合适的方法时。
  • ✓当你编写匹配模式,用来在文本中查找词语或短语时。
  • ✓当你需要选择 compromise 的导入版本,或添加插件时。

技能链接

https://github.com/spencermountain/compromise/blob/master/skills/compromise/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/spencermountain/compromise/blob/master/skills/compromise/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我应该用 compromise 的哪个方法,才能提取这段文本中的所有日期和数字?”

每周 5 个新技能,1 分钟读完。

工作原理

AI 会检查已安装的版本和构建,然后选择对应的方法或模式,并说明结果会包含什么。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Using compromise

Compromise is a rule-based English NLP library that runs locally in Node.js and browsers. Its tagging and transformations are heuristic; it does not provide a dependency parse tree, semantic understanding, or an LLM service.

Choose the API for the installed version

Inspect the project's compromise version, import, and registered plugins before choosing APIs. Prefer the full import nlp from 'compromise' for ordinary use:

Import Available features
compromise or compromise/three Tokenization, tagging, named selections and transforms
compromise/two Tokenization and tagging; no .people(), .verbs(), or .numbers()
compromise/one or compromise/tokenize Tokenization; no automatic part-of-speech tagging

Use the existing module system; CommonJS can use const nlp = require('compromise'). If a method is missing, check the build tier, version, and plugins before inventing a replacement API. Specialized transforms belong on specialized selections: use .verbs().toPastTense(), not .match('#Verb').toPastTense().

Read only the detailed docs needed for the task. These paths resolve inside this repository and packages that ship this skill alongside docs/:

  • API: method names, arguments, and specialized selection methods.
  • Match syntax: pattern operators and capture groups.
  • Tag definitions: valid tags and their hierarchy.
  • Concepts: document, View, Term, and mutation semantics.
  • Recipes: task-specific starting points.
  • Tagging differences: conventions when comparing other taggers.

If this skill was installed separately, look for these files in the consuming project's node_modules/compromise/docs/ or its resolved package directory. If unavailable, consult the upstream repository at the installed version's tag when available. Do not assume the latest docs describe an older installed version. When docs and behavior disagree, reproduce against that version and inspect its source/types.

Keep the document and selection distinct

nlp(text) returns a View of the whole document. Selections return Views sharing that document. Transforms mutate the shared document; reading .text() from a selection gives only that fragment. Keep the whole-document variable when the requested output is the rewritten input:

import nlp from 'compromise'

const original = nlp('She walks home.')
const past = original.clone()
past.verbs().toPastTense()
past.text() // 'She walked home.'
original.text() // 'She walks home.'

Clone before transforming when the original must be preserved. Cloning a selection does not turn it into a whole-document selection. .all() returns a View of the whole underlying document.

  • .match(pattern) extracts matching terms; .has(pattern) returns a boolean.
  • .if(pattern) filters the current phrases, retaining each whole phrase containing a match. Use .sentences().if(pattern) to retain matching sentences.
  • .found is a boolean property, not a method. An empty View is still a truthy JavaScript object.
  • .replace(from, to) finds a pattern and replaces it; .replaceWith(to) replaces the selection.
  • .text() returns a string; .out('array') returns strings per match; .json() returns structured records. These are outputs, not chainable Views.
  • Text outputs can preserve case and punctuation. .text('normal') is not a universal punctuation stripper. Choose and verify normalization for the requested output rather than stripping blindly.

Write term patterns, not character regexes

Patterns operate on tokenized terms within each sentence. Literal words match case-insensitively; use {walk} to include inflections such as walked. Use real tag names: #Person, #Place, #Organization, #Noun, #Verb, #Adjective, #Value, and #Date are useful starting points. Tags form a hierarchy, so #FirstName also matches #Person and #Noun. Unknown tags silently match nothing unless explicitly defined by an extension. Do not invent tags such as #Name, #Location, #Subject, #Object, or #Adj.

Pattern Meaning
#Adjective+ #Noun One or more adjective terms followed by a noun
the big? cat Optional big term
(cat|dog) Alternatives
`the .
常见问题

我需要哪个版本的 compromise?

该技能说明,在选择方法之前,要先检查项目中已安装的版本和导入方式。

如果某个方法不存在怎么办?

它建议在尝试其他方法之前,先检查构建层级、版本和插件。

它能做依存句法分析吗?

不能。它说明 compromise 不提供依存句法树或语义理解。

详情

作者的原始描述

Write and debug JavaScript or TypeScript that uses the compromise English NLP library to match text, extract entities or numbers, customize tagging, and transform sentences. Use when the user requests compromise or the project already uses it, especially for its match syntax, selection semantics, build tiers, and plugins.

repo: spencermountain/compromise

热度

GitHub 星标
12k
排名
#11472
许可证
MIT
更新时间
2026/10/30

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能