Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function parseJob(markup) {
// gets the first sentence in Wikipedia markup
var sentence = WikipediaApi.plaintext(markup).split(/\. [A-Z]/)[0];
// split after name and DOB
var arr = sentence.split(' is ');
arr.splice(0, 1);
// get their job
var job = arr.join(' is ').replace(/^a /, '').replace(/^an /, '').replace(/^the /, '');
job = job.split(' who')[0];
job = job.split(', where')[0];
job = job.split(' from')[0];
job = job.split('; ')[0];
job = job.replace(/[,.:;!@#$%^&*()+ ]+$/, '');
// if job description is over 90 characters, is probably bad.
return job.length > 90 ? '' : job;
};
wtf_wikipedia.from_api(title, lang, function (markup) {
let text = wtf_wikipedia.plaintext(markup) || '';
let filename = __dirname + '/corpus/' + title + '.txt';
fs.writeFileSync(filename, text, 'utf8')
let mb = (fs.statSync(filename).size || 0) / 1000000.0;
console.log(title + ' - ' + mb.toFixed(2) + 'mb');
cb(null, '');
});
};
wikipedia.from_api(args, "en", function(markup){
var text = wikipedia.plaintext(markup).substring(0,100) + "...";
if (text != "...") {
chan.say(text + " https://en.wikipedia.org/w/index.php?title=" + encodeURIComponent(args));
} else {
chan.say("No page found");
}
});
} else {