npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, πŸ‘‹, I’m Ryan HefnerΒ  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you πŸ™

Β© 2026 – Pkg Stats / Ryan Hefner

punctuation-restore

v0.1.0

Published

πŸ§‘β€πŸ­ Node.js package for restoring punctuation and casing to strings via ONNX Model `punctuation_fullstop_truecase_english`

Readme

πŸ§‘β€πŸ­ Punctuation Restore

A Node.js package that restores punctuation and casing to unpunctuated text using the punctuation_fullstop_truecase_english ONNX model: https://huggingface.co/1-800-BAD-CODE/punctuation_fullstop_truecase_english

punctuation-restore

Features

  • Restores punctuation marks (periods, commas, question marks, etc.)
  • Handles casing
  • Supports batch processing of multiple texts
  • Uses efficient ONNX runtime for inference
  • Automatically downloads required models

Notes

  • Models are automatically downloaded from Hugging Face on first use and saved locally to the ./models directory for future use.
  • Punctuation correction isn't perfect, but it's good enough for most use cases (use with caution).

Installation

npm install punctuation-restore

Quick Start

import PunctuationRestorer from 'punctuation-restore';

const restorer = new PunctuationRestorer();

const texts = [
  "this is a string without any punctuation or casing yesterday i went to disneyworld and had a great time",
  "washing your dog once a month is important nothing quite beats a walk on the beach"
];

const results = await restorer.restore(texts);
console.log(results);

API Reference

PunctuationRestorer

The main class for handling punctuation restoration.

Methods

  • async restore(texts: string[]): Promise<string[]>

    • Takes an array of unpunctuated texts
    • Returns an array of punctuated and cased sentences
    • Automatically handles model initialization and cleanup
  • async cleanup()

    • Manually release ONNX session resources
    • Called automatically after restore(), but can be called explicitly if needed

Model Architecture

The package uses two main models:

  • model.onnx: Main ONNX model for punctuation and casing prediction
  • tokenizer.model: Tokenizer model for text preprocessing

Models are automatically downloaded from Hugging Face on first use and saved locally to the ./models directory for future use.

Example

Check out example/example.js for a complete working example:

import PunctuationRestorer from '../punctuationRestore.js';

const testTexts = [
  "this is a string without any punctuation or casing yesterday i went to disneyworld and had a great time",
  "washing your dog once a month is important nothing quite beats a walk on the beach"
];

try {
    const restorer = new PunctuationRestorer();
    const results = await restorer.restore(testTexts);
    results.forEach(result => console.log(result));
} catch (error) {
    console.error('Test failed:', error);
}

Development

Scripts

  • npm run clean: Clean install dependencies
  • npm run example: Run the example script

Project Structure

punctuation-restore/
β”œβ”€β”€ modules/
β”‚   β”œβ”€β”€ downloadModel.js    # Model download handling
β”‚   β”œβ”€β”€ tokenizer.js        # Text tokenization
β”‚   └── postProcessor.js    # Output processing
β”œβ”€β”€ example/
β”‚   └── example.js         # Usage example
└── punctuationRestore.js  # Main package entry

Dependencies

  • onnxruntime-node: ^1.16.3 - ONNX runtime for Node.js
  • sentence-parse: ^1.3.0 - Sentence parsing utilities

License

MIT