The input is the text, the search query and the resultsCount number. In this project, resultsCount lines from the text are returned in descending order of relevance. If two lines have the same relevance, they are returned in the same order in which they occur in the text. If there are less than resultsCount relevant (with relevance > 0) rows, then as many relevant rows as could be found are returned.
The measure of relevance will be the sum of TF-IDF for unique words included in the query. A document is a string, a collection of documents is a set of lines of text.
The algorithm is not case-sensitive. A word is considered to be the maximum continuous sequence of characters that satisfies the criterion std::isalpha(). Lines in the text that do not contain words are ignored.
Class SearchEngine is realized in this project.
Class has such methods:
BuildIndex- processes the text and builds an index on itsearch- searches for relevant strings
A typical application pattern is sparse indexing and frequent search queries.
- C++ Compiler: C++17 compatible (e.g., GCC, Clang, MSVC).
- CMake (Optional): Version 3.10+ for Option 1.
Navigate to your project's root directory, then execute the following commands in your terminal:
mkdir build
cd build
cmake ..
cmake --build .
cd Debug
./searchEngineTestsg++ -std=c++17 searchEngine.cpp tests.cpp -o searchEngineTests
./searchEngineTests