This project is the Final Capstone for the course COMS W3134: Data Structures in Java at Columbia University.
It is a command-line Java application that performs word replacements in a text file, using efficient data structures and graph-based cycle detection.
- Load word β replacement rules from file
- Supports transitive replacement chains
- Detects and rejects replacement cycles
BSTreeMapβ Binary Search Tree MapRBTreeMapβ Red-Black Tree MapMyHashMapβ Custom HashMap
- Validate all arguments and input files
- Use Java's
StringBuilderfor efficient output - Exit gracefully with error messages on failure
java WordReplacer inputs/input1.txt inputs/replacements1.txt bstWhere:
input1.txt: the original textreplacements1.txt: word replacement rulesbst: the data structure (bst,rbt, orhash)
Text:
Alice will meet Bob at the supermarket.
Rules:
Alice -> Jennifer
supermarket -> diner
Output:
Jennifer will meet Bob at the diner.
Run with large input (e.g. warandpeace.txt):
time java WordReplacer warandpeace.txt warandpeace_replacements.txt hash > /dev/nullRepeat with all three data structures and record average timings.
Final/
βββ src/ # Core source code and data structures
βββ inputs/ # Test cases and replacement files
βββ WordReplacer/ # Main executable class
βββ sampledata/ # Large-scale test files
βββ readme.txt # Report with timing and analysis
βββ Capstone-WordReplacer.pdf # Project specification
Developed by Fan Yi (Sumio0)
Columbia University - Fall 2024