<commit_before>package main

import (
	"flag"
	"fmt"
	"os"

	"github.com/milosgajdos83/gosom/pkg/dataset"
	"github.com/milosgajdos83/gosom/pkg/utils"
	"github.com/milosgajdos83/gosom/som"
)

var (
	// path to input data set
	input string
	// feature scaling flag
	scale bool
	// map dimensions: 2D only [for now]
	dims string
	// map grid type: planar
	grid string
	// training method: seq, batch
	training string
	// map unit shape type: hexagon, rectangle
	ushape string
	// initial SOM unit neihbourhood radius
	radius int
	// radius decay strategy: lin, exp
	rdecay string
	// neighbourhood func: gaussian, bubble, mexican
	neighb string
	// initial SOM learning rate
	lrate int
	// learning rate decay strategy: lin, exp
	ldecay string
)

func init() {
	flag.StringVar(&input, "input", "", "Path to input data set")
	flag.BoolVar(&scale, "scale", false, "Request data scaling")
	flag.StringVar(&dims, "dims", "", "comma-separated SOM dimensions")
	flag.StringVar(&grid, "grid", "planar", "SOM grid")
	flag.StringVar(&ushape, "ushape", "hexagon", "SOM map unit shape")
	flag.StringVar(&training, "training", "seq", "SOM training method")
	flag.IntVar(&radius, "radius", 0, "SOM neihbourhood starting radius")
	flag.StringVar(&rdecay, "rdecay", "lin", "Radius decay strategy")
	flag.StringVar(&neighb, "neighb", "gaussian", "SOM neighbourhood function")
	flag.IntVar(&lrate, "lrate", 0, "SOM initial learning rate")
	flag.StringVar(&ldecay, "ldecay", "lin", "Learning rate decay strategy")
}

func parseCliFlags() error {
	// parse cli flags
	flag.Parse()
	// path to input data is mandatory
	if input == "" {
		return fmt.Errorf("Invalid path to input data: %s\n", input)
	}
	return nil
}

func main() {
	// parse cli flags; exit with non-zero return code on error
	if err := parseCliFlags(); err != nil {
		fmt.Printf("Error parsing cli flags: %s\n", err)
		os.Exit(1)
	}
	// parse SOM grid dimensions
	mdims, err := utils.ParseDims(dims)
	if err != nil {
		fmt.Printf("Error parsing grid dimensions: %s\n", err)
		os.Exit(1)
	}
	// load data set from a file in provided path
	ds, err := dataset.New(input)
	if err != nil {
		fmt.Printf("Unable to load Data Set: %s\n", err)
		os.Exit(1)
	}
	// scale input data if requested
	data := ds.Data()
	if scale {
		data = ds.Scale()
	}
	// SOM configuration
	mConfig := &som.MapConfig{
		Dims:     mdims,
		InitFunc: som.RandInit,
		Grid:     grid,
		UShape:   ushape,
	}
	// create new SOM map
	smap, err := som.NewMap(mConfig, data)
	if err != nil {
		fmt.Printf("Failed to create new SOM: %s\n", err)
		os.Exit(1)
	}
	fmt.Printf("Hello Go SOM: %v\n", smap)
}
<commit_msg>radius and lrate are now floats as they should be<commit_after>package main

import (
	"flag"
	"fmt"
	"os"

	"github.com/milosgajdos83/gosom/pkg/dataset"
	"github.com/milosgajdos83/gosom/pkg/utils"
	"github.com/milosgajdos83/gosom/som"
)

var (
	// path to input data set
	input string
	// feature scaling flag
	scale bool
	// map dimensions: 2D only [for now]
	dims string
	// map grid type: planar
	grid string
	// training method: seq, batch
	training string
	// map unit shape type: hexagon, rectangle
	ushape string
	// initial SOM unit neihbourhood radius
	radius float64
	// radius decay strategy: lin, exp
	rdecay string
	// neighbourhood func: gaussian, bubble, mexican
	neighb string
	// initial SOM learning rate
	lrate float64
	// learning rate decay strategy: lin, exp
	ldecay string
)

func init() {
	flag.StringVar(&input, "input", "", "Path to input data set")
	flag.BoolVar(&scale, "scale", false, "Request data scaling")
	flag.StringVar(&dims, "dims", "", "comma-separated SOM dimensions")
	flag.StringVar(&grid, "grid", "planar", "SOM grid")
	flag.StringVar(&ushape, "ushape", "hexagon", "SOM map unit shape")
	flag.StringVar(&training, "training", "seq", "SOM training method")
	flag.Float64Var(&radius, "radius", 0.0, "SOM neihbourhood starting radius")
	flag.StringVar(&rdecay, "rdecay", "lin", "Radius decay strategy")
	flag.StringVar(&neighb, "neighb", "gaussian", "SOM neighbourhood function")
	flag.Float64Var(&lrate, "lrate", 0.0, "SOM initial learning rate")
	flag.StringVar(&ldecay, "ldecay", "lin", "Learning rate decay strategy")
}

func parseCliFlags() error {
	// parse cli flags
	flag.Parse()
	// path to input data is mandatory
	if input == "" {
		return fmt.Errorf("Invalid path to input data: %s\n", input)
	}
	return nil
}

func main() {
	// parse cli flags; exit with non-zero return code on error
	if err := parseCliFlags(); err != nil {
		fmt.Printf("Error parsing cli flags: %s\n", err)
		os.Exit(1)
	}
	// parse SOM grid dimensions
	mdims, err := utils.ParseDims(dims)
	if err != nil {
		fmt.Printf("Error parsing grid dimensions: %s\n", err)
		os.Exit(1)
	}
	// load data set from a file in provided path
	ds, err := dataset.New(input)
	if err != nil {
		fmt.Printf("Unable to load Data Set: %s\n", err)
		os.Exit(1)
	}
	// scale input data if requested
	data := ds.Data()
	if scale {
		data = ds.Scale()
	}
	// SOM configuration
	mConfig := &som.MapConfig{
		Dims:     mdims,
		InitFunc: som.RandInit,
		Grid:     grid,
		UShape:   ushape,
	}
	// create new SOM map
	smap, err := som.NewMap(mConfig, data)
	if err != nil {
		fmt.Printf("Failed to create new SOM: %s\n", err)
		os.Exit(1)
	}
	fmt.Printf("Hello Go SOM: %v\n", smap)
}

{'fraction_non_alphanumeric': 0.14339622641509434, 'fraction_numerical': 0.006792452830188679, 'mean_word_length': 3.7670863309352516, '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': '6548037', 'n_tokens_mistral': 1984, 'n_tokens_neox': 1924, 'n_words': 593}