Skip to content

Commit

Permalink
Remove debugs
Browse files Browse the repository at this point in the history
  • Loading branch information
rajendrant committed Dec 23, 2018
1 parent 75d96c7 commit a5579d1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 47 deletions.
22 changes: 0 additions & 22 deletions src/path_scorer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename Head, typename... Args>
void trace_internal(const Head& head, const Args&... args )
{
std::cout << head << " ";
trace_internal(args...);
}

};


Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
Expand All @@ -86,35 +69,30 @@ 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
//
// A penalty based on the size of the basePath is applied to fullPathScore
// 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));
}

Expand Down
25 changes: 0 additions & 25 deletions src/scorer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename Head, typename... Args>
void trace_internal(const Head& head, const Args&... args )
{
std::cout << head << " ";
trace_internal(args...);
}

} // namepace

struct AcronymResult {
Expand Down Expand Up @@ -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
Expand All @@ -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);
}

Expand All @@ -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
/*
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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]=='/') {
Expand Down

0 comments on commit a5579d1

Please sign in to comment.