ArKanjo 0.5.1
A tool for find code duplicated functions in codebases
embedding_method.hpp
Go to the documentation of this file.
1
11#pragma once
12
13#include <cstdio>
14#include <string>
15#include <vector>
16#include <filesystem>
18
19namespace fs = std::filesystem;
20
29class EmbeddingMethod : public IMethod {
30 private:
31 static constexpr const char* SAVING_MESSAGE = "Saving results...";
32
33 fs::path base_path;
34 double similarity;
35 std::vector<std::string> pass_through_args;
36
42 std::string build_command(const fs::path& source_dir) const;
43
50 bool parse_line(const std::string& line, DuplicationEntry& entry) const;
51
57 std::vector<DuplicationEntry> read_results(FILE* pipe) const;
58
63 void save_duplications(std::vector<DuplicationEntry>& file_duplication_pairs) override;
64
65 public:
73 EmbeddingMethod(const fs::path& base_path_, double similarity_,
74 std::vector<std::string> pass_through_args_ = {});
75
76 void on_function(const FunctionData& fd) override;
77
78 void execute() override;
79};
Semantic duplication detector using LLM embeddings.
void execute() override
void on_function(const FunctionData &fd) override
EmbeddingMethod(const fs::path &base_path_, double similarity_, std::vector< std::string > pass_through_args_={})
Constructs the LLM detector.
std::tuple< double, std::string, std::string > DuplicationEntry
tuple format of the detected duplicates (similarity_percentage, path1, path2)
Definition: method.hpp:11