spencermountain/compromise

modest natural-language processing

What it solves

Compromise addresses the difficulty of parsing and manipulating natural language in JavaScript environments. It provides a lightweight, fast, and "good-enough" way to turn unstructured text into structured data without the overhead of heavy machine learning models.

How it works

It operates by tokenizing text and applying part-of-speech tagging and grammar interpretation. It uses a lexicon of approximately 14,000 words and conjugates them to understand different forms. The library is modular, divided into three tiers: /one for basic tokenization, /two for part-of-speech tagging and grammar, and /three for advanced phrase and sentence-level operations. It allows developers to match, transform, and extract data from text using a chainable, intuitive API.

Who it’s for

It is designed for developers who need to perform basic natural language processing in the browser or Node.js without requiring a massive dependency footprint. It is particularly useful for those building AI agents, LLM-based applications, or text-processing tools where speed and simplicity are prioritized over deep, complex linguistic analysis.

Highlights

  • Lightweight and fast: ~250kb minified, capable of processing ~1MB of text per second.
  • Chainable API: Allows for easy manipulation of text, such as changing verb tenses, pluralizing nouns, or extracting specific entities.
  • Flexible matching: Includes a powerful .match() syntax to find and extract specific patterns within text.
  • Modular architecture: Three distinct tiers allow users to choose the level of complexity needed for their specific task.
  • AI/LLM ready: Includes specific documentation and guidance for integrating with AI agents and LLM workflows.

Related

  • Project
  • Project
  • Project
  • Project
  • Project