compromise-nlp
Fungsinya
Skill ini mengajari AI untuk memakai pustaka compromise guna mencocokkan kata, memberi tag kelas kata, dan mengubah kalimat. Skill ini untuk pengembang JavaScript yang bekerja dengan teks bahasa Inggris.
Kapan dipakai
- βSaat Anda menulis JavaScript yang menemukan kata benda, kata kerja, atau nama dalam teks bahasa Inggris.
- βSaat Anda ingin mengubah kalimat ke bentuk lampau atau menormalkan teks dengan compromise.
- βSaat Anda men-debug kode compromise yang menghasilkan hasil yang tidak Anda harapkan.
Link skill
https://github.com/spencermountain/compromise/blob/master/docs/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βBisakah Anda membantu saya menulis JavaScript yang mengambil nama orang dari sebuah paragraf teks bahasa Inggris?β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
AI mengubah teks menjadi dokumen, memberi tag pada setiap kata, lalu memakai metode seleksi dan transformasi untuk menemukan atau mengubah bagian-bagiannya.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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' })
Pertanyaan umum
Apakah ini memerlukan layanan AI atau akses internet?
Tidak. Pustaka compromise berjalan secara lokal tanpa jaringan, model, atau dependensi tambahan.
Mengapa output saya hanya menampilkan sebagian kalimat?
Transformasi mengubah dokumen di tempat dan hanya mengembalikan bagian yang dipilih, jadi baca teks lengkap dari variabel dokumen asli.
Apakah skill ini memahami makna?
Tidak sepenuhnya. Skill ini memakai pemberian tag berbasis aturan, sehingga tidak menyediakan pemahaman semantik yang mendalam.
Detail
Deskripsi asli dari pembuat
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
Popularitas
- Bintang GitHub
- 12k
- Peringkat
- #11471
- Lisensi
- MIT
- Diperbarui
- 30/10/2026
Komentar
- β¦
Skill lain dari repositori ini
Skill serupa
diffs
394kMemungkinkan agent Anda menghasilkan diff perubahan yang nyata dan dapat dibagikan sebagai tautan viewer atau file gambar, bukan ringkasan yang ditulis manual.
coding-agent
394kMembantu agent Anda menyerahkan pekerjaan pemrograman besar ke Codex, Claude Code, atau OpenCode di latar belakang, lalu memeriksa kemajuannya.
gh-issues
394kMembantu agent Anda menemukan issue GitHub, memilih yang dikerjakan, dan membuka pull request perbaikan, termasuk tindak lanjut komentar tinjauan.