मुख्य सामग्री पर जाएँ
Skillpedia
सामान्य कोडिंग12k · #11471

compromise-nlp

यह क्या करती है

यह AI को compromise लाइब्रेरी से शब्दों का मिलान करने, शब्द-भेद टैग करने और वाक्य बदलने का तरीका सिखाती है। यह अंग्रेज़ी टेक्स्ट के साथ काम करने वाले JavaScript डेवलपर्स के लिए है।

कब इस्तेमाल करें

  • ✓जब आप ऐसा JavaScript लिख रहे हैं जो अंग्रेज़ी टेक्स्ट में संज्ञा, क्रिया या नाम ढूँढे।
  • ✓जब आप compromise से वाक्य भूतकाल में बदलना या टेक्स्ट को सामान्य रूप देना चाहते हैं।
  • ✓जब आप compromise कोड डीबग कर रहे हैं जो अपेक्षा से अलग नतीजे देता है।

Skill का लिंक

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

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/spencermountain/compromise/blob/master/docs/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“क्या आप ऐसा JavaScript लिखने में मदद कर सकते हैं जो अंग्रेज़ी पैराग्राफ़ से व्यक्तियों के नाम निकाले?”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

AI टेक्स्ट को एक document में बदलता है, हर शब्द को टैग करता है, फिर selection और transform methods से उसके हिस्से ढूँढता या बदलता है।

तकनीकी सामग्री (मूल 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 (#Tag patterns 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 लाइब्रेरी बिना नेटवर्क, मॉडल या अतिरिक्त निर्भरता के स्थानीय रूप से चलती है।

मेरा आउटपुट वाक्य का केवल हिस्सा क्यों दिखाता है?

Transforms document को उसी जगह बदलते हैं और केवल चुना हुआ हिस्सा लौटाते हैं, इसलिए पूरा टेक्स्ट मूल document variable से पढ़ें।

क्या यह अर्थ समझती है?

पूरी तरह नहीं। यह नियम-आधारित टैगिंग इस्तेमाल करती है, इसलिए यह गहरी अर्थ-समझ नहीं देती।

जानकारी

लेखक का मूल विवरण

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

repo: spencermountain/compromise

लोकप्रियता

GitHub स्टार
12k
रैंकिंग में स्थान
#11471
लाइसेंस
MIT
अपडेट की गई
30/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills