Note: this is a Maven project. The repository contains both the code developed for this task and a set of tests to check its functionalities.
This document provides some usage examples of the indexing tool.
When launched the program will perform the following steps:
- Ask the user to insert the path of one or more files (or directories) they wish to include in the search.
- Ask the user to specify the operation they want to perform: (1) search a word or (2) search a pattern. A check is performed on the user input to ensure its validity.
- If the user selects search a word, the program asks the user to insert the word to search for in the specified files/directories.
- The program iterates over all the files specified by the user. If the user specified a directory the program will recursively inspect all files/directories included in it.
- The program reads line-by-line the content of each file and, if the file contains the given word, it adds the path to the file to the list of query results.
- The program prints the path to all files containing the word specified by the user.
By changing the Operation class from SplitByWordOperation to PatternSearchOperation, the program can look for a pattern in the files specified by the user. To do this, the tool relies on an implementation of the Rabin Karp algorithm.
The steps performed by the tool in this example are the following:
- Ask the user to insert the path of one or more files (or directories) they wish to include in the search.
- Ask the user to specify the operation they want to perform: (1) search a word or (2) search a pattern. A check is performed on the user input to ensure its validity.
- If the user selects search a pattern, the program asks the user to insert the pattern to search for in the specified files/directories.
- The program iterates over all the files specified by the user. If the user specified a directory the program will recursively inspect all files/directories included in it.
- The program inspect the text contained in each file using the Rabin Karp algorithm. If the file contains the given patter, it adds its path to the list of query results.
- The program prints the path to all files containing the pattern specified by the user.