# in Proceedings of the 16th IEEE International Conference on Program Comprehension (OCPC'08)
module mendel_metrics
-import model
import metrics_base
import mclasses_metrics
-import phase
-import frontend
+import modelize
redef class ToolContext
- var mendel_metrics_phase = new MendelMetricsPhase(self, null)
+ # Compute MENDEL metrics.
+ #
+ # See `mendel_metrics` module documentation.
+ var mendel_metrics_phase: Phase = new MendelMetricsPhase(self, null)
end
private class MendelMetricsPhase
metrics.collect(mclasses)
if csv then metrics.to_csv.save("{out}/mendel.csv")
- print toolcontext.format_h4("\tlarge mclasses (threshold: {cnblp.threshold})")
- for mclass in cnblp.above_threshold do
- print toolcontext.format_p("\t {mclass.name}: {cnblp.values[mclass]}")
+ var threshold = cnblp.threshold
+ print toolcontext.format_h4("\tlarge mclasses (threshold: {threshold})")
+ for mclass in cnblp.sort do
+ var val = cnblp.values[mclass]
+ if val.to_f < threshold then break
+ print toolcontext.format_p("\t {mclass.name}: {val}")
end
- print toolcontext.format_h4("\tbudding mclasses (threshold: {cnvi.threshold})")
- for mclass in cnvi.above_threshold do
- print toolcontext.format_p("\t {mclass.name}: {cnvi.values[mclass]}")
+ threshold = cnvi.threshold
+ print toolcontext.format_h4("\tbudding mclasses (threshold: {threshold})")
+ for mclass in cnvi.sort do
+ var val = cnvi.values[mclass]
+ if val.to_f < threshold then break
+ print toolcontext.format_p("\t {mclass.name}: {val}")
end
- print toolcontext.format_h4("\tblooming mclasses (threshold: {cnvs.threshold})")
- for mclass in cnvs.above_threshold do
- print toolcontext.format_p("\t {mclass.name}: {cnvs.values[mclass]}")
- end
-
- print toolcontext.format_h4("\tblooming mclasses (threshold: {cnvs.threshold})")
- for mclass in cnvs.above_threshold do
- print toolcontext.format_p("\t {mclass.name}: {cnvs.values[mclass]}")
+ threshold = cnvs.threshold
+ print toolcontext.format_h4("\tblooming mclasses (threshold: {threshold})")
+ for mclass in cnvs.sort do
+ var val = cnvs.values[mclass]
+ if val.to_f < threshold then break
+ print toolcontext.format_p("\t {mclass.name}: {val}")
end
if csv then
- var csvh = new CSVDocument
+ var csvh = new CsvDocument
+ csvh.format = new CsvFormat('"', ';', "\n")
csvh.header = ["povr", "ovr", "pext", "ext", "pspe", "spe", "prep", "rep", "eq"]
for mclass in mclasses do
var povr = mclass.is_pure_overrider(vis).object_id
var prep = mclass.is_pure_replacer(vis).object_id
var rep = mclass.is_replacer(vis).object_id
var eq = mclass.is_equal(vis).object_id
- csvh.add_line(povr, ovr, pext, ext, pspe, spe, prep, rep, eq)
+ csvh.add_record(povr, ovr, pext, ext, pspe, spe, prep, rep, eq)
end
csvh.save("{out}/inheritance_behaviour.csv")
end
redef fun name do return "cbms"
redef fun desc do return "branch mean size, mean number of introduction available among ancestors"
+ # Mainmodule used to compute class hierarchy.
var mainmodule: MModule
- init(mainmodule: MModule) do self.mainmodule = mainmodule
redef fun collect(mclasses) do
for mclass in mclasses do
redef fun name do return "cnvi"
redef fun desc do return "class novelty index, contribution of the class to its branch in term of introductions"
+ # Mainmodule used to compute class hierarchy.
var mainmodule: MModule
- init(mainmodule: MModule) do self.mainmodule = mainmodule
redef fun collect(mclasses) do
var cbms = new CBMS(mainmodule)
redef fun name do return "cnvs"
redef fun desc do return "class novelty score, importance of the contribution of the class to its branch"
+ # Mainmodule used to compute class hierarchy.
var mainmodule: MModule
- init(mainmodule: MModule) do self.mainmodule = mainmodule
redef fun collect(mclasses) do
var cnvi = new CNVI(mainmodule)