Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Text Search Tool

Overview

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.

List of Classes and Descriptions

GUI

Functionality

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.

Key Features

Search field, search button, exact match checkbox, results display area, and options to set file ranges.

searchData

Functionality

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.

Key Features

File content loading, search query processing, and relevance scoring based on exact matches, wildcards, and multiple search terms.

searchScore

Functionality

Calculates the relevance score for each file based on the occurrence of the search terms. Supports exact phrase matching, wildcards, and multiple word searches.

Key Features

Scoring based on direct matches, wildcards (* for multiple characters), and handling of phrases.

fileRange

Functionality

A dialogue that allows users to specify the range of file numbers to include in the search, enhancing search customization.

Key Features

UI components for inputting start and end file numbers, and buttons to set or reset the specified range.

Core Functionality

Single and Multiple Word Searches

Users can search for single words or phrases. The system handles these either as exact phrases or as individual words based on user selection.

Searching Text Files

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.

Strongest Match

Each file's relevance to the search query is calculated and presented as a percentage, with results sorted by this relevance score.

Optional Functionality

Exact Phrase Matching

Beyond basic keyword matching, the system can perform searches for exact phrases, enhancing the precision of search results.

Wildcard Searches

The application supports wildcard characters "*" to allow for words matching the wildcard search e.g grab* (grabbed, grabbing, grabber etc.)

Exclude Certain Words

Any words between dollar signs ($) will be ignored in the search and only the words around it will be matched to the text files.

Interactive File Range Adjustment

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.

About

Java Search Engine using OOP principles

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages