<commit_before>package dock

import "bytes"

func makeMessageSplitter() func(input []byte) []string {
	buffer := []byte{}

	return func(input []byte) []string {
		buffer = append(buffer, input...)
		msgs := []string{}

		for {
			i := bytes.IndexByte(buffer, '\r')
			if i == -1 {
				break
			}
			msgs = append(msgs, string(buffer[:i]))
			buffer = buffer[i+1:]
		}

		return msgs
	}
}

func msgToEvent(msg string) Event {
	return Event{}
}<commit_msg>added msgToEvent<commit_after>package dock

import (
	"bytes"
	"fmt"
)

func makeMessageSplitter() func(input []byte) []string {
	buffer := []byte{}

	return func(input []byte) []string {
		buffer = append(buffer, input...)
		msgs := []string{}

		for {
			i := bytes.IndexByte(buffer, '\r')
			if i == -1 {
				break
			}
			msgs = append(msgs, string(buffer[:i]))
			buffer = buffer[i+1:]
		}

		return msgs
	}
}

// u 1/module int,int,int,int....
func msgToEvent(msg string) Event {
	var evtype rune
	var port int
	var module string
	var values [8]int

	n, _ := fmt.Sscanf(msg, "%c %d/%s %d,%d,%d,%d,%d,%d,%d,%d",
		&evtype, &port, &module,
		&values[0], &values[1], &values[2], &values[3],
		&values[4], &values[5], &values[6], &values[7])

	//	fmt.Println(evtype, port, module, values, n, err)

	event := Event{}
	switch evtype {
	case 'c':
		event.EventType = Connected
	case 'd':
		event.EventType = Disconnected
	case 'u':
		event.EventType = Update
	default:
		event.EventType = Invalid
	}

	event.ModuleType = FromString(module)
	event.Port = port
	event.Params = values[:n-3]

	return event
}
{'fraction_non_alphanumeric': 0.1811175337186898, 'fraction_numerical': 0.009633911368015413, 'mean_word_length': 3.5555555555555554, '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': '2073576', 'n_tokens_mistral': 653, 'n_tokens_neox': 587, 'n_words': 146}