#!/usr/bin/env bash # Fetch the POJ-104 C++ source corpus from Microsoft's CodeXGLUE repo. # # Layout afterwards: # bench/corpora/poj-104/dataset/ # 1/1.txt 2.txt ... # 104 algorithm folders, each containing ~500 .txt # 2/... # ... # # CodeXGLUE ships the files as `.txt` (the original submission archive used # .txt to bypass file-type filtering). We rename them to `.cpp` in place so # the standard run_bench.py glob picks them up. set -euo pipefail HERE="$(cd "$(dirname "$0")" && pwd)" cd "$HERE" if [[ -d dataset ]]; then echo "POJ-104 already fetched at $HERE/dataset; skipping clone." exit 0 fi echo "Cloning CodeXGLUE (sparse: POJ-104 only)..." TMPDIR="$(mktemp -d)" trap 'rm -rf "$TMPDIR"' EXIT git clone --depth 1 --filter=blob:none --sparse \ https://github.com/microsoft/CodeXGLUE.git "$TMPDIR/codex" ( cd "$TMPDIR/codex" && \ git sparse-checkout set Code-Code/Clone-detection-POJ-104/dataset ) mv "$TMPDIR/codex/Code-Code/Clone-detection-POJ-104/dataset" "$HERE/dataset-raw" echo "Renaming .txt → .cpp so run_bench's *.cpp glob finds them..." ( cd "$HERE/dataset-raw" && find . -name '*.txt' -print0 \ | xargs -0 -I{} sh -c 'mv "{}" "${1%.txt}.cpp"' _ {} ) mv "$HERE/dataset-raw" "$HERE/dataset" count=$(find "$HERE/dataset" -name '*.cpp' | wc -l) echo "POJ-104 ready: $count .cpp files in $HERE/dataset" echo "" echo "Next:" echo " python3 bench/gold/_generate_poj104.py" echo " python3 bench/run_bench.py --corpus $HERE/dataset --name poj-104 \\" echo " --tools fold,clang-tidy --detectors equiv --processes 4" echo " python3 bench/score.py --run-dir bench/results/ \\" echo " --gold bench/gold/poj-104.json"