show_results.sh 1.7 KB
Newer Older
H
Hui Zhang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
#!/usr/bin/env bash
mindepth=0
maxdepth=1

. utils/parse_options.sh

if [ $# -gt 1 ]; then
    echo "Usage: $0 --mindepth 0 --maxdepth 1 [exp]" 1>&2
    echo ""
    echo "Show the system environments and the evaluation results in Markdown format."
    echo 'The default of <exp> is "exp/".'
    exit 1
fi

[ -f ./path.sh ] && . ./path.sh
set -euo pipefail
if [ $# -eq 1 ]; then
    exp=$1
else
    exp=exp
fi


cat << EOF
<!-- Generated by $0 -->
# RESULTS
## Environments
- date: \`$(LC_ALL=C date)\`
EOF

python3 << EOF
import sys, paddle
pyversion = sys.version.replace('\n', ' ')

print(f"""- python version: \`{pyversion}\`
- paddle version: \`paddle {paddle.__version__}\`""")
EOF

cat << EOF
- Git hash: \`$(git rev-parse HEAD)\`
  - Commit date: \`$(git log -1 --format='%cd')\`

EOF

while IFS= read -r expdir; do
    if ls ${expdir}/decode_*/result.txt &> /dev/null; then
    # 1. Show the result table
    cat << EOF
## $(basename ${expdir})
### CER

|dataset|Snt|Wrd|Corr|Sub|Del|Ins|Err|S.Err|
|---|---|---|---|---|---|---|---|---|
EOF
        grep -e Avg ${expdir}/decode_*/result.txt \
            | sed -e "s#${expdir}/\([^/]*\)/result.txt:#|\1#g" \
            | sed -e 's#Sum/Avg##g' | tr '|' ' ' | tr -s ' ' '|'
        echo

        # 2. Show the result table for WER
        if ls ${expdir}/decode_*/result.wrd.txt &> /dev/null; then
            cat << EOF
### WER

|dataset|Snt|Wrd|Corr|Sub|Del|Ins|Err|S.Err|
|---|---|---|---|---|---|---|---|---|
EOF
            grep -e Avg ${expdir}/decode_*/result.wrd.txt \
                | sed -e "s#${expdir}/\([^/]*\)/result.wrd.txt:#|\1#g" \
                | sed -e 's#Sum/Avg##g' | tr '|' ' ' | tr -s ' ' '|'
            echo
        fi
    fi
done < <(find ${exp} -mindepth ${mindepth} -maxdepth ${maxdepth} -type d)