This project simulates a simple search engine using the map data structure πΊοΈ. The program constructs an inverted index π from a set of documents, enabling efficient searching. The search engine can process different types of user queries and display the names of documents that match the search criteria.
- Inverted Index Construction π: The program reads multiple documents and constructs an inverted index, mapping each word to the documents in which it appears.
- Search Queries π: The program supports three types of queries:
- Must-have Words β¨: Words that must appear in the search results (no prefix).
- At Least One Word β: Words prefixed with
+
, where at least one of the specified words must be present in the result. - Exclusion Words β: Words prefixed with
-
, which should not be present in the search results.
- Inverted Index π: The inverted index is created by reading documents and storing the words along with their corresponding document names.
- User Input π: The program takes a search query from the user and returns the document names based on the following rules:
- No Prefix β: Returns documents containing all the specified words.
- + Prefix β: Returns documents containing at least one of the specified words.
- - Prefix β: Excludes documents containing the specified word.
Input: "apple orange"
Output: Documents containing both "apple" and "orange".
Input: "+apple +banana"
Output: Documents containing either "apple" or "banana" or both.
Input: "-apple"
Output: Documents that do not contain the word "apple".