<commit_before>package main

import (
	"bufio"
	"io"
	"os"
	"os/user"

	blake "github.com/minio/blake2b-simd"
)

// GetUserHome obtain the current home directory of the user
func GetUserHome() string {
	usr, err := user.Current()
	if err != nil {
		panic(err)
	}

	return usr.HomeDir
}

const bufferSize = 2 * 1024

// ComputeHash calculates the hash for the current file
// if bufferNumber is not zero then we will only hash the first bufferNumber blocks (bufferSize)
func ComputeHash(filename string, bufNumber int) ([]byte, error) {
	file, err := os.Open(filename)
	if err != nil {
		return nil, err
	}
	defer file.Close()

	hash := blake.New256()
	buf, reader := make([]byte, bufferSize), bufio.NewReader(file)
	if bufNumber <= 0 {
		for {
			n, err := reader.Read(buf)
			if err != nil {
				if err == io.EOF {
					break
				}
				return nil, err
			}

			hash.Write(buf[:n])
		}
	} else {
		for ; bufNumber > 0; bufNumber -= 1 {
			n, err := reader.Read(buf)
			if err != nil {
				if err == io.EOF {
					break
				}
				return nil, err
			}

			hash.Write(buf[:n])
		}
	}

	return hash.Sum(nil), nil<commit_msg>replaced bufNumber -=1 for bufNumber--<commit_after>package main

import (
	"bufio"
	"io"
	"os"
	"os/user"

	blake "github.com/minio/blake2b-simd"
)

// GetUserHome obtain the current home directory of the user
func GetUserHome() string {
	usr, err := user.Current()
	if err != nil {
		panic(err)
	}

	return usr.HomeDir
}

const bufferSize = 2 * 1024

// ComputeHash calculates the hash for the current file
// if bufferNumber is not zero then we will only hash the first bufferNumber blocks (bufferSize)
func ComputeHash(filename string, bufNumber int) ([]byte, error) {
	file, err := os.Open(filename)
	if err != nil {
		return nil, err
	}
	defer file.Close()

	hash := blake.New256()
	buf, reader := make([]byte, bufferSize), bufio.NewReader(file)
	if bufNumber <= 0 {
		for {
			n, err := reader.Read(buf)
			if err != nil {
				if err == io.EOF {
					break
				}
				return nil, err
			}

			hash.Write(buf[:n])
		}
	} else {
		for ; bufNumber > 0; bufNumber-- {
			n, err := reader.Read(buf)
			if err != nil {
				if err == io.EOF {
					break
				}
				return nil, err
			}

			hash.Write(buf[:n])
		}
	}

	return hash.Sum(nil), nil
{'fraction_non_alphanumeric': 0.134394341290893, 'fraction_numerical': 0.010610079575596816, 'mean_word_length': 2.829103214890017, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6211258', 'n_tokens_mistral': 945, 'n_tokens_neox': 810, 'n_words': 248}