<commit_before>package file

import (
	"io/ioutil"
	"path/filepath"
)

type Manager interface {
	Read(path string) ([]byte, error)
	Write(path string, data []byte) error
	Search(query string) (interface{}, error)

	GetFullPath(path string) string
}

func New(basepath string) (Manager, error) {
	return &manager{
		basepath: basepath,
	}, nil
}

type manager struct {
	basepath string
}

func (m *manager) Read(path string) ([]byte, error) {
	return ioutil.ReadFile(m.GetFullPath(path))
}
func (m *manager) Write(path string, data []byte) error {
	return ioutil.WriteFile(m.GetFullPath(path), data, 0644)
}
func (m *manager) GetFullPath(path string) string {
	return filepath.Join(m.basepath, path)
}<commit_msg>Add mkdirp on write file<commit_after>package file

import (
	"io/ioutil"
	"os"
	"path/filepath"
)

type Manager interface {
	Read(path string) ([]byte, error)
	Write(path string, data []byte) error
	Search(query string) (interface{}, error)

	GetFullPath(path string) string
}

func New(basepath string) (Manager, error) {
	return &manager{
		basepath: basepath,
	}, nil
}

type manager struct {
	basepath string
}

func (m *manager) Read(path string) ([]byte, error) {
	return ioutil.ReadFile(m.GetFullPath(path))
}
func (m *manager) Write(path string, data []byte) error {
	fullpath := m.GetFullPath(path)
	dirpath := filepath.Dir(fullpath)
	if err := os.MkdirAll(dirpath, 0755); err != nil {
		return err
	}
	return ioutil.WriteFile(m.GetFullPath(path), data, 0644)
}
func (m *manager) GetFullPath(path string) string {
	return filepath.Join(m.basepath, path)
}
{'fraction_non_alphanumeric': 0.13760304375396323, 'fraction_numerical': 0.007609384908053266, 'mean_word_length': 5.1640625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4589761', 'n_tokens_mistral': 585, 'n_tokens_neox': 569, 'n_words': 155}