Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed two unicode-related bugs in the text index. #502

Merged
merged 2 commits into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/index/Index.Text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ void Index::passContextFileIntoVector(const string& contextFile,
LOG(WARN) << "There are more entities not in the KB..."
<< " suppressing further warnings...\n";
}
} else {
entityNotFoundErrorMsgCount++;
}
}
} else {
Expand All @@ -189,6 +191,11 @@ void Index::passContextFileIntoVector(const string& contextFile,
LOG(INFO) << "Lines processed: " << i << '\n';
}
}
LOG(WARN)
<< "Number of entity mentions where the entity is not part of the KB: "
<< entityNotFoundErrorMsgCount << std::endl;
LOG(WARN) << "Number of total entity mentions: " << nofEntityPostings
<< std::endl;
++nofContexts;
addContextToVector(writer, currentContext, wordsInContext, entitiesInContext);
_textMeta.setNofTextRecords(nofContexts);
Expand Down
4 changes: 2 additions & 2 deletions src/index/StringSortComparator.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class SimpleStringComparator {
if (cmpRes != 0 || level != Level::TOTAL) {
return cmpRes;
}
return a.compare(b) < 0;
return a.compare(b);
}

/**
Expand Down Expand Up @@ -409,7 +409,7 @@ class TripleComponentComparator {
public:
using Level = LocaleManager::Level;

/**
/* mentions*
* @param lang The language of the locale, e.g. "en" or "de"
* @param country The country of the locale, e.g. "US" or "CA"
* @param ignorePunctuationAtFirstLevel If true then spaces/punctuation etc.
Expand Down
8 changes: 7 additions & 1 deletion src/index/Vocabulary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ void Vocabulary<S, C>::createFromSet(const ad_utility::HashSet<S>& set) {
_words.reserve(set.size());
_words.insert(begin(_words), begin(set), end(set));
LOG(INFO) << "... sorting ...\n";
std::sort(begin(_words), end(_words), _caseComparator);
auto totalComparison = [this](const auto& a, const auto& b) {
return _caseComparator(a, b, SortLevel::TOTAL);
};
std::sort(begin(_words), end(_words), totalComparison);
LOG(INFO) << "Done creating vocabulary.\n";
}

Expand Down Expand Up @@ -407,6 +410,9 @@ template <typename S, typename C>
bool Vocabulary<S, C>::getId(const string& word, Id* id) const {
if (!shouldBeExternalized(word)) {
// need the TOTAL level because we want the unique word.
if (ad_utility::startsWith(word, "krivokapic")) {
LOG(INFO) << word << '\n';
}
*id = lower_bound(word, SortLevel::TOTAL);
// works for the case insensitive version because
// of the strict ordering.
Expand Down