<commit_before>#!/usr/bin/env bash

rvm use default
rvm gemset use selenium

OS=$(uname -s)
BASEDIR=$HOME/backup/sz

if [[ "$OS" == "OpenBSD" ]]; then
    ps -a | awk '$5 ~ /Xvfb/ { print $5; }' | grep -q Xvfb
else
    ps -a | awk '$4 ~ /Xvfb/ { print $4; }' | grep -q Xvfb
fi

if (( $? != 0 )); then
    nohup Xvfb :1 -screen 1 1600x1200x8 &>/dev/null &
    sleep 1
fi

DISPLAY=:1 saezei.rb $BASEDIR 2>> $BASEDIR/saezei.log
if (( $? != 0 )); then
    exit 1
fi 

DIR=$(ls -tr $BASEDIR/*/ | tail -1)

saezei_convert.rb $BASEDIR/$DIR 2>> $BASEDIR/saezei_convert.log
if (( $? != 0 )); then
    exit 2
fi 

saezei_compile.rb $BASEDIR/$DIR 2>> $BASEDIR/saezei_compile.log
if (( $? != 0 )); then
    exit 2
fi <commit_msg>Source .bashrc, use param as basedir.<commit_after>#!/usr/bin/env bash

. $HOME/.bashrc

rvm use default
rvm gemset use selenium

OS=$(uname -s)

BASEDIR=${1:-$HOME/backup/sz}
mkdir -p $BASEDIR

if [[ "$OS" == "OpenBSD" ]]; then
    ps -a | awk '$5 ~ /Xvfb/ { print $5; }' | grep -q Xvfb
else
    ps -a | awk '$4 ~ /Xvfb/ { print $4; }' | grep -q Xvfb
fi

if (( $? != 0 )); then
    nohup Xvfb :1 -screen 1 1600x1200x8 &>/dev/null &
    sleep 1
fi

DISPLAY=:1 saezei.rb $BASEDIR 2>> $BASEDIR/saezei.log
if (( $? != 0 )); then
    exit 1
fi 

DIR=$(ls -tr $BASEDIR/*/ | tail -1)

saezei_convert.rb $BASEDIR/$DIR 2>> $BASEDIR/saezei_convert.log
if (( $? != 0 )); then
    exit 2
fi 

saezei_compile.rb $BASEDIR/$DIR 2>> $BASEDIR/saezei_compile.log
if (( $? != 0 )); then
    exit 2
fi 
{'fraction_non_alphanumeric': 0.19333333333333333, 'fraction_numerical': 0.038, 'mean_word_length': 2.79040404040404, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4835657', 'n_tokens_mistral': 710, 'n_tokens_neox': 679, 'n_words': 183}