Compare commits

2 Commits

Author SHA1 Message Date
6ff4a66551 Fix small mistake 2026-02-04 14:23:27 +01:00
45f73c721e Add savaToFile option 2026-02-04 13:18:54 +01:00
3 changed files with 30 additions and 21 deletions

View File

@@ -136,7 +136,11 @@ namespace Similarity
}
else if (f == &Similarity::hamming_distance)
{
return "hamming";
return "hamming_distance";
}
else if (f == &Similarity::hamming_distance_without_seeds)
{
return "hamming_distance_without_seeds";
}
else if (f == &Similarity::levenshtein_distance)
{
@@ -144,7 +148,7 @@ namespace Similarity
}
else
{
return "unknown";
return "unknown nameofFunc";
}
}
@@ -167,7 +171,6 @@ namespace Similarity
const auto int_ms = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
TraceLog(LOG_INFO, "%s, %d", nameofFunc(f), int_ms);
return average_similarity * 100.0f;
}

View File

@@ -28,6 +28,7 @@ public:
private:
bool showSelection;
bool showStats;
bool saveToFile;
sqlite3 *db;
sqlite3_stmt *get_gen_num;
std::vector<int64_t> ids;

View File

@@ -110,7 +110,7 @@ void Vapp::update()
stageOfDrawing = DrawingStage::save;
break;
case DrawingStage::save:
drawToFile();
if(saveToFile) drawToFile();
stageOfDrawing = DrawingStage::done;
break;
case DrawingStage::done:
@@ -140,6 +140,10 @@ void Vapp::draw()
{
setUpTable();
}
if(ImGui::MenuItem("Save to File", nullptr, saveToFile, true))
{
saveToFile = !saveToFile;
}
ImGui::EndMainMenuBar();
}
@@ -335,27 +339,28 @@ void Vapp::setUpTable()
}
sql::reset(get_gen_stmt);
int64_t id = ids[selected_id_index];
char buff[50];
sprintf(buff, "%ld.txt", id);
std::ofstream file(buff);
file << "| index | euclidean_distance | cosine_similarity | cosine_similarity_int | hamming_distance | levenshtein_distance | dot_minmax |\n";
file << "| --- | --- | --- | --- | --- | --- | --- |\n";
for (size_t i = 0; i < similTable.size(); i++)
if(saveToFile)
{
file << "|" << i << "|";
for (size_t j = 0; j < similTable[i].size(); j++)
int64_t id = ids[selected_id_index];
const char* buff = TextFormat("%ld.txt", id);
std::ofstream file(buff);
file << "| index | euclidean_distance | cosine_similarity | cosine_similarity_int | hamming_distance | levenshtein_distance | dot_minmax |\n";
file << "| --- | --- | --- | --- | --- | --- | --- |\n";
for (size_t i = 0; i < similTable.size(); i++)
{
file << similTable[i][j] << "|";
file << "|" << i << "|";
for (size_t j = 0; j < similTable[i].size(); j++)
{
file << similTable[i][j] << "|";
}
file << "\n";
}
file << "\n";
}
}
}
sql::finalize(get_gen_stmt);
}