This project is a command-line dictionary application developed in Java. It allows users to search for words and retrieve definitions along with their associated parts of speech. The program supports multiple query options and demonstrates efficient data organization and retrieval.
- Keyword-based dictionary search
- Filtering by part of speech (e.g., noun, verb)
- Removal of duplicate definitions using a
distinctoption - Reverse ordering of results using a
reverseoption - Command-based interaction (
!help,!q) - Input validation with clear error messaging
The application is organized into four primary components:
-
DictionaryData.java Defines dictionary entries using an enum. Each entry contains a keyword, part of speech, and definition stored as separate fields.
-
DictionaryEntry.java Represents a single dictionary entry, encapsulating part of speech and definition.
-
Dictionary.java Responsible for loading data into a
HashMap, where each keyword maps to a collection of definitions. -
DictionaryApp.java Handles user interaction, input parsing, search execution, and output formatting.
A HashMap<String, ArrayList<DictionaryEntry>> is used as the primary data structure.
This design was chosen to:
- Enable constant-time lookup (O(1)) for search operations
- Efficiently map each keyword to multiple definitions
- Improve scalability compared to linear search structures such as
ArrayList
The program follows object-oriented design principles including encapsulation and separation of responsibilities across classes.
-
Compile the program:
javac *.java -
Run the application:
java DictionaryApp
Search [1]: book
Search [2]: book noun
Search [3]: book noun distinct
Search [4]: book noun distinct reverse
- Refactor large methods into smaller, modular components
- Enhance input handling for additional edge cases
- Improve code documentation and inline comments
- Load dictionary data from external sources (e.g., files or databases)
- Develop a graphical user interface (GUI)
- Java
- HashMap
- ArrayList
- Enum-based data modeling
This project was completed as part of a data structures and software design assignment.
Conceptual understanding, debugging, and refinement were supported in part by AI-based tools (such as DeepSeek and similar assistants), particularly for improving explanations, validating design decisions, and enhancing code clarity. All implementation and final integration were completed independently.
Aarzu Karki