<commit_before>package workspace

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

// Document is a file in a directory.
type Document struct {
	Root     string
	Filepath string
}

// NewDocument creates a document from a filepath.
func NewDocument(root, file string) Document {
	return Document{
		Root:     root,
		Filepath: file,
	}
}

// Path is the normalized path.
// It uses forward slashes regardless of the operating system.
func (doc Document) Path() string {
	path := strings.Replace(doc.Filepath, doc.Root, "", 1)
	path = strings.TrimLeft(path, string(os.PathSeparator))
	return filepath.ToSlash(path)
}
<commit_msg>Clarify doc comment for NewDocument<commit_after>package workspace

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

// Document is a file in a directory.
type Document struct {
	Root     string
	Filepath string
}

// NewDocument creates a document from a filepath.
// The root is typically the root of the exercise, and
// path is the relative path to the file within the root directory.
func NewDocument(root, path string) Document {
	return Document{
		Root:     root,
		Filepath: path,
	}
}

// Path is the normalized path.
// It uses forward slashes regardless of the operating system.
func (doc Document) Path() string {
	path := strings.Replace(doc.Filepath, doc.Root, "", 1)
	path = strings.TrimLeft(path, string(os.PathSeparator))
	return filepath.ToSlash(path)
}

{'fraction_non_alphanumeric': 0.0989247311827957, 'fraction_numerical': 0.0014336917562724014, 'mean_word_length': 3.8472222222222223, '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': '4188875', 'n_tokens_mistral': 436, 'n_tokens_neox': 429, 'n_words': 158}