LexioJS

A lightweight (~7.60 kb minified) simple JavaScript library for Natural Language Processing (NLP) tasks.

Overview

Lexio.js provides various classes and methods for text processing, sentiment analysis, named entity recognition, stemming, and lemmatization.

Classes

Lexio

The core class containing Tokenizer and StopWordRemover.

LexioSentimentAnalyzer

Analyzes sentiment of input text.

Lner (Named Entity Recognizer)

Identifies named entities in input text.

LexioPorterStemmer

Stems input tokens.

LexioLemmatizer

Lemmatizes input text.

Usage

Importing Lexio.js

You can use a CDN to include Lexio in directly in your project!

<script src="(link unavailable)"></script>

Tokenization

const lexio = new Lexio();
const tokenizer = new lexio.Tokenizer();
const tokens = tokenizer.tokenize('This is an example sentence.');
console.log(tokens); // Output: ["This", "is", "an", "example", "sentence"]

Sentiment Analysis

const lexio = new Lexio();
const sentimentAnalyzer = new LexioSentimentAnalyzer();
const sentiment = sentimentAnalyzer.analyzeSentiment('I love this product!');
console.log(sentiment); // Output: "positive"

Named Entity Recognition

const lexio = new Lexio();
const ner = new Lner();
const entities = ner.identifyEntities('John Smith is a software engineer at Google.');
console.log(entities); // Output: [{"token": "John Smith", "type": "Person"}, {"token": "Google", "type": "Organization"}]

Stemming

const stemmer = new LexioPorterStemmer();
const stemmedToken = stemmer.stem('running');
console.log(stemmedToken); // Output: "run"
Here's the remaining HTML code: ```

Lemmatization

const lemmatizer = new LexioLemmatizer();
const lemmatizedTokens = lemmatizer.lemmatize('The quick brown fox jumps over the lazy dog.');
console.log(lemmatizedTokens); // Output: ["The", "quick", "brown", "fox", "jump", "over", "the", "lazy", "dog"]

License

Lexio.js is licensed under the MIT License.

Contributing

Pull requests and issues are welcome!