<commit_before>from utils import json2
import jsonschema

class JsonSchema:
	def __init__(self, schema_file, verbose = True):
		self.f = schema_file
		self.verbose = verbose
		self.schema = json2.loadf(self.f)
	def validate(self, jsonObj):
		try:
			#return jsonschema.validate(jsonObj, self.schema, format_checker=jsonschema.FormatChecker())
			jsonschema.validate(jsonObj, self.schema)
			return True
		except ValidationError as err:
			if self.verbose:
				print err
			return False
				


<commit_msg>hacked base path on json schema [ref:jsonschema/issues/274]<commit_after>from utils import json2
import jsonschema
import os

class JsonSchema:
	def __init__(self, schema_file, verbose = True):
		self.f = schema_file
		self.verbose = verbose
		self.schema = json2.loadf(self.f)
		self.base = os.path.dirname(os.path.abspath(__file__))
		for e in self.schema['anyOf']:
			e['$ref'] = e['$ref'].format(self.base)




	def validate(self, jsonObj):
		try:
			#return jsonschema.validate(jsonObj, self.schema, format_checker=jsonschema.FormatChecker())
			jsonschema.validate(jsonObj, self.schema)
			return True
		except jsonschema.ValidationError as err:
			if self.verbose:
				print err
			return False
				



{'fraction_non_alphanumeric': 0.10296540362438221, 'fraction_numerical': 0.005766062602965404, 'mean_word_length': 4.259740259740259, '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': '2343880', 'n_tokens_mistral': 460, 'n_tokens_neox': 411, 'n_words': 98}