$ show loretoparisi/fasttext.js
FastText.js is a Node.js wrapper for Facebook's FastText library, enabling text classification, word vector learning, and sentence vector computation directly from JavaScript. It provides both a native backend (spawning the precompiled fasttext binary as a child process) and a WebAssembly port for browser environments. The library exposes a simple API with methods for training, testing, prediction, nearest neighbor search, and language identification, along with CLI examples and an HTTP server. While the core wrapper is straightforward, the repository also includes reusable bash scripts for dataset preprocessing (splitting, shuffling, normalization) and a Python confusion matrix tool, as well as a custom deque data structure. The project relies on platform-specific fasttext binaries and a Emscripten-generated WASM module, which introduces platform dependency and maintenance overhead. Installation via npm is trivial, but the codebase shows signs of technical driftβoutdated Docker base images, Node version, and manually patched WASM glue codeβsuggesting moderate maintenance activity but not active evolution.
The LLM identified 3 files worth highlighting for reuse:
A self-contained, MIT-licensed deque (double-ended queue) implementation with dynamic capacity resizing. Suitable for any JavaScript project needing efficient queue operations. Demonstrates careful handling of capacity thresholds and circular buffer management.
A parameterized bash script to split a TSV/CSV dataset into training and test sets by ratio. Accepts input file, output folder, and split ratio as arguments. Can be reused for any labeled dataset preprocessing pipeline without modification.
A standalone Python script that reads fasttext prediction output (label: [score]) and generates a confusion matrix with precision, recall, F1 per class, and a heatmap visualization. Uses argparse for input/output paths and pandas/matplotlib for computation and plotting. Self-contained and reusable with any classification result in the same format.