<commit_before>package main

import (
	"strconv"
	"strings"
)

func initRHash() *RObject {
	obj := &RObject{}
	obj.name = "RHash"
	obj.ivars = make(map[string]Object)
	obj.class = nil
	obj.methods = make(map[string]*RMethod)

	// RHash method initialization
	obj.methods["new"] = &RMethod{gofunc: RHash_new}
	obj.methods["[]="] = &RMethod{gofunc: RHash_assign_to_key}
	obj.methods["inspect"] = &RMethod{gofunc: RHash_inspect}

	return obj
}

func RHash_new(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := &RObject{}
	obj.class = vm.consts["RHash"]
	obj.ivars = make(map[string]Object)
	obj.ivars["map"] = make(map[RValue]*RObject)

	if v != nil && len(v) > 0 {
		for i := 0; i < len(v); i += 2 {
			key, val := v[i].(*RObject), v[i+1].(*RObject)
			dummy_pair := make([]Object, 2, 2)
			dummy_pair[0] = key
			dummy_pair[1] = val
			RHash_assign_to_key(vm, obj, dummy_pair)
		}
	}

	return obj
}

func RHash_assign_to_key(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := receiver.(*RObject)
	hash := obj.ivars["map"].(map[RValue]*RObject)
	if v != nil && len(v) == 2 {
		hash[v[0].(*RObject).val] = v[1].(*RObject)
	}

	return obj
}

func RHash_inspect(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := receiver.(*RObject)
	hash := obj.ivars["map"].(map[RValue]*RObject)

	if len(hash) == 0 {
		return "[]"
	}

	strList := make([]string, 0, 0)

	for key, val := range hash {
		valStr := make([]string, 2, 2)
		if len(key.str) != 0 {
			valStr[0] = key.str
		} else { // Currently we only have fixnum
			valStr[0] = strconv.FormatInt(key.fixnum, 10)
		}
		valStr[1] = val.methodLookup("inspect").gofunc(vm, val, nil).(string)
		strList = append(strList, strings.Join(valStr, "=>"))
	}

	finalStr := strings.Join(strList, ", ")

	strList = []string{"{", finalStr, "}"}

	return strings.Join(strList, "")
}
<commit_msg>[RHash] find by key implemented<commit_after>package main

import (
	"strconv"
	"strings"
)

func initRHash() *RObject {
	obj := &RObject{}
	obj.name = "RHash"
	obj.ivars = make(map[string]Object)
	obj.class = nil
	obj.methods = make(map[string]*RMethod)

	// RHash method initialization
	obj.methods["new"] = &RMethod{gofunc: RHash_new}
	obj.methods["[]"] = &RMethod{gofunc: RHash_find_by_key}
	obj.methods["[]="] = &RMethod{gofunc: RHash_assign_to_key}
	obj.methods["inspect"] = &RMethod{gofunc: RHash_inspect}

	return obj
}

func RHash_new(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := &RObject{}
	obj.class = vm.consts["RHash"]
	obj.ivars = make(map[string]Object)
	obj.ivars["map"] = make(map[RValue]*RObject)

	if v != nil && len(v) > 0 {
		for i := 0; i < len(v); i += 2 {
			key, val := v[i].(*RObject), v[i+1].(*RObject)
			dummy_pair := make([]Object, 2, 2)
			dummy_pair[0] = key
			dummy_pair[1] = val
			RHash_assign_to_key(vm, obj, dummy_pair)
		}
	}

	return obj
}

func RHash_find_by_key(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := receiver.(*RObject)
	hash := obj.ivars["map"].(map[RValue]*RObject)
	val, ok := hash[v[0].(*RObject).val]

	if !ok {
		return nil
	}
	return val
}

func RHash_assign_to_key(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := receiver.(*RObject)
	hash := obj.ivars["map"].(map[RValue]*RObject)
	if v != nil && len(v) == 2 {
		hash[v[0].(*RObject).val] = v[1].(*RObject)
	}

	return obj
}

func RHash_inspect(vm *GobiesVM, receiver Object, v []Object) Object {
	obj := receiver.(*RObject)
	hash := obj.ivars["map"].(map[RValue]*RObject)

	if len(hash) == 0 {
		return "[]"
	}

	strList := make([]string, 0, 0)

	for key, val := range hash {
		valStr := make([]string, 2, 2)
		if len(key.str) != 0 {
			valStr[0] = key.str
		} else { // Currently we only have fixnum
			valStr[0] = strconv.FormatInt(key.fixnum, 10)
		}
		valStr[1] = val.methodLookup("inspect").gofunc(vm, val, nil).(string)
		strList = append(strList, strings.Join(valStr, "=>"))
	}

	finalStr := strings.Join(strList, ", ")

	strList = []string{"{", finalStr, "}"}

	return strings.Join(strList, "")
}

{'fraction_non_alphanumeric': 0.19305694305694307, 'fraction_numerical': 0.011238761238761238, 'mean_word_length': 4.242146596858639, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5951986', 'n_tokens_mistral': 1727, 'n_tokens_neox': 1625, 'n_words': 338}