This project is a Java-based graphical application that allows users to search for terms across a collection of text files. Users can input search terms through a graphical user interface (GUI), and the application searches the contents of the text files to determine which files contain the searched terms. Files with the strongest match to the search terms are displayed at the top of the results list.
This class is responsible for the main graphical user interface. It allows users to enter search queries, initiate searches, and view results. It also provides options to set the range of files to search within.
Search field, search button, exact match checkbox, results display area, and options to set file ranges.
Handles the loading of text files and performing search operations. It filters files based on the specified range and computes the relevance of each file to the search query.
File content loading, search query processing, and relevance scoring based on exact matches, wildcards, and multiple search terms.
Calculates the relevance score for each file based on the occurrence of the search terms. Supports exact phrase matching, wildcards, and multiple word searches.
Scoring based on direct matches, wildcards (* for multiple characters), and handling of phrases.
A dialogue that allows users to specify the range of file numbers to include in the search, enhancing search customization.
UI components for inputting start and end file numbers, and buttons to set or reset the specified range.
Users can search for single words or phrases. The system handles these either as exact phrases or as individual words based on user selection.
The application uses hashmaps to efficiently manage and search through text files. A primary hashmap (fileContents) stores the contents of each file associated with its filename for quick retrieval, reducing the need for repetitive file system access. Another hashmap (fileScores) is used during searches to calculate and store relevance scores for each file based on the search query, supporting dynamic updates and efficient sorting to present the results ordered by relevance.
Each file's relevance to the search query is calculated and presented as a percentage, with results sorted by this relevance score.
Beyond basic keyword matching, the system can perform searches for exact phrases, enhancing the precision of search results.
The application supports wildcard characters "*" to allow for words matching the wildcard search e.g grab* (grabbed, grabbing, grabber etc.)
Any words between dollar signs ($) will be ignored in the search and only the words around it will be matched to the text files.
Through a secondary dialogue, users can dynamically adjust the range of files to search, allowing for flexible data exploration and targeted searches.
If more time were available for this project, I would implement an efficient spell-checking feature for search inputs. This would ensure that searches are correctly spelled, enhancing the accuracy of the search results. Additionally, enhancing error handling and user input validation would be a priority. While the current application provides appropriate error messages to the users, it lacks the ability to guide users in correcting their inputs or resolving issues autonomously.