Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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!
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
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%
.
This project is targeting the Node v18 LTS
. Target for ts
is set to ES3
to support all browsers with lower versions.
node
installed with at least v18+
npm ci
Installation is simple:
npm i nlp-chasm
You have access to all modules exported from the project, but in reality you probably need only one of them.
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[][];
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.
This project has just been made public, thus the documentation will be updated soon to cover all the aspects.
FAQs
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!
We found that nlp-chasm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.