CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-nlp-compromise

Natural language processing library that analyzes, transforms, and extracts meaning from English text in browsers and Node.js

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

nlp_compromise

nlp_compromise is a lightweight natural language processing library for JavaScript that performs NLP operations directly in browsers and Node.js environments. It provides a fluent API for understanding, analyzing, transforming, and extracting meaning from English text without dependencies or configuration.

Package Information

  • Package Name: nlp_compromise
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install nlp_compromise

Core Imports

const nlp = require('nlp_compromise');

For browser environments:

<script src="https://unpkg.com/nlp_compromise@latest/builds/nlp_compromise.min.js"></script>
<script>
  const nlp = window.nlp_compromise;
</script>

Basic Usage

const nlp = require('nlp_compromise');

// Parse and transform text
nlp.sentence('She sells seashells').to_past().text();
// 'She sold seashells'

// Extract entities
nlp.text('Tony Hawk did a kickflip').people();
// [Person { text: 'Tony Hawk' ... }]

// Word-level operations
nlp.noun('dinosaur').pluralize();
// 'dinosaurs'

nlp.verb('speak').conjugate();
// { past: 'spoke', infinitive: 'speak', gerund: 'speaking', ... }

Architecture

nlp_compromise is built around several key components:

  • Factory Functions: Core constructors (text, sentence, noun, verb, etc.) that create typed objects
  • Text Processing: Multi-sentence text analysis with entity extraction and transformations
  • Sentence Analysis: Single sentence operations including POS tagging, pattern matching, and grammatical transformations
  • Term Hierarchy: Specialized term types (Noun, Verb, Adjective, Adverb) with part-of-speech specific methods
  • Entity Recognition: Automatic detection and classification of people, places, dates, values, and organizations
  • Plugin System: Extensible architecture for adding custom functionality

Capabilities

Core Factory Functions

Factory functions for creating and analyzing different text units and linguistic elements.

function text(string, options?): Text;
function sentence(string, options?): Sentence;
function statement(string): Statement;
function question(string): Question;
function term(string): Term;
function noun(string): Noun;
function verb(string): Verb;
function adjective(string): Adjective;  
function adverb(string): Adverb;
function value(string): Value;
function person(string): Person;
function date(string): Date;
function place(string): Place;
function organization(string): Organization;

Core Functions

Text Analysis

Multi-sentence text processing with comprehensive entity extraction, pattern matching, and document-level transformations.

class Text {
  sentences: Sentence[];
  raw_text: string;
  
  text(): string;
  normal(): string;
  root(): string;
  terms(): Term[];
  tags(): string[][];
  match(pattern: string, options?): Result[];
  replace(pattern: string, replacement: string, options?): Text;
}

Text Analysis

Sentence Processing

Single sentence analysis including grammatical transformations, pattern matching, and entity extraction.

class Sentence {
  terms: Term[];
  str: string;
  
  text(): string;
  normal(): string;
  sentence_type(): string;
  terminator(): string;
  match(pattern: string, options?): Result[];
  replace(pattern: string, replacement: string, options?): Sentence;
}

Sentence Processing

Word-Level Operations

Individual word and term analysis with part-of-speech specific methods for inflection, conjugation, and classification.

class Term {
  text: string;
  normal: string;
  pos: object;
  tag: string;
  
  root(): string;
  match(pattern: string, options?): boolean;
  forms(): object;
}

Word-Level Operations

Entity Recognition

Automatic detection, extraction, and analysis of named entities including people, places, dates, values, and organizations.

class Person extends Noun {
  firstName: string;
  lastName: string;
  gender(): string;
  pronoun(): string;
}

class Value extends Noun {
  number: number;
  unit: string;  
  measurement: string;
}

Entity Recognition

Plugin System

Extensible plugin architecture for adding custom functionality and extending existing classes.

function plugin(obj): void;
function lexicon(obj?): object;

Plugin System

Types

// Core result types
interface Result {
  terms: Term[];
  match(string, options?): Result[];
  normal(): string;
  replace(words: string[]): Result;
  text(): string;
}

// Contractions helper
interface Contractions {
  expand(): Text | Sentence;
  contract(): Text | Sentence;
}

// Topic extraction result
interface Topic {
  count: number;
  text: string;
}
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/nlp_compromise@6.5.x
Publish Source
CLI
Badge
tessl/npm-nlp-compromise badge