Nice to see a mini project in C++ language. Search engines are used in our daily life and they are based on the large models.
You have written the search engine in a great way while managing the file opening if the file is not opening with the help of the ifstream
.
Your basic functionality for this search engine is correct to search in the file. The program allows the users to enter the query dynamically.
Areas of Improvements:
- You should implement a
case- insensitive
search function because your current function is case sensitive and if you currently searchHello
it will not considerhello
. So implementingcase-insensitive
search function can help us to solve this problem.
#include < algorithm >
string toLowerCase(const string& str) {
string lowerStr = str;
transform(lowerStr.begin(), lowerStr.end(), lowerStr.begin(), ::tolower);
return lowerStr;
}
It is how you can implement
case-insensitive
in your search function.The program searches for substrings instead of whole words. For example when you search for
the
the program will also matchthere
orthese
. On the other hand if you use regular expressions oristringstream
to tokenize the words then it can help to solve this problem as well.On the other hand you can further improve the performance of your search function by implementing memory mapping because checking line by line will consume a lot of resources.
Plagiarism Free | ✅ |
---|---|
#steemexclusive | ✅ |
AI Free | ✅ |

Thank you so much for the verification and the valuable feedback. I will try my best to improve.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
You are welcome.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit