<commit_before>package fox

import (
	"sync"
	"gopkg.in/gcfg.v1"
	"log"
)

// Data structure for configuration
type Config struct {
	Storage struct{
		Filepath string
			 }
}

// Sanitize the configuration 
func sanitize(c *Config){
	// Make sure the db path ends with a forwardslash
	s := c.Storage.Filepath
	if len(s) > 0{
		if string(s[len(s) - 1]) != "/" {
			c.Storage.Filepath = s + "/"
		}
	}
}

func LoadConfig(){
	LoadConfigByName("config.gcfg")
}

func LoadConfigByName(name string){
	var isFatal bool = (config == nil)
	var fName = name
	var tmp *Config
	
	tmp = new(Config)
	
	if err := gcfg.ReadFileInto(tmp, fName); err != nil{
		// No config to start up on
		if isFatal {
			panic(err)	
		} else {
			log.Println("Failed to load configuration from " + fName)
			return
		}	
	}
	
	sanitize(tmp)
	cLock.Lock()<commit_msg>Commented the config functions, other minor changes<commit_after>package fox

import (
	"sync"
	"gopkg.in/gcfg.v1"
	"log"
)

// Config is the data structure for passing configuration info
type Config struct {
	Storage struct{
		Filepath string
			 }
}

// Sanitize the configuration 
func sanitize(c *Config){
	// Make sure the db path ends with a forwardslash
	s := c.Storage.Filepath
	if len(s) > 0{
		if string(s[len(s) - 1]) != "/" {
			c.Storage.Filepath = s + "/"
		}
	}
}

// LoadConfig loads configuration using a hard-coded name
// This is what gets called during normal operation
func LoadConfig(){
	LoadConfigByName("config.gcfg")
}

// LoadConfigByName loads a config from a specific file
// Used for separating test from operational conifguration
func LoadConfigByName(name string){
	var isFatal = (config == nil)
	var fName = name
	var tmp *Config
	
	tmp = new(Config)
	
	if err := gcfg.ReadFileInto(tmp, fName); err != nil{
		// No config to start up on
		if isFatal {
			panic(err)	
		} else {
			log.Println("Failed to load configuration from " + fName)
			return
		}	
	}
	
	sanitize(tmp)
	cLock.Lock()
{'fraction_non_alphanumeric': 0.11879160266257041, 'fraction_numerical': 0.0030721966205837174, 'mean_word_length': 3.247826086956522, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2082799', 'n_tokens_mistral': 733, 'n_tokens_neox': 681, 'n_words': 211}