const langs = require('./languages.json'); try { old = new Date(); console.log("LangDetect Autotraining v1, using LangDetect Training API v1"); const train = require('./filer'); const fs = require('fs'); global.__train_totallangs = 0; global.__train_donelangs = 0; langs.forEach((lang) => { if (fs.existsSync("./train/" + lang.code)) { __train_totallangs++; } }) langs.forEach((lang) => { if (fs.existsSync("./train/" + lang.code)) { console.log("Starting training in " + lang.name + "..."); train(lang.code); __train_donelangs++; } }) rec = new Date(); diff = rec - old; dp = Math.ceil(diff / 1000); console.log("Done in " + dp + " seconds"); } catch (e) { if (e.message == "Unexpected end of JSON input") { console.log("Unable to open database file. Is the databased opened by another program? Or is it corrupted?"); } else { throw e; } }