<commit_before>dir = File.dirname(__FILE__)

# Loading trusted version of Treetop to compile the compiler
trusted_treetop_path = Gem.source_index.find_name('treetop', ["1.1.3"]).last.full_gem_path
require File.join(trusted_treetop_path, 'lib', 'treetop')

# Relocating trusted version of Treetop to Trusted::Treetop
Trusted = Module.new
Trusted::Treetop = Treetop
Object.send(:remove_const, :Treetop)
Object.send(:remove_const, :TREETOP_ROOT)

# Requiring version of Treetop that is under test
require File.expand_path(File.join(dir, '..', 'lib', 'treetop'))
# Remove stale Metagrammar defined by the generated metagrammar.rb in system under test
Treetop::Compiler.send(:remove_const, :Metagrammar)

# Compile and evaluate freshly generated metagrammar source
METAGRAMMAR_PATH = File.join(TREETOP_ROOT, 'compiler', 'metagrammar.treetop')
compiled_metagrammar_source = Trusted::Treetop::Compiler::GrammarCompiler.new.ruby_source(METAGRAMMAR_PATH)
Object.class_eval(compiled_metagrammar_source)
<commit_msg>wb/ns - Relaxed versioning constraint on trusted treetop gem<commit_after>dir = File.dirname(__FILE__)

# Loading trusted version of Treetop to compile the compiler
trusted_treetop_path = Gem.source_index.find_name('treetop').last.full_gem_path
require File.join(trusted_treetop_path, 'lib', 'treetop')

# Relocating trusted version of Treetop to Trusted::Treetop
Trusted = Module.new
Trusted::Treetop = Treetop
Object.send(:remove_const, :Treetop)
Object.send(:remove_const, :TREETOP_ROOT)

# Requiring version of Treetop that is under test
require File.expand_path(File.join(dir, '..', 'lib', 'treetop'))
# Remove stale Metagrammar defined by the generated metagrammar.rb in system under test
Treetop::Compiler.send(:remove_const, :Metagrammar)

# Compile and evaluate freshly generated metagrammar source
METAGRAMMAR_PATH = File.join(TREETOP_ROOT, 'compiler', 'metagrammar.treetop')
compiled_metagrammar_source = Trusted::Treetop::Compiler::GrammarCompiler.new.ruby_source(METAGRAMMAR_PATH)
Object.class_eval(compiled_metagrammar_source)

{'fraction_non_alphanumeric': 0.10215053763440861, 'fraction_numerical': 0.001466275659824047, 'mean_word_length': 7.9, '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': '4883410', 'n_tokens_mistral': 704, 'n_tokens_neox': 675, 'n_words': 152}