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 🙏

© 2024 – Pkg Stats / Ryan Hefner

nlp-chasm

v1.0.2

Published

Split your long text into paragraphs using NLP attributes. Chasm allows you to easily split your long text with just a suingle command, all you need are a few language attributes for each token. That's it!

Downloads

6

Readme

📄 Chasm – tiny, fast, paragraph!

npm version npm test & build codecov

Chasm is a very tiny and useful tool when you are processing raw sentences and would like to have a way to split those sentences into paragraphs, but if you dont know how to do it quickly and easily this tool can help you with that task!

Chasm is easily extended within the project and can currently provide the following algorithms:

  • cosine similarity
  • more to come...

Library is extremely fast and simple, id does not have any other dependencies and is easy to install, use and extend when needed.

Test coverage is always kept at > 99%.

Dev requirements

This project is targeting the Node v18 LTS. Target for ts is set to ES3 to support all browsers with lower versions.

  • Have node installed with at least v18+
  • Install required packages with npm ci

Installation

Installation is simple:

npm i nlp-chasm

Usage

You have access to all modules exported from the project, but in reality you probably need only one of them.

Basic usage

Here is an example how to use the chasm library in your project:

// improt it
import chasm from "nlp-chasm";

// use it
const paragraphs = chasm(sentences);

// use your paragraphs later...

Where the type of the chasm function is as follows:

export type Chasm = (sentences: Sentence[], threshold?: number) => ChasmResult;

Your sentences must follow a specific structure which is defined in the types of this library. Here, below, you can see the structure you must use:

export interface Token {
  index: number;
  token: string;
}

export interface Sentence {
  index: number;
  tokens: Token[];
}

An example of this structure will look like this:

[
    {
        index: 0,
        tokens: [
            { index: 0, "token1" },
            { index: 1, "token2" },
            { index: 2, "token3" },
        ]
    },
    {
        index: 1,
        tokens: [
            { index: 0, "token10" },
            { index: 1, "token11" }
        ]
    }
]

When you run the chasm method to split your sentences into paragraphs then you will receive a result of the following structure:

[
    [
        {
            index: 0,
            tokens: [
                { index: 0, "token1" },
                { index: 1, "token2" },
                { index: 2, "token3" },
            ]
        }
    ],
    [
        {
            index: 1,
            tokens: [
                { index: 0, "token10" },
                { index: 1, "token11" }
            ]
        }
    ]
]

This is defined as the following:

export type ChasmResult = Sentence[][];

Advanced configuration

Currently there is not much to configure, the common property which is optional is the threshold?: number property. This defines threshold for similarity between sentences. All values must be between [0, 1] for threshold.

Note

This project has just been made public, thus the documentation will be updated soon to cover all the aspects.