From e37cabd282c5499826efbb0ebc62983104160a54 Mon Sep 17 00:00:00 2001 From: Rafael Kallis Date: Tue, 24 Nov 2020 21:04:44 +0100 Subject: [PATCH] chore: lint fixes --- bin/tickettagger.js | 39 +++++++++++++++++++++++++-------------- package-lock.json | 6 +++--- package.json | 2 +- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/bin/tickettagger.js b/bin/tickettagger.js index a15e967a..cb1482bc 100644 --- a/bin/tickettagger.js +++ b/bin/tickettagger.js @@ -42,13 +42,13 @@ fs.mkdirSync(DATASET_DIR, { recursive: true }); const datasetManager = new DatasetManager({ DATASET_DIR }); const labels = ["__label__bug", "__label__enhancement", "__label__question"]; const datasetTable = { - ['30k']: + ["30k"]: "https://tickettagger.blob.core.windows.net/datasets/github-labels-top3-30493-real.csv", - ['127k']: + ["127k"]: "https://tickettagger.blob.core.windows.net/datasets/github-labels-top3-real-127k.txt", - ['397k']: + ["397k"]: "https://tickettagger.blob.core.windows.net/datasets/github-labels-top3-real-397k.txt", - ['30k-balanced']: + ["30k-balanced"]: "https://gist.githubusercontent.com/rafaelkallis/6aa281b00d73d77fc843bd34f8184854/raw/8c10ebf2fd6f937f8667c660ea33d122bac739eb/issues.txt", english: "https://gist.githubusercontent.com/rafaelkallis/6aa281b00d73d77fc843bd34f8184854/raw/8c10ebf2fd6f937f8667c660ea33d122bac739eb/issues_english.txt", @@ -116,7 +116,11 @@ const filterHyperparameters = (opts) => ) ); -console.log(chalk.magenta(`tickettagger, Copyright (C) ${new Date().getFullYear()} Rafael Kallis, GPL-v3 license\n`)) +console.log( + chalk.magenta( + `tickettagger, Copyright (C) ${new Date().getFullYear()} Rafael Kallis, GPL-v3 license\n` + ) +); yargs(process.argv.slice(2)) .scriptName("tickettagger") @@ -205,8 +209,7 @@ yargs(process.argv.slice(2)) .positional( "dataset", datasetOption({ - description: - "The dataset (key or URL) to train the model with.", + description: "The dataset (key or URL) to train the model with.", }) ) .option("force", { @@ -293,9 +296,14 @@ async function crossHandler({ dataset: datasetUri, folds, force, ...opts }) { } /** - * Train a model. + * Train a model. */ -async function trainHandler({ dataset: datasetUri, model: modelPath, force, ...opts }) { +async function trainHandler({ + dataset: datasetUri, + model: modelPath, + force, + ...opts +}) { const dataset = await datasetManager.fetch(datasetUri, force); const classifier = new Classifier(); await classifier.train("supervised", { @@ -305,12 +313,12 @@ async function trainHandler({ dataset: datasetUri, model: modelPath, force, ...o }); } -function cleanHandler({}) { +function cleanHandler() { for (const datasetPath of fs.readdirSync(DATASET_DIR)) { - fs.unlinkSync(path.join(DATASET_DIR, datasetPath)); + fs.unlinkSync(path.join(DATASET_DIR, datasetPath)); } for (const modelPath of fs.readdirSync(MODEL_DIR)) { - fs.unlinkSync(path.join(MODEL_DIR, modelPath)); + fs.unlinkSync(path.join(MODEL_DIR, modelPath)); } } @@ -325,7 +333,10 @@ async function* evaluateIter(datasetPath, classifier) { } const [actual] = line.match(/__label__[a-zA-Z0-9]+/); const text = line.substring(actual.length); - const [predictionResult = { label: null }] = await classifier.predict(text, 1); + const [predictionResult = { label: null }] = await classifier.predict( + text, + 1 + ); const predicted = predictionResult.label; yield { actual, predicted }; } @@ -338,7 +349,7 @@ async function evaluateInline(datasetPath, classifier, actual, predicted) { predicted.push(recordPredicted); } } - + function printStats({ actual, predicted }) { const cm = ConfusionMatrix.fromLabels(actual, predicted); console.log(chalk.bgMagenta(" stats ")); diff --git a/package-lock.json b/package-lock.json index 5fe83c99..447451bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "tickettagger", - "version": "2.1.3", + "version": "2.1.4", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -4361,7 +4361,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { "ansi-regex": "^2.0.0" @@ -7152,7 +7152,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", diff --git a/package.json b/package.json index 9b9297aa..a053c0db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tickettagger", - "version": "2.1.3", + "version": "2.1.4", "description": "Machine learning driven issue classification bot.", "license": "GPL-3.0", "repository": {