Lightweight machine learning / text processing utilities for Starlight and JS projects
npm install starlight-ml.mjs).
bash
npm install starlight-ml
``
$3
`html
`
---
Usage
$3
`javascript
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));
`
$3
* tokenize(text: string): string[] – Split text into words.
* removeStopwords(tokens: string[]): string[] – Remove common stopwords.
* bagOfWords(tokens: string[]): Record – Count occurrences of words.
* mapTokens(tokens: string[], func: Function): any[]` – Map over tokens with a custom function.