Repolode
spencermountain

spencermountain/compromise

A JavaScript natural language processing library that tags parts of speech, matches text patterns, and transforms text such as verb tenses and numbers.

Stars
12,165
Forks
668
Open issues
93
Last commit
20 hours ago

What is it?

compromise is a lightweight natural language processing library for JavaScript that runs in the browser and in Node.js. It turns raw text into a structured document where you can find nouns, verbs, numbers, dates, people and places, then read them out or rewrite them.

The library offers a small pattern-matching syntax, such as '#Adjective of times', for selecting parts of a sentence, and a set of transforms for things like converting a verb to past tense, pluralizing nouns, expanding contractions, or adding numbers. Results can be exported as text or JSON. The core build is a tokenizer and tagger, with separate entry points for lighter tokenization-only use. Optional plugins extend it, for example compromise-speech for syllables.

The project is English-focused. Sibling packages cover French, German, Italian and Spanish.

Key features

  • 01Part-of-speech tagging with a graph of 83 tags
  • 02Pattern matching with a small match syntax for selecting phrases
  • 03Verb conjugation, noun pluralization and tense conversion
  • 04Number, money, fraction and percentage parsing and arithmetic
  • 05Contraction expansion and text normalization
  • 06Plugin system and a tokenizer-only build for lighter use

Use cases

  • Extracting names, places and dates from article or chat text
  • Generating or correcting English sentences with proper verb forms
  • Parsing numbers and currency from user input in forms or search
  • Running lightweight text analysis directly in a browser

Quick start

  1. 1

    Install the library from npm

    npm install compromise
  2. 2

    Import it and run a quick example on a sentence

Things to know

  • It is not as smart as it sounds, relying on limited, rule-based decisions.
  • The full library is about 250kb minified, which is large for small bundles.
  • Other languages are provided only as separate projects such as fr-compromise, de-compromise, it-compromise, and es-compromise.

Topics

FAQ

What is compromise?
A JavaScript natural language processing library that tags parts of speech, matches text patterns, and transforms text such as verb tenses and numbers. compromise is a lightweight natural language processing library for JavaScript that runs in the browser and in Node.js. It turns raw text into a structured document where you can find nouns, verbs, numbers, dates, people and places, then read them out or rewrite them.
Is compromise free to use? What license does it have?
compromise is open source under the MIT license. Check the license terms before using it in commercial products.
Is compromise still maintained?
Actively maintained. The last commit to compromise was on Oct 19, 2026.
What can I use compromise for?
Extracting names, places and dates from article or chat text Generating or correcting English sentences with proper verb forms Parsing numbers and currency from user input in forms or search Running lightweight text analysis directly in a browser
How do I install compromise?
Install the library from npm: npm install compromise Import it and run a quick example on a sentence
Where can I get compromise?
The source code and installation instructions are on GitHub: https://github.com/spencermountain/compromise

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects