<commit_before>package main

import (
	"github.com/xeipuuv/gojsonreference"
	"path"
	"strings"
)

type JsonSchemaBundler interface {
	Bundle()
	GetRootBundle() (*bundle)
	GetBundle(string) (*bundle)
}

type bundler struct {
	rootRef *gojsonreference.JsonReference
	bundles map[string]JsonSchema
}

func NewJsonSchemaBundler(rootReference *gojsonreference.JsonReference) (JsonSchemaBundler) {
	b := bundler{ rootReference, make(map[string]JsonSchema) }
	b.registerBundle(b.rootRef.String(), b.rootRef)
	return &b
}

func (b *bundler) GetRootBundle() (*bundle) {
	return b.GetBundle(b.rootRef.String())
}

func (b *bundler) Bundle() {
	b.bundleRecursive(b.GetRootBundle().schema)
}

func (b *bundler) bundleRecursive(schema *JsonSchema) {
	if schema.Ref != "" {
		b.registerBundle(schema.Ref, &NewRelativeJsonReference(b.rootRef, NewJsonReference(schema.Ref)))
	}
	// object type
	for _, v := range schema.Properties {
		b.bundleRecursive(&v)
	}
	for _, d := range schema.Dependencies {
		b.bundleRecursive(&d)
	}
	// array type
	for _, i := range schema.GetItemList() {
		b.bundleRecursive(&i)
	}
}

func (b *bundler) registerBundle(path string, ref *gojsonreference.JsonReference) {
	b.bundles[path] = bundle {
		ref,
		&GetJsonSchemaLoader().Load(ref),
	}
}

func (b *bundler) GetBundle(path string) (*bundle) {
	return &b.bundles[path]
}

type bundle struct {
	ref *gojsonreference.JsonReference
	schema *JsonSchema
}

func (b *bundle) GetBundleName() (string) {
	if b.schema.Id {
		return b.schema.Id
	}
	// filename + pointer
	p := b.ref.GetUrl().Path
	n := []string{
		strings.Replace(path.Base(p), path.Ext(p), "", 1),
		strings.Split(b.ref.GetPointer().String(), "/"),
	}
	return
}


<commit_msg>fixed the dependency resolution in JsonSchemaBundle<commit_after>package main

import (
	"github.com/xeipuuv/gojsonreference"
)

type JsonSchemaBundler interface {
	GetRootSchema() (JsonSchema)
	GetSchema(string) (JsonSchema)
}

type bundler struct {
	rootRef *gojsonreference.JsonReference
	loader JsonSchemaLoader
}

func NewJsonSchemaBundler(loader JsonSchemaLoader, rootRef *gojsonreference.JsonReference) (JsonSchemaBundler) {
	b := &bundler{
		loader,
		rootRef,
	}
	return b
}

func (b *bundler) GetRootSchema() (JsonSchema) {
	return b.loader.Load(b.rootRef)
}

func (b *bundler) GetSchema(refString string) (JsonSchema) {
	return b.loader.Load(NewRelativeJsonReference(b.rootRef, NewJsonReference(refString)))
}


{'fraction_non_alphanumeric': 0.13731958762886598, 'fraction_numerical': 0.0004123711340206186, 'mean_word_length': 5.220512820512821, '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': '883398', 'n_tokens_mistral': 879, 'n_tokens_neox': 862, 'n_words': 171}