Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
dropsuit-bow
Advanced tools
Readme
DropSuit NLP is an open-source JavaScript and Node.js library offering diverse functions for natural language processing and data manipulation. The bow function is one of its modules, designed for generating a bag of words from input text and data requests. It returns an array of 'bag of words'. It is available under the Apache License 2.0.
The bow function is a part of the DropSuit NLP library, it's a JavaScript and Node.js function that generates a bag of words from input text and data requests, it returns an array of 'bag of words'. It's open-source and available under the Apache License 2.0.
Add the library function by installing it via npm:
npm install dropsuit-bow
Import the library in your project:
const dropsuit_bow = require("dropsuit-bow");
The provided code imports the Dropsuit Bow library into your project. You can create a new instance of the dropsuit_bow class by passing in null as the argument, which will process the basic bag of words from the input sentence. If you want to see the processing results in the terminal, you can set the second argument to true when creating the instance, like this:
let dsbow = new dropsuit_bow(null, false);
{ 'word': 1 }
.[ 0, 1 ]
{ 'a': 1 }
.let input = "John likes to watch movies. Mary likes movies too.";
let out = dsbow.bow(input);
console.log(out);
Processing output:
{
tokenized: [
'john', 'likes',
'to', 'watch',
'movies', 'mary',
'too'
],
word_bow: { john: 1, likes: 2, to: 1, watch: 1, movies: 2, mary: 1, too: 1 },
val_vect: [
1, 2, 1, 1,
2, 1, 1
],
proc_str: 'john likes to watch movies mary likes movies too',
cont_str: 'johnlikestowatchmoviesmarylikesmoviestoo',
char_frq: {
j: 1,
o: 6,
h: 2,
n: 1,
l: 2,
i: 4,
k: 2,
e: 4,
s: 4,
t: 3,
w: 1,
a: 2,
c: 1,
m: 3,
v: 2,
r: 1,
y: 1
},
tokens: [Function: tokens],
vector: [Function: vector],
values: [Function: values],
chars: [Function: chars],
design: [Function: design]
}
The design(type, delimiter) option in the bow() function returns the output strings in pascal or camel case with the specified delimiter. The type parameter can be either "pascal" or "camel". The delimiter parameter is optional and can be any string. If not provided, the default delimiter is an empty string. Here's an example usage:
let input = "The camel walks through the hot desert";
let dsbdes = new dropsuit_bow(null, false);
Then, we can use the design function to generate different string representations, like this:
// Default (no arguments) returns a space separated string
let output1 = dsbdes.bow(input).design(); // the camel walks through the hot desert
// Empty delimiter returns a string without spaces
let output2 = dsbdes.bow(input).design(""); // thecamelwalksthroughhotdesert
// Delimiter "-" returns a hyphen separated string in kebab case
let output3 = dsbdes.bow(input).design("", "-"); // the-camel-walks-through-hot-desert
// Pascal case with no delimiter and 'pascal-' minus '-' property to remove duplicates
let output4 = dsbdes.bow(input).design("pascal-"); // TheCamelWalksThroughHotDesert
// Pascal case with delimiter "~"
let output5 = dsbdes.bow(input).design("pascal", "~"); // The~Camel~Walks~Through~The~Hot~Desert
// Camel case with no delimiter
let output6 = dsbdes.bow(input).design("camel"); // theCamelWalksThroughTheHotDesert
// Camel case with delimiter " @" and 'camel-' minus '-' property to remove duplicates
let output7 = dsbdes.bow(input).design("camel-", " @"); // the @Camel @Walks @Through @Hot @Desert
Refer to the tests for more information on how to use additional options for Bag of Words. You can provide an 'intentData' object from the intents.json file to the constructor using the 'jsonIntStrct' function, as shown below:
const json_data = require("dropsuit-bow/jsobj.js");
let intentData = json_data.jsonIntStrct("assets/json/intents.json");
Alternatively, you can provide an array of strings to the constructor as input:
let inputArray = [
"John likes to watch movies. Mary likes movies too.",
"Mary also likes to watch football games.",
];
DropSuit is an open-source library and I am dedicated to ensuring its continued development and improvement. If you have any questions, feedback, or encounter any issues, please reach out through the support via PayPal, and read more about support details.
Your support is crucial for the library's success. You can also contribute to the project by submitting bug reports, feature requests, or by providing feedback. Sharing the library with others who may find it useful and giving it a star on GitHub are also great ways to show your support. Thank you for using DropSuit!
FAQs
DropSuit NLP - bow function: A JavaScript and Node.js library for generating a bag of words from input and data requests
The npm package dropsuit-bow receives a total of 0 weekly downloads. As such, dropsuit-bow popularity was classified as not popular.
We found that dropsuit-bow 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.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.