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.
ngram-natural-language-generator
Advanced tools
Takes in a text/file/stream and generates random sentences that sound like they could have been in the text
Takes in text/file(s)/stream(s) and generates random sentences that sound like they could have been in the original text using a bigram generator. Surprisingly works on most languages and writing styles.
You can experiment with your own texts here http://cesine.github.io/ngram-natural-language-generator/samples
$ npm install ngram-natural-language-generator --save
$ ./index.js samples/jaberwocky.txt
$ bower install ngram-natural-language-generator --save
There is an example browser use in samples/index.html.
<textarea id="ngram-nlg-text"></textarea>
<textarea id="ngram-nlg-result"></textarea>
<script>
window.NLG = window.exports = window.exports || {};
</script>
<script src="bower_components/ngram-natural-language-generator/lib/tokenizer.js"></script>
<script src="bower_components/ngram-natural-language-generator/lib/nlg.js"></script>
<script src="bower_components/ngram-natural-language-generator/lib/ngrams.js"></script>
<script src="bower_components/ngram-natural-language-generator/lib/ngram-nlg.js"></script>
<script src="bower_components/ngram-natural-language-generator/lib/drag-and-drop-file-upload.js"></script>
<script>
NLG.currentOptions = {
text: ''
};
NLG.currentOptions.text = document.getElementById('ngram-nlg-text').value;
NLG.build(NLG.currentOptions, function(err, result){
if (err) return console.warn(err);
document.getElementById('ngram-nlg-result').value = NLG.generate(NLG.currentOptions.model);
});
</script>
From file:
var generator = require('ngram-natural-language-generator').generator;
generator({
filename: 'samples/jabberwocky.txt',
model: {
maxLength: 100,
minLength: 50
}
}, function(err, sentence){
console.log(sentence);
// One two. Callooh. Beware the borogoves And the claws that bite the Jabberwock my
// beamish boy. One two. One two. And through the mome raths outgrabe. And stood The
// frumious Bandersnatch. He took his joy. And the borogoves And the claws that bite the
// wabe All mimsy were the Jabberwock with eyes of flame Came whiffling through and the
// slithy toves Did gyre and through The Jabberwock. Twas brillig and shun The Jabberwock
// my son. Beware the borogoves And the mome raths outgrabe. Beware the Jabberwock. Come
// to my son.
});
From text:
var generator = require('ngram-natural-language-generator').generator;
generator({
text: 'Colorless green ideas sleep furiously.',
model: {
maxLength: 100,
minLength: 50
}
}, function(err, sentence){
console.log(sentence);
});
From web url:
var generator = require('ngram-natural-language-generator').generator;
var http = require('http');
http.get('http://www.jabberwocky.com/carroll/jabber/jabberwocky.html', function(res) {
generator({
stream: res
}, function(err, sentence){
console.log(sentence);
});
});
From tokens:
If you're working with a language which doesn't tokenize on whitespace or unicode punctionation you can supply the tokens.
var generator = require('ngram-natural-language-generator').generator;
generator({
tokens: ['その', '酩酊', '状態を', '愛する', 'ことに', 'よって'],
model: {
maxLength: 100,
minLength: 50
}
}, function(err, sentence){
console.log(sentence);
});
FAQs
Takes in a text/file/stream and generates random sentences that sound like they could have been in the text
The npm package ngram-natural-language-generator receives a total of 4 weekly downloads. As such, ngram-natural-language-generator popularity was classified as not popular.
We found that ngram-natural-language-generator 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.