<commit_before>package monetdb

import (
	"database/sql"
	"database/sql/driver"
)

func init() {
	sql.Register("monetdb", &Driver{})
}

type Driver struct {
}

type config struct {
	Username string
	Password string
	Hostname string
	Database string
	Port     int
}

func (*Driver) Open(name string) (driver.Conn, error) {
	c := config{
		Username: "voc",
		Password: "<PASSWORD>",
		Hostname: "localhost",
		Database: "voc",
		Port:     50000,
	}

	return newConn(c)
}<commit_msg>Add connection string parser<commit_after>package monetdb

import (
	"database/sql"
	"database/sql/driver"
	"fmt"
	"regexp"
	"strconv"
)

func init() {
	sql.Register("monetdb", &Driver{})
}

type Driver struct {
}

type config struct {
	Username string
	Password string
	Hostname string
	Database string
	Port     int
}

func (*Driver) Open(name string) (driver.Conn, error) {
	c, err := parseDSN(name)
	if err != nil {
		return nil, err
	}
	return newConn(c)
}

func parseDSN(name string) (config, error) {
	re := regexp.MustCompile(`((?P<username>.+?)(:(?P<password>.+?))?@)?(?P<hostname>.+?)(:(?P<port>\d+?))?/(?P<database>.+?)`)
	if !re.MatchString(name) {
		return config{}, fmt.Errorf("Invalid DSN")
	}
	m := re.FindAllStringSubmatch(name, -1)[0]
	n := re.SubexpNames()

	c := config{
		Hostname: "localhost",
		Port:     50000,
	}
	for i, v := range m {
		if n[i] == "username" {
			c.Username = v
		} else if n[i] == "password" {
			c.Password = v
		} else if n[i] == "hostname" {
			c.Hostname = v
		} else if n[i] == "port" {
			c.Port, _ = strconv.Atoi(v)
		} else if n[i] == "database" {
			c.Database = v
		}
	}

	return c, nil
}
{'fraction_non_alphanumeric': 0.1781750924784217, 'fraction_numerical': 0.007398273736128237, 'mean_word_length': 3.623931623931624, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6828506', 'n_tokens_mistral': 675, 'n_tokens_neox': 633, 'n_words': 154}