Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
transcript-parser
Advanced tools
Readme
Parses plaintext speech/debate/radio transcripts into JavaScript objects. It is still in early development. Pull requests are welcome.
Tests can be run with npm test
and a benchmark can be run with npm run benchmark
. For a full coverage report using Istanbul, run npm run travis-test
.
Tested for Node.js >= v4.4.6
npm install transcript-parser
'use strict';
const fs = require('fs');
const TranscriptParser = require('transcript-parser');
const tp = new TranscriptParser();
//Synchronous example
const parsed = tp.parseOneSync(fs.readFileSync('transcript.txt', 'utf8'));
console.log(parsed);
//Asynchronous example
fs.readFile('transcript.txt', (err, data) => {
if(err) return console.error('Error:', err);
tp.parseOne(data, (err, parsed) => {
if(err) return console.error('Error:', err);
console.log(parsed);
}));
});
//Stream example
const stream = fs.createReadStream('transcript.txt', 'utf8');
tp.parseStream(stream, (err, parsed) => {
if(err) return console.error('Error:', err);
console.log(parsed);
});
The constructor for TranscriptParser
accepts an options argument.
removeActions
true
removeAnnotations
true
[]
).removeTimestamps
true
removeAnnotations
is true[##:##:##]
format).removeUnknownSpeakers
false
none
.blacklist
[]
aliases
{}
Array
of the aliases' regular expressions as the value.{ "Mr. Robot": [ /[A-Z\ ]*SLATER[A-Z\ ]*/ ] }
The parseStream()
method parses a Stream
and returns an object representing it.
This is the preferred method for parsing streams asynchronously as it doesn't have to load the entire transcript into memory (unlike parseOne()
).
tp.parseOneSync(stream, callback)
stream
Readable
stream to read.callback(err, data)
The parseOneSync()
method parses a string and returns an object representing it.
tp.parseOneSync(transcript)
transcript
string
.The parseOne()
method parses a string and returns an object representing it.
tp.parseOne(transcript, callback)
transcript
string
.callback(err, data)
The resolveAliasesSync()
method resolves all aliases specified in the configuration passed to the TranscriptParser
's constructor (see above).
Renames the names in the order
list to match the new names in the transcript. Note that there is a signifigant performance penalty, so don't use this method unless you need it.
tp.resolveAliasesSync(data)
data
The resolveAliases()
method resolves all aliases specified in the configuration passed to the TranscriptParser
's constructor (see above).
Renames the names in the order
list to match the new names in the transcript. Note that there is a signifigant performance penalty, so don't use this method unless you need it.
tp.resolveAliases(data, callback)
data
callback(err, resolved)
FAQs
Parses plaintext speech/debate/radio transcripts into JavaScript objects.
We found that transcript-parser 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
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).