This repository has been archived by the owner on Apr 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.js
87 lines (63 loc) · 2.74 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const fs = require("fs");
const parser = require("./model/parser")
const measurement = require("./quality/measurement");
const assessment = require("./quality/assessment");
const args = process.argv.slice(2);
const folder = args[0];
const path = "./repository/" + folder + "/";
var stream = fs.createWriteStream("./statistics/" + folder + ".csv");
stream.once("open", function() {
console.log("Processing BPMN models:");
stream.write(
"file," +
"w1,w2,w3,w4,w5," +
"d.R1,d.R2,d.R3,d.R4,d.R5," +
"c.R1,c.R2,c.R3,c.R4,c.R5," +
"d.wsm,d.min,d.wsml,d.minl," +
"c.wsm,c.min,c.wsml,c.minl\n"
);
var modelsCount = 0;
const reportingCondition = modelsCount => modelsCount % 500 === 0;
fs.readdirSync(path).forEach(file => {
var xmlModel = fs.readFileSync(path + file, "utf8");
var measuresList = parser.parse(xmlModel);
for (var k in measuresList) {
modelsCount++;
var measures = measuresList[k];
var discrete = measurement.calculateDiscreteCriteria(measures);
var continuous = measurement.calculateContinuousCriteria(measures);
assessment.recalculateWeights(discrete);
var report = assessment.assessQuality(discrete, continuous);
if (reportingCondition(modelsCount)) {
stream.write(
file + "," +
assessment.weights.R1 + "," +
assessment.weights.R2 + "," +
assessment.weights.R3 + "," +
assessment.weights.R4 + "," +
assessment.weights.R5 + "," +
report.measures.discrete.R1 + "," +
report.measures.discrete.R2 + "," +
report.measures.discrete.R3 + "," +
report.measures.discrete.R4 + "," +
report.measures.discrete.R5 + "," +
report.measures.continuous.R1 + "," +
report.measures.continuous.R2 + "," +
report.measures.continuous.R3 + "," +
report.measures.continuous.R4 + "," +
report.measures.continuous.R5 + "," +
report.quality.discrete.wsm + "," +
report.quality.discrete.min + "," +
report.quality.discrete.wsml + "," +
report.quality.discrete.minl + "," +
report.quality.continuous.wsm + "," +
report.quality.continuous.min + "," +
report.quality.continuous.wsml + "," +
report.quality.continuous.minl + "\n"
);
}
}
console.log(file);
});
stream.end();
});