Search for words in files | Поиск слов в файлах.
Application for searching of request words (JSON file requests.json) in resources text files (path to resources files are specified in config.json). Search result is putting into answers.json.
Приложение для поиска запрашиваемых слов (JSON файл requests.json) в текстовых файлах ресурсов (путь к ресурсам указан в config.json). Результат поиска помещается в answers.json.
https://github.com/nlohmann/json
https://github.com/google/googletest
-
Step 1: Build the project.
-
If you use Visual Studio compiler you can build x64 or x32 version respectively:
- For x64 version:
cmake -A x64 -S . -B "build64"
cmake --build build64 --config Release
- For x32 version:
cmake -A Win32 -S . -B "build32"
cmake --build build32 --config Release
- For x64 version:
-
In other cases use default build:
cmake -S . -B "build"
cmake --build build --config Release
-
-
Step 2: copy files:
.\bin\requests.json
,.\bin\config.json
,.\bin\answers.json
and.\bin\resources
folder
from.\bin
folder
to the.\bin\Release
folder. -
Step 3: run the application:
.\bin\Release\Search_in_files
- config.json
File where specified name and version of application.
Here you can also change the maximal quantity of relevant pages that will be put into answers.json (max_respones).
Default content:
{
"config":
{
"name": "FileSearchEngine",
"version": "0.1",
"max_responses": 5
},
"files":
[
"resources/file001.txt",
"resources/file002.txt"
]
}
- requests.json
File where specified requests for search.
Each separate request sholud be entered after ',' on new line. Example below.
Example content:
{
"requests":
[
"tiger fox",
"wolf bird",
"monkey"
]
}
- answers.json
File where search result will be written in JSON format.
Example content:
{
"answers": {
"request0": {
"relevance": [
{
"docid": 1,
"rank": 1.0
},
{
"docid": 0,
"rank": 0.6700000166893005
}
],
"result": true
},
"request1": {
"relevance": [
{
"docid": 0,
"rank": 1.0
},
{
"docid": 1,
"rank": 1.0
}
],
"result": true
},
"request2": {
"docid": 1,
"rank": 1.0,
"result": true
}
}
}
NOTE:
docid - identificator of a relevant document,
rank - relative index,
result - true (if relevance is found), or false (if document absolutely not relevant for certain request).