ArKanjo 0.5.1
A tool for find code duplicated functions in codebases
big_clone_tailor_evaluator.hpp
Go to the documentation of this file.
1
11#pragma once
12
13#include <map>
14#include <set>
15#include <string>
16#include <tuple>
17#include <vector>
18
19#include <arkanjo/base/path.hpp>
21
23
30class BigCloneTailorEvaluator : public CommandBase<BigCloneTailorEvaluator> {
31 private:
32 std::string CLONE_LABELS_FILE_PATH = "/home/luan/linux/test-duplication-code/parser/bigclonebench/clone_labels.txt";
33 std::string EXTENSION = ".java";
34 int NUMBER_OF_TYPES = 6;
35 int NOT_CLONE_TYPE_ID = 5;
36 std::string RECALL_PER_TYPE_PRINT = "Recall Value of each type";
37 double MINIMUM_SIMILARITY_TEMP = 0;
38
40 std::vector<std::string> ID_TO_TYPE_LABEL = {
41 "T1",
42 "T2",
43 "ST3",
44 "MT3",
45 "WT3/T4",
46 "Negative",
47 };
48
49 Similarity_Table* similarity_table;
50 std::map<std::pair<int, int>, int> id_pair_to_type;
51 std::vector<int> count_of_samples_by_type;
52
56 void read_clone_labels();
57
63 int path_to_id(Path path);
64
69 std::vector<std::tuple<double, int, int>> similar_path_pairs_formated_with_id();
70
77 bool is_relevant_pair(int id0, int id1);
78
84 std::set<std::pair<int, int>> filter_similar_id_pairs_only_relevant_ones(
85 std::vector<std::pair<int, int>> similar_id_pairs);
86
93 std::vector<std::pair<int, int>> filter_similar_path_pairs_by_similarity(
94 std::vector<std::tuple<double, int, int>> similar_id_pairs,
95 double minimum_similarity);
96
102 std::vector<int> build_frequency_corrected_guessed_by_type(
103 std::vector<std::pair<int, int>> similar_id_pairs);
104
111 double calc_recall(std::vector<int> frequency, int type);
112
117 void print_recall_per_type(std::vector<int> frequency);
118
123 void evaluate(double minimum_similarity);
124
125 public:
127 "Evaluate clone detection results using the BigCloneBench dataset "
128 "methodology. The command compares detected similarities against "
129 "ground truth labels and reports recall metrics per clone type.")
130
131
135 explicit BigCloneTailorEvaluator(Similarity_Table* _similarity_table);
136
137 bool validate(const ParsedOptions& options) override;
138
142 bool run(const ParsedOptions& options) override;
143};
Evaluates clone detection using BigCloneBench methodology.
COMMAND_DESCRIPTION("Evaluate clone detection results using the BigCloneBench dataset " "methodology. The command compares detected similarities against " "ground truth labels and reports recall metrics per clone type.") explicit BigCloneTailorEvaluator(Similarity_Table *_similarity_table)
Constructs evaluator with similarity data.
bool validate(const ParsedOptions &options) override
Validate the arguments already analyzed.
bool run(const ParsedOptions &options) override
Handles BigCloneBench evaluation command.
const CliOption * options() const final
Represents a logical path to a function in the codebase.
Definition: path.hpp:26
Represents a similarity graph between functions (paths).
Logical path abstraction for source code elements.
Similarity relationships storage and analysis.