Skip to content

Commit

Permalink
Warn about missing terms and removed stopwords
Browse files Browse the repository at this point in the history
  • Loading branch information
elshize committed Jan 15, 2024
1 parent 8c8fb46 commit 994d101
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/query/query_parser.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "query/query_parser.hpp"
#include <spdlog/spdlog.h>

#include "query/queries.hpp"
#include "query/query_parser.hpp"

namespace pisa {

Expand All @@ -13,6 +15,8 @@ auto QueryParser::parse(std::string_view query) -> Query {
for (auto token: *tokens) {
if (auto id = (*m_term_map)(token); id) {
query_ids.push_back(*id);
} else {
spdlog::warn("Term `{}` not found and will be ignored", token);
}
}
return {std::move(id), std::move(query_ids), {}};
Expand Down
8 changes: 4 additions & 4 deletions src/token_filter.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "pisa/token_filter.hpp"

#include <cctype>

#include <boost/algorithm/string.hpp>
#include <spdlog/spdlog.h>

#include "pisa/token_filter.hpp"

namespace pisa {

Expand Down Expand Up @@ -60,6 +59,7 @@ auto StopWordRemover::filter(std::string_view input) const -> std::unique_ptr<To

auto StopWordRemover::filter(std::string input) const -> std::unique_ptr<TokenStream> {
if (m_stopwords.find(input) != m_stopwords.end()) {
spdlog::warn("Term `{}` is a stopword and will be ignored", input);
return std::make_unique<EmptyTokenStream>();
}
return std::make_unique<SingleTokenStream>(std::move(input));
Expand Down

0 comments on commit 994d101

Please sign in to comment.