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

core-functions.mddocs/

Core Factory Functions

Factory functions for creating and analyzing different text units and linguistic elements. These functions serve as the primary entry points for nlp_compromise operations.

Capabilities

Text Factory Function

Creates a Text object for analyzing multi-sentence text with comprehensive NLP operations.

/**
 * Creates a Text object for multi-sentence analysis
 * @param {string} str - Input text (can contain multiple sentences)
 * @param {object} [options] - Optional parsing configuration
 * @returns {Text} Text object with sentence-level operations
 */
function text(str, options);

Usage Examples:

const nlp = require('nlp_compromise');

// Multi-sentence text analysis
const doc = nlp.text('Hello world. How are you today? Great weather!');
console.log(doc.sentences.length); // 3

// Extract all people from text
const people = nlp.text('Tony Hawk and Elon Musk are innovators').people();
console.log(people[0].text); // 'Tony Hawk'

Sentence Factory Function

Creates a Sentence object for single sentence analysis and transformations.

/**
 * Creates a Sentence object for single sentence operations
 * @param {string} str - Input sentence text
 * @param {object} [options] - Optional parsing configuration
 * @returns {Sentence} Sentence object with term-level operations
 */
function sentence(str, options);

Statement Factory Function

Creates a Statement object specifically for declarative sentences.

/**
 * Creates a Statement object for declarative sentences
 * @param {string} str - Declarative sentence text
 * @returns {Statement} Statement object extending Sentence
 */
function statement(str);

Question Factory Function

Creates a Question object specifically for interrogative sentences.

/**
 * Creates a Question object for interrogative sentences
 * @param {string} str - Question sentence text
 * @returns {Question} Question object extending Sentence
 */
function question(str);

Usage Examples:

// Sentence transformations
const stmt = nlp.statement('She walks to school');
console.log(stmt.to_past().text()); // 'She walked to school'

// Question analysis
const q = nlp.question('Where did she go?');
console.log(q.from()); // 'where'

Term Factory Function

Creates a Term object for individual word analysis.

/**
 * Creates a Term object for single word operations
 * @param {string} str - Individual word or term
 * @returns {Term} Term object with basic word operations
 */
function term(str);

Noun Factory Function

Creates a Noun object with noun-specific inflection methods.

/**
 * Creates a Noun object with pluralization and classification
 * @param {string} str - Noun word
 * @returns {Noun} Noun object with inflection methods
 */
function noun(str);

Usage Examples:

// Noun operations
const n = nlp.noun('cat');
console.log(n.pluralize()); // 'cats'
console.log(n.article()); // 'a'

// Check noun properties
console.log(nlp.noun('children').is_plural()); // true
console.log(nlp.noun('water').is_uncountable()); // true

Verb Factory Function

Creates a Verb object with conjugation and tense methods.

/**
 * Creates a Verb object with conjugation capabilities
 * @param {string} str - Verb word
 * @returns {Verb} Verb object with tense and conjugation methods
 */
function verb(str);

Usage Examples:

// Verb conjugation
const v = nlp.verb('run');
console.log(v.to_past()); // 'ran'
console.log(v.conjugate());
// { infinitive: 'run', present: 'runs', past: 'ran', gerund: 'running' }

// Tense analysis
console.log(nlp.verb('running').tense()); // 'present'

Adjective Factory Function

Creates an Adjective object with comparison methods.

/**
 * Creates an Adjective object with comparative/superlative forms
 * @param {string} str - Adjective word
 * @returns {Adjective} Adjective object with comparison methods
 */
function adjective(str);

Usage Examples:

// Adjective comparisons
const adj = nlp.adjective('big');
console.log(adj.to_comparative()); // 'bigger'  
console.log(adj.to_superlative()); // 'biggest'
console.log(adj.to_adverb()); // 'bigly'

Adverb Factory Function

Creates an Adverb object with conversion methods.

/**
 * Creates an Adverb object
 * @param {string} str - Adverb word
 * @returns {Adverb} Adverb object with conversion methods
 */
function adverb(str);

Value Factory Function

Creates a Value object for numeric values and measurements.

/**
 * Creates a Value object for parsing numbers and units
 * @param {string} str - Numeric value with optional unit
 * @returns {Value} Value object with numeric parsing
 */
function value(str);

Usage Examples:

// Numeric value parsing
const val = nlp.value('five hundred dollars');
console.log(val.number); // 500
console.log(val.unit); // 'dollar'
console.log(val.measurement); // 'Money'

// Unit conversion awareness
const temp = nlp.value('98.6 degrees fahrenheit');
console.log(temp.measurement); // 'Temperature'

Person Factory Function

Creates a Person object for person name analysis.

/**
 * Creates a Person object for name parsing and analysis
 * @param {string} str - Person name
 * @returns {Person} Person object with name parsing
 */
function person(str);

Date Factory Function

Creates a Date object for date parsing.

/**
 * Creates a Date object for temporal parsing
 * @param {string} str - Date expression
 * @returns {Date} Date object with date parsing
 */
function date(str);

Place Factory Function

Creates a Place object for location analysis.

/**
 * Creates a Place object for location parsing
 * @param {string} str - Place name
 * @returns {Place} Place object with location analysis
 */
function place(str);

Organization Factory Function

Creates an Organization object for organization name analysis.

/**
 * Creates an Organization object for organization parsing
 * @param {string} str - Organization name
 * @returns {Organization} Organization object
 */
function organization(str);

Usage Examples:

// Entity creation and analysis
const person = nlp.person('Dr. Jane Smith');
console.log(person.firstName); // 'Jane'
console.log(person.lastName); // 'Smith'
console.log(person.honourific); // 'Dr.'

const place = nlp.place('New York City');
console.log(place.city); // 'New York City'

const org = nlp.organization('Apple Inc.');
console.log(org.text); // 'Apple Inc.'

docs

core-functions.md

entity-recognition.md

index.md

plugin-system.md

sentence-processing.md

text-analysis.md

word-operations.md

tile.json