From a5579d1e1fc561239d531771e3a56f166f3be4b4 Mon Sep 17 00:00:00 2001 From: rajendrant Date: Sat, 22 Dec 2018 23:32:51 -0800 Subject: [PATCH] Remove debugs --- src/path_scorer.cc | 22 ---------------------- src/scorer.cc | 25 ------------------------- 2 files changed, 47 deletions(-) diff --git a/src/path_scorer.cc b/src/path_scorer.cc index 369fb6af..9864b506 100644 --- a/src/path_scorer.cc +++ b/src/path_scorer.cc @@ -8,19 +8,6 @@ size_t tau_depth = 20; // Full path is also penalized for length of basename. This adjust a scale factor for that penalty. Score file_coeff = 2.5; -#define TRACE(...) trace_internal(__FUNCTION__, "(", __LINE__, ")", __VA_ARGS__) - -void trace_internal() { - std::cout << std::endl; -} - -template -void trace_internal(const Head& head, const Args&... args ) -{ - std::cout << head << " "; - trace_internal(args...); -} - }; @@ -52,11 +39,8 @@ Score path_scorer_score(const Candidate &string, const Element &query, const Opt return 0; } const auto string_lw = ToLower(string); - TRACE(string, query, string_lw); auto sc = computeScore(string, string_lw, options.preparedQuery); - TRACE(sc); sc = scorePath(string, string_lw, sc, options); - TRACE(sc); return ceil(sc); } @@ -73,7 +57,6 @@ Score scorePath(const Candidate &subject, const Candidate &subject_lw, Score ful int end = subject.size() - 1; while (subject[end] == options.pathSeparator) end--; - TRACE(end); // Get position of basePath of subject. int basePos = subject.rfind(options.pathSeparator, end); @@ -86,27 +69,23 @@ Score scorePath(const Candidate &subject, const Candidate &subject_lw, Score ful extAdjust += getExtensionScore(subject_lw, options.preparedQuery.ext, basePos, end, 2); fullPathScore *= extAdjust; } - TRACE(fullPathScore, basePos, fileLength, extAdjust); // no basePath, nothing else to compute. if (basePos == -1) return fullPathScore; // Get the number of folder in query int depth = options.preparedQuery.depth; - TRACE(depth, options.pathSeparator); // Get that many folder from subject while (basePos > -1 && depth-- > 0) { basePos = subject.rfind(options.pathSeparator, basePos - 1); } - TRACE(basePos); // Get basePath score, if BaseName is the whole string, no need to recompute // We still need to apply the folder depth and filename penalty. Score basePathScore = (basePos == -1) ? fullPathScore : extAdjust * computeScore(subject.substr(basePos + 1, end + 1), subject_lw.substr(basePos + 1, end + 1), options.preparedQuery); - TRACE(basePathScore); // Final score is linear interpolation between base score and full path score. // For low directory depth, interpolation favor base Path then include more of full path as depth increase // @@ -114,7 +93,6 @@ Score scorePath(const Candidate &subject, const Candidate &subject_lw, Score ful // That way, more focused basePath match can overcome longer directory path. Score alpha = 0.5 * tau_depth / ( tau_depth + countDir(subject, end + 1, options.pathSeparator) ); - TRACE(alpha, subject, end); return alpha * basePathScore + (1 - alpha) * fullPathScore * scoreSize(0, file_coeff * (fileLength)); } diff --git a/src/scorer.cc b/src/scorer.cc index 25e5cbf5..521f4a93 100644 --- a/src/scorer.cc +++ b/src/scorer.cc @@ -28,19 +28,6 @@ Score tau_size = 150; // This has a direct influence on worst case scenario benchmark. float miss_coeff = 0.75; // Max number missed consecutive hit = ceil(miss_coeff*query.length) + 5 -#define TRACE(...) trace_internal(__FUNCTION__, "(", __LINE__, ")", __VA_ARGS__) - -void trace_internal() { - std::cout << std::endl; -} - -template -void trace_internal(const Head& head, const Args&... args ) -{ - std::cout << head << " "; - trace_internal(args...); -} - } // namepace struct AcronymResult { @@ -128,14 +115,11 @@ Score computeScore(const Candidate &subject, const Candidate &subject_lw, const int m = subject.size(); int n = query.size(); - TRACE(subject, subject_lw, query, query_lw); - //---------------------------- // Abbreviations sequence auto acro = scoreAcronyms(subject, subject_lw, query, query_lw); auto acro_score = acro.score; - TRACE(acro.score, acro.pos, acro.count); // Whole query is abbreviation ? // => use that as score @@ -148,7 +132,6 @@ Score computeScore(const Candidate &subject, const Candidate &subject_lw, const auto pos = subject_lw.find(query_lw); if (pos != std::string::npos) { - TRACE(pos, n, m); return scoreExactMatch(subject, subject_lw, query, query_lw, pos, n, m); } @@ -166,7 +149,6 @@ Score computeScore(const Candidate &subject, const Candidate &subject_lw, const auto miss_budget = ceil(miss_coeff * n) + 5; auto miss_left = miss_budget; bool csc_should_rebuild = true; - TRACE(sz, miss_budget, miss_left, miss_coeff); // Fill with 0 /* @@ -252,7 +234,6 @@ Score computeScore(const Candidate &subject, const Candidate &subject_lw, const // get hightest score so far auto score = score_row[n - 1]; - TRACE(score, sz); return score * sz; } @@ -303,7 +284,6 @@ Score scoreSize(Score n, Score m) { } Score scoreExact(size_t n, size_t m, size_t quality, Score pos) { - TRACE(n, m, quality, pos); return 2 * n * ( wm * quality + scorePosition(pos) ) * scoreSize(n, m); } @@ -402,8 +382,6 @@ Score scoreExactMatch(const Candidate &subject, const Candidate &subject_lw, con // Test for word start bool start = isWordStart(pos, subject, subject_lw); - TRACE(query, query_lw); - TRACE(pos, n, m, start); // Heuristic // If not a word start, test next occurrence @@ -418,7 +396,6 @@ Score scoreExactMatch(const Candidate &subject, const Candidate &subject_lw, con if (start) pos = pos2; } } - TRACE(start, pos); //Exact case bonus. int i = -1; @@ -427,10 +404,8 @@ Score scoreExactMatch(const Candidate &subject, const Candidate &subject_lw, con if (query[i] == subject[pos + i]) sameCase++; } - TRACE(sameCase); int end = isWordEnd(pos + n - 1, subject, subject_lw, m); - TRACE(end); Score baseNameStart = 1; if (start && pos>0 && subject[pos-1]=='/') {