<commit_before>diff --git a/src/tm_mad/tm_common.sh b/src/tm_mad/tm_common.sh
index 0f589fe..1e98122 100644
--- a/src/tm_mad/tm_common.sh
+++ b/src/tm_mad/tm_common.sh
@@ -145,3 +145,56 @@ function timeout_exec_and_log
         exit $CMD_CODE
     fi
 }
+ 
+function download_extract
+{
+    URL=$1
+    ARCHIVE=$2
+    FILENAME=$3
+    HOST=$4
+
+    if [ "x$HOST" != "x" ]; then
+        HOST="ssh $HOST"
+    fi
+
+    $HOST curl -k -o $ARCHIVE $URL
+
+    extract_tar $ARCHIVE $FILENAME
+
+    rm -rf $ARCHIVE
+}
+
+function file_ends_with
+{
+    FILE=$1
+    EXTENSION=$2
+
+    if [ "x$(echo $FILE | grep -E $EXTENSION)" != "x" ]; then
+        echo 0
+    else
+        echo 1
+    fi
+}
+
+function extract_tar
+{
+    ARCHIVE=$1
+    OUTPUT=$2
+
+    if [ $(file_ends_with $ARCHIVE '.tar.gz') = 0 ]; then
+        $FORMAT=z
+    elif [ $(file_ends_with $ARCHIVE '.tar.bz2') = 0 ]; then
+        $FORMAT=j
+    elif [ $(file_ends_with $ARCHIVE '.tar.xz') = 0 ]; then
+        $FORMAT=J
+    fi
+
+    TAR_CMD="tar -x${FORMAT}f $ARCHIVE"
+
+    if [ "x$OUTPUT" != "x" ]; then
+        $TAR_CMD -O > $OUTPUT
+    else
+        $TAR_CMD
+    fi
+}
+<commit_msg>Fix tm common patch to work with ssh tm<commit_after>diff --git a/src/tm_mad/tm_common.sh b/src/tm_mad/tm_common.sh
index 0f589fe..dcd03cb 100644
--- a/src/tm_mad/tm_common.sh
+++ b/src/tm_mad/tm_common.sh
@@ -145,3 +145,65 @@ function timeout_exec_and_log
         exit $CMD_CODE
     fi
 }
+
+function download_extract
+{
+    URL=$1
+    ARCHIVE=$2
+    FILENAME=$3
+    HOST=$4
+
+    if [ "x$HOST" != "x" ]; then
+        SSH_CMD="ssh $HOST"
+    fi
+
+    $SSH_CMD curl -k -o $ARCHIVE $URL
+
+    extract_tar $ARCHIVE $FILENAME $HOST
+
+    $SSH_CMD rm -rf $ARCHIVE
+}
+
+function file_ends_with
+{
+    FILE=$1
+    EXTENSION=$2
+
+    if [ "x$(echo $FILE | grep -E $EXTENSION)" != "x" ]; then
+        echo 0
+    else
+        echo 1
+    fi
+}
+
+function extract_tar
+{
+    ARCHIVE=$1
+    OUTPUT=$2
+    HOST=$3
+
+    if [ $(file_ends_with $ARCHIVE '.tar.gz') = 0 ]; then
+        FORMAT=z
+    elif [ $(file_ends_with $ARCHIVE '.tar.bz2') = 0 ]; then
+        FORMAT=j
+    elif [ $(file_ends_with $ARCHIVE '.tar.xz') = 0 ]; then
+        FORMAT=J
+    fi
+    
+    TAR_CMD="tar -x${FORMAT}f $ARCHIVE"
+
+    if [ "x$HOST" != "x" ]; then
+       SSH_CMD="ssh $HOST"
+    fi
+
+    if [ "x$OUTPUT" != "x" ]; then
+        if [ "x$HOST" != "x" ]; then
+            $SSH_CMD "$TAR_CMD -O > $OUTPUT"
+        else
+            $TAR_CMD -O > $OUTPUT
+        fi
+    else
+        $SSH_CMD $TAR_CMD 
+    fi
+}
+
{'fraction_non_alphanumeric': 0.18455598455598454, 'fraction_numerical': 0.02895752895752896, 'mean_word_length': 2.2146401985111663, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4128928', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1095, 'n_words': 225}