A lightweight (~7.60 kb minified) simple JavaScript library for Natural Language Processing (NLP) tasks.
Lexio.js provides various classes and methods for text processing, sentiment analysis, named entity recognition, stemming, and lemmatization.
The core class containing Tokenizer and StopWordRemover.
Tokenizer
tokenize(text: string)
: Tokenizes the input text into individual words or tokens.removePunctuation(text: string)
: Removes punctuation from the input text.expandContractions(text: string)
: Expands contractions in the input text.StopWordRemover
removeStopWords(tokens: array)
: Removes stopwords from the input tokens.Analyzes sentiment of input text.
analyzeSentiment(text: string)
: Analyzes sentiment of the input text.Identifies named entities in input text.
identifyEntities(text: string)
: Identifies named entities in the input text.Stems input tokens.
stem(token: string)
: Stems the input token.Lemmatizes input text.
lemmatize(text: string)
: Lemmatizes the input text.You can use a CDN to include Lexio in directly in your project!
<script src="(link unavailable)"></script>
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"]
const lexio = new Lexio();
const sentimentAnalyzer = new LexioSentimentAnalyzer();
const sentiment = sentimentAnalyzer.analyzeSentiment('I love this product!');
console.log(sentiment); // Output: "positive"
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"}]
const stemmer = new LexioPorterStemmer();
const stemmedToken = stemmer.stem('running');
console.log(stemmedToken); // Output: "run"
Here's the remaining HTML code:
```
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"]
Lexio.js is licensed under the MIT License.
Pull requests and issues are welcome!