I have to design and implement an algorithm for my university project that searches a given set of documents based on the keywords/query given. Assume that each document contain few sentences and these documents can be stored in a suitable data structure. When a query is made I have to display the documents that contain the keywords. A query can contain simple logical operators such as “AND” and “OR”.
For example assume that there are 3 documents named Doc1, Doc2, Doc3 with this content:
- Doc1: This is my University.
- Doc2: My University is situated at Delhi.
- Doc3: I like My University.
Here are the answers to some queries:
- "University": Doc1, Doc2, Doc3
- "my AND University": Doc1, Doc2
- "like OR Delhi": Doc2, Doc3
Currently what I have developed reads each file and put its contents into separate binary trees, and I've developed a function for searching one word from the binary trees. How can I extend my search algorithm for search with logical operators?