compromise-nlp
하는 일
compromise 라이브러리로 단어를 매칭하고, 품사를 태깅하고, 문장을 변환하도록 AI에 가르칩니다. 영어 텍스트를 다루는 JavaScript 개발자를 위한 스킬입니다.
사용하는 경우
- ✓영어 텍스트에서 명사, 동사, 이름을 찾는 JavaScript를 작성할 때.
- ✓compromise로 문장을 과거형으로 바꾸거나 텍스트를 정규화하고 싶을 때.
- ✓예상하지 못한 결과를 반환하는 compromise 코드를 디버그할 때.
스킬 링크
https://github.com/spencermountain/compromise/blob/master/docs/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“한 단락의 영어 텍스트에서 사람 이름을 뽑아내는 JavaScript를 작성하도록 도와줄 수 있나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
AI는 텍스트를 문서로 바꾸고, 각 단어에 태그를 붙인 뒤, 선택과 변환 메서드로 텍스트의 일부를 찾거나 바꿉니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Using compromise
compromise is a rule-based English NLP library for JavaScript (no network, no model, no deps).
You tokenize text into a document, it tags each word's part-of-speech, and you find and
transform parts of the text with a jQuery-like chained API.
import nlp from 'compromise'
let doc = nlp('she sells seashells by the seashore.')
doc.verbs().toPastTense() // transform
doc.text() // 'she sold seashells by the seashore.'
The five rules that prevent almost every mistake
These are the things that are easy to get wrong from memory. Internalize them before writing code.
1. Transforms mutate the document in place — read the result from the original variable
Every transform method (.toPastTense(), .replace(), .tag(), .normalize(), case/whitespace
methods…) changes the underlying document. The View it returns is the selection it acted on, not
the whole document. So calling .text() on the chain gives you only the selected fragment:
let doc = nlp('I walk to work')
doc.verbs().toPastTense()
doc.text() // ✅ 'I walked to work' (read from doc)
nlp('I walk to work').verbs().toPastTense().text() // ❌ 'walked work' (just the selection)
To transform a copy and leave the original untouched, call .clone() first:
let past = doc.clone().verbs().toPastTense().text()
Read-only methods (.match, .has, .if, .found, .text, .json, accessors) never mutate.
2. Only real tags work — an invalid #Tag matches nothing, silently
There are ~88 valid part-of-speech tags, and they're a hierarchy (#FirstName ⊂ #Person ⊂
#Noun). A #Tag that isn't real does not error — it just matches nothing, which looks like a
logic bug. Common inventions that are NOT tags: #Name, #Location, #Subject, #Object,
#Adj, #Entity. (Valid ones include #Person, #Place, #Organization, #Noun, #Verb,
#Value, #Date.) When unsure, check node_modules/compromise/docs/tag-definitions.md.
3. Match-syntax is term-level, not regex
.match() matches whole words/terms, not characters. + * ? . ^ $ operate on terms. For
character-level patterns, use a /regex/ token. Cheat sheet (see references for the rest):
| Token | Means | Example |
|---|---|---|
#Tag |
a part-of-speech tag | #Person |
. |
any one term | the . sat |
* |
any run of terms | the * sat |
(a|b) |
one of these | (cat|dog) |
word? |
optional term | the big? cat |
#Tag+ |
one or more | #Adjective+ |
! |
negate a term | the !#Verb |
[ ] / [<name> ] |
capture group | [<who>#Person+] |
^ / $ |
sentence start / end | ^the / sat$ |
~word~ |
fuzzy / typo-tolerant | ~organization~ |
{root} |
match all conjugations | {walk} matches walked/walking |
/regex/ |
character-level regex | /colou?r/ |
nlp('John Smith left').match('[<who>#Person+]').groups('who').text() // 'john smith'
4. Sentences are the ceiling — matches don't cross sentence boundaries
nlp("that's it. Back to Winnipeg!").has('it back') is false. For multi-sentence matching, use
the compromise-paragraphs plugin.
5. compromise is the full build — import it unless size is critical
import nlp from 'compromise'— full library:.people(),.verbs(),.numbers(), all selections. Default.import nlp from 'compromise/two'— POS tags +.match(), but no named selections.import nlp from 'compromise/tokenize'(/one) — tokenize only, no tags (#Tagpatterns won't work).
There's no useful tree-shaking below these tiers; run the full build.
Common tasks (verified patterns)
// entities
nlp(text).people().out('array') // ['Mary', 'Dr. John Smith']
nlp(text).topics().out('array') // people + places + organizations
// NOTE: out('array') keeps trailing punctuation ('Paris.'); use .text('normal') for clean tokens
// transform (remember rule #1 — read from doc)
let d = nlp('I walk'); d.verbs().toPastTense(); d.text() // 'I walked'
let n = nlp('one dog'); n.nouns().toPlural(); n.text() // 'one dogs'
// numbers
nlp('five hundred').numbers().toNumber().text() // '500'
nlp('it cost twelve dollars').numbers().get() // [12]
// find / route (boolean, never mutates)
nlp('the deal is closed').has('#Determiner #Noun') // true
// teach it words
nlp(text, { kermit: 'FirstName' })
자주 묻는 질문
AI 서비스나 인터넷 접속이 필요한가요?
아닙니다. compromise 라이브러리는 네트워크, 모델, 추가 의존성 없이 로컬에서 실행됩니다.
출력에 문장의 일부만 나오는 이유는 무엇인가요?
변환은 문서를 제자리에서 바꾸고 선택된 부분만 반환하므로, 원래 문서 변수에서 전체 텍스트를 읽으세요.
의미를 이해하나요?
완전하지는 않습니다. 규칙 기반 태깅을 사용하므로 깊은 의미 이해를 제공하지 않습니다.
상세 정보
작성자의 원본 설명
Write correct code with the `compromise` JavaScript NLP library (the npm package `compromise`, imported as `nlp`). Use this whenever you are writing or editing JS/TS that imports compromise, calls `nlp(...)`, or chains methods like `.match()`, `.tag()`, `.people()`, `.verbs()`, `.nouns()`, `.numbers()`, `.normalize()`, or `.replace()` — and also whenever doing rule-based natural-language tasks in JavaScript (extracting entities/dates/numbers, matching text patterns, changing verb tense, pluralizing, redacting/anonymizing text, building a simple chatbot intent matcher) where compromise is or co
인기도
- GitHub 스타
- 12k
- 순위
- #11471
- 라이선스
- MIT
- 업데이트
- 2026. 10. 30.
댓글
- …