<commit_before>package main

import (
	"fmt"
	"net"
	"os"
	"path/filepath"
	"strings"
)

func findAvailablePort() (*net.TCPAddr, error) {
	l, err := net.Listen("tcp", ":0")
	if err == nil {
		defer l.Close()
		addr := l.Addr()
		if a, ok := addr.(*net.TCPAddr); ok {
			return a, nil
		}
		return nil, fmt.Errorf("Unable to obtain a valid tcp port. %v", addr)
	}
	return nil, err
}

// Test whether any element in prefix begins with path
func hasPrefix(path string, prefix []string) bool {
	if len(path) == 0 || len(prefix) == 0 {
		return false
	}

	for _, p := range prefix {
		p = strings.TrimSpace(p)

		if len(p) > 0 && strings.HasPrefix(path, p) {
			return true
		}
	}

	return false
}

// Returns a list of directory names with a sub-directory named "src"
func ImportRoots(path string) (roots []string) {
	dir, _ := filepath.Split(filepath.Clean(path))

	for i, p := len(dir)-1, len(dir); i > 0; i-- {
		if os.IsPathSeparator(dir[i]) {
			if dir[i+1:p] == "src" {
				roots = append(roots, dir[:i])
			}
			p = i
		}
	}

	return roots
}

func fileExists(name string) bool {
	if _, err := os.Open(name); err != nil {
		return !os.IsNotExist(err)
	}

	return true
}
<commit_msg>Close file handle<commit_after>package main

import (
	"fmt"
	"net"
	"os"
	"path/filepath"
	"strings"
)

func findAvailablePort() (*net.TCPAddr, error) {
	l, err := net.Listen("tcp", ":0")
	if err == nil {
		defer l.Close()
		addr := l.Addr()
		if a, ok := addr.(*net.TCPAddr); ok {
			return a, nil
		}
		return nil, fmt.Errorf("Unable to obtain a valid tcp port. %v", addr)
	}
	return nil, err
}

// Test whether any element in prefix begins with path
func hasPrefix(path string, prefix []string) bool {
	if len(path) == 0 || len(prefix) == 0 {
		return false
	}

	for _, p := range prefix {
		p = strings.TrimSpace(p)

		if len(p) > 0 && strings.HasPrefix(path, p) {
			return true
		}
	}

	return false
}

// Returns a list of directory names with a sub-directory named "src"
func ImportRoots(path string) (roots []string) {
	dir, _ := filepath.Split(filepath.Clean(path))

	for i, p := len(dir)-1, len(dir); i > 0; i-- {
		if os.IsPathSeparator(dir[i]) {
			if dir[i+1:p] == "src" {
				roots = append(roots, dir[:i])
			}
			p = i
		}
	}

	return roots
}

func fileExists(name string) bool {
	f, err := os.Open(name)
	if err != nil {
		return !os.IsNotExist(err)
	}

	f.Close()

	return true
}

{'fraction_non_alphanumeric': 0.16359060402684564, 'fraction_numerical': 0.00587248322147651, 'mean_word_length': 3.140625, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 7, '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': '6353431', 'n_tokens_mistral': 989, 'n_tokens_neox': 911, 'n_words': 270}