Ajla Šačić
This project involves building an inverted index pipeline in several stages:
-
Document Cleaning:
- Removing subtitles (text surrounded by
=symbols) - Removing wikitables
- Removing references and 'see also' sections
- Removing any HTML and XML tags
- Separating punctuation connected to words
- Removing subtitles (text surrounded by
-
Document Merging:
- Adding all files into a single file
- Formatting as
[filename.txt] [Title] [Content], all tab-separated
-
MapReduce for Word Counts:
- Input: Combined file
- Output:
filenametitletarget wordtarget word frequency countall contexts related to the word
-
Creating the Inverted Index:
- Uses
pickleto store a searchable dictionary of words.
- Uses
-
Searching the Inverted Index:
- Options for a simple or rich search UI.
python3 simpleSearch.pypython3 richSearch.py-
Create a new environment:
python -m venv venv
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
-
Install dependencies:
pip install -r requirements.txt
-
Run the inverted index pipeline:
python3 processFiles.py --run_mapreduce --build_inverted_index
Alternatively, execute each step separately:
python3 preprocess.py -i [--input_dir] INPUT_DIR -o [--output_dir] OUTPUT_DIR
Output: Directory called
OUTPUT_DIRcontaining cleaned files.python3 combine_files.py -i [--input_dir] INPUT_DIR -o [--output_file] OUTPUT_FILE
Output: Single file
OUTPUT_FILEcontaining all documents.python3 mapReduceWordCount.py combined_documents.txt > word_counts.txtOutput:
word_counts.txtwith word counts per file, including contexts.python3 invertedIndex.py --input_file word_counts.txt --output_file inverted_index.pkl
python3 countWords.py -i [--input_dir] INPUT_DIR -o [--output_file] OUTPUT_FILE
-
Run the Search:
- Simple UI:
python3 simpleSearch.py
- Rich UI:
python3 richSearch.py
- Simple UI: