Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions app/lib/search/text_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,23 @@ Map<String, double>? tokenize(String? originalText, {bool isSplit = false}) {

// Scan for CamelCase phrases and extract Camel and Case separately.
final wordCodeUnits = word.codeUnits;
final changeIndex = <int>[0];
bool prevLower = _isLower(wordCodeUnits[0]);
for (int i = 1; i < word.length; i++) {
final lower = _isLower(wordCodeUnits[i]);
if (!lower && prevLower) {
changeIndex.add(i);
int prevIndex = 0;
for (int i = 1; i <= word.length; i++) {
if (i < word.length) {
final lower = _isLower(wordCodeUnits[i]);
final isChanging = !lower && prevLower;
prevLower = lower;
if (!isChanging) continue;
}
prevLower = lower;
}
changeIndex.add(word.length);
for (int i = 1; i < changeIndex.length; i++) {
final token = normalizeBeforeIndexing(
word.substring(changeIndex[i - 1], changeIndex[i]));

final token = normalizeBeforeIndexing(word.substring(prevIndex, i));
final weight = math.pow((token.length / word.length), 0.5).toDouble();
if ((tokens[token] ?? 0.0) < weight) {
tokens[token] = weight;
}

prevIndex = i;
}
}
return tokens;
Expand Down
Loading