<commit_before>#!/bin/bash

OPTIND=1
SCRIPT_DIR=$(dirname $0)
JATTACH=$SCRIPT_DIR/build/jattach
PROFILER=$(realpath $SCRIPT_DIR/build/libasyncProfiler.so)
ACTION=""
PID=""
START_OPTIONS=""
FILE=""

while getopts ":h?a:p:o:f:" opt; do
    case $opt in
        h|\?)
            echo "Usage: $0 -a <start|stop|dump> -p <pid>"
            echo "       [-o start-options] [-f output-file]"
            echo ""
            echo "Example: $0 -p 8983 -a start"
            echo "         $0 -p 8983 -a stop"
            exit 1
            ;;
        a)
            ACTION=$OPTARG
            ;;
        p)
            PID=$OPTARG
            ;;
        o)
            START_OPTIONS=$OPTARG
            ;;
        f)
            FILE=$OPTARG
            ;;
    esac
done

if [[ "$PID" == "" ]]
then
    echo "Error: pid is required"
    exit 1
fi
if [[ "$ACTION" == "" ]]
then
    echo "Error: action is required (start, stop, or dump)"
    exit 1
fi

case $ACTION in
    "start")
        $JATTACH $PID load $PROFILER true $START_OPTIONS,start > /dev/null
        ;;
    "stop")
        $JATTACH $PID load $PROFILER true stop > /dev/null
        ;;
    "dump")
        if [[ "$FILE" == "" ]]
        then
            echo "Error: file required for dump action"
            exit 1
        fi
        $JATTACH $PID load $PROFILER true dumpRawTraces:$FILE > /dev/null
        ;;
esac
<commit_msg>Replaced usage of realpath with readlink -f<commit_after>#!/bin/bash

OPTIND=1
SCRIPT_DIR=$(dirname $0)
JATTACH=$SCRIPT_DIR/build/jattach
# realpath is not present on all distros, notably on the Travis CI image
PROFILER=$(readlink -f $SCRIPT_DIR/build/libasyncProfiler.so)
ACTION=""
PID=""
START_OPTIONS=""
FILE=""

while getopts ":h?a:p:o:f:" opt; do
    case $opt in
        h|\?)
            echo "Usage: $0 -a <start|stop|dump> -p <pid>"
            echo "       [-o start-options] [-f output-file]"
            echo ""
            echo "Example: $0 -p 8983 -a start"
            echo "         $0 -p 8983 -a stop"
            exit 1
            ;;
        a)
            ACTION=$OPTARG
            ;;
        p)
            PID=$OPTARG
            ;;
        o)
            START_OPTIONS=$OPTARG
            ;;
        f)
            FILE=$OPTARG
            ;;
    esac
done

if [[ "$PID" == "" ]]
then
    echo "Error: pid is required"
    exit 1
fi
if [[ "$ACTION" == "" ]]
then
    echo "Error: action is required (start, stop, or dump)"
    exit 1
fi

case $ACTION in
    "start")
        $JATTACH $PID load $PROFILER true $START_OPTIONS,start > /dev/null
        ;;
    "stop")
        $JATTACH $PID load $PROFILER true stop > /dev/null
        ;;
    "dump")
        if [[ "$FILE" == "" ]]
        then
            echo "Error: file required for dump action"
            exit 1
        fi
        $JATTACH $PID load $PROFILER true dumpRawTraces:$FILE > /dev/null
        ;;
esac

{'fraction_non_alphanumeric': 0.1349095966620306, 'fraction_numerical': 0.011821974965229486, 'mean_word_length': 1.582585278276481, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 13, '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': '3768983', 'n_tokens_mistral': 1006, 'n_tokens_neox': 948, 'n_words': 270}