starlight-ml
v1.0.0
Published
Lightweight machine learning / text processing utilities for Starlight and JS projects
Maintainers
Readme
Starlight ML
A lightweight JavaScript machine learning utility library for text processing and simple ML tasks. Designed for use in Starlight scripts, Node.js, or browser environments with ES modules (.mjs).
Features
- Tokenization – Split text into words or custom tokens.
- Stopword removal – Filter common words from text.
- Bag-of-Words – Count frequency of words.
- Mapping & utilities – Create dictionaries and perform simple text-to-vector transformations.
- ESM-ready – Can be imported as an ES module.
Installation
Node.js
npm install starlight-mlBrowser (via jsDelivr)
<script type="module">
import * as ml from 'https://cdn.jsdelivr.net/npm/[email protected]/starlight-ml.mjs';
const text = "Hello world! This is Starlight ML.";
const tokens = ml.tokenize(text);
console.log(tokens);
</script>Usage
Import in Node.js
import * as ml from "starlight-ml";
const text = "Machine learning is fun!";
const tokens = ml.tokenize(text);
console.log(tokens); // ["Machine", "learning", "is", "fun"]
console.log(ml.removeStopwords(tokens));
console.log(ml.bagOfWords(tokens));Functions
tokenize(text: string): string[]– Split text into words.removeStopwords(tokens: string[]): string[]– Remove common stopwords.bagOfWords(tokens: string[]): Record<string, number>– Count occurrences of words.mapTokens(tokens: string[], func: Function): any[]– Map over tokens with a custom function.
License
MIT © Dominex Macedon
