<commit_before>package models

import (
	"strings"
)

type (
	Common struct {
		Type     string `json:"type"`
		DeviceId string `json:"deviceId"`
		Source   string `json:"source"`
		Time     string `json:"time"`
	}

	BgEvent struct {
		Common
		Units string `json:"units"`
		Value string `json:"value"`
	}

	FoodEvent struct {
		Common
		Carbs string `json:"carbs"`
	}

	BasalEvent struct {
		Common
		DeliveryType string `json:"deliveryType"`
		Value        string `json:"value"`
	}
	BolusEvent struct {
		Common
		SubType string `json:"subType"`
		Value   string `json:"value"`
	}
)

const (
	BG    = "BG="
	CARB  = "CHO="
	BASAL = "SA="
	BOLUS = "LA="
)

func Translate(smsString string) []interface{} {

	var events []interface{}

	raw := strings.Split(smsString, " ")

outer:
	for i := range raw {
		switch {
		case strings.Index(raw[i], BG) != -1:
			events = append(events, makeBg(raw[i]))
			break
		case strings.Index(raw[i], CARB) != -1:
			events = append(events, makeCarb(raw[i]))
			break
		case strings.Index(raw[i], BASAL) != -1:
			events = append(events, makeBasal(raw[i]))
			break
		case strings.Index(raw[i], BOLUS) != -1:
			events = append(events, makeBolus(raw[i]))
			break
		default:
			events = append(events, makeNote(smsString))
			break outer
		}
	}
	return events
}

func makeBg(bgString string) *BgEvent {
	return &BgEvent{Common: Common{Type: "smbg", Source: "dinojr"}, Units: "", Value: ""}
}

func makeNote(noteString string) *Common {
	return &Common{Type: "note", Source: "dinojr"}
}

func makeCarb(carbString string) *FoodEvent {
	return &FoodEvent{Common: Common{Type: "food", Source: "dinojr"}, Carbs: ""}
}

func makeBolus(bolusString string) *BolusEvent {
	return &BolusEvent{Common: Common{Type: "bolus", Source: "dinojr"}, SubType: "injected", Value: ""}
}

func makeBasal(basalString string) *BasalEvent {
	//"deliveryType": "injected",
	return &BasalEvent{Common: Common{Type: "basal", Source: "dinojr"}, DeliveryType: "injected", Value: ""}
}<commit_msg>get the values<commit_after>package models

import (
	"strings"
)

type (
	Common struct {
		Type     string `json:"type"`
		DeviceId string `json:"deviceId"`
		Source   string `json:"source"`
		Time     string `json:"time"`
	}

	BgEvent struct {
		Common
		Units string `json:"units"`
		Value string `json:"value"`
	}

	FoodEvent struct {
		Common
		Carbs string `json:"carbs"`
	}

	BasalEvent struct {
		Common
		DeliveryType string `json:"deliveryType"`
		Value        string `json:"value"`
	}
	BolusEvent struct {
		Common
		SubType string `json:"subType"`
		Value   string `json:"value"`
	}
)

const (
	BG    = "BG="
	CARB  = "CHO="
	BASAL = "SA="
	BOLUS = "LA="
)

func Translate(smsString string) []interface{} {

	var events []interface{}

	raw := strings.Split(smsString, " ")

outer:
	for i := range raw {
		switch {
		case strings.Index(raw[i], BG) != -1:
			events = append(events, makeBg(raw[i]))
			break
		case strings.Index(raw[i], CARB) != -1:
			events = append(events, makeCarb(raw[i]))
			break
		case strings.Index(raw[i], BASAL) != -1:
			events = append(events, makeBasal(raw[i]))
			break
		case strings.Index(raw[i], BOLUS) != -1:
			events = append(events, makeBolus(raw[i]))
			break
		default:
			events = append(events, makeNote(smsString))
			break outer
		}
	}
	return events
}

func makeBg(bgString string) *BgEvent {
	bg := strings.Split(bgString, BG)
	return &BgEvent{Common: Common{Type: "smbg", Source: "dinojr"}, Units: "", Value: bg[1]}
}

func makeNote(noteString string) *Common {
	return &Common{Type: "note", Source: "dinojr"}
}

func makeCarb(carbString string) *FoodEvent {
	carb := strings.Split(carbString, CARB)
	return &FoodEvent{Common: Common{Type: "food", Source: "dinojr"}, Carbs: carb[1]}
}

func makeBolus(bolusString string) *BolusEvent {
	bolus := strings.Split(bolusString, BOLUS)
	return &BolusEvent{Common: Common{Type: "bolus", Source: "dinojr"}, SubType: "injected", Value: bolus[1]}
}

func makeBasal(basalString string) *BasalEvent {
	basal := strings.Split(basalString, BASAL)
	return &BasalEvent{Common: Common{Type: "basal", Source: "dinojr"}, DeliveryType: "injected", Value: basal[1]}
}
{'fraction_non_alphanumeric': 0.15840154068367837, 'fraction_numerical': 0.002888781896966779, 'mean_word_length': 4.340616966580977, 'pattern_counts': {'":': 1, '<': 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': '6386303', 'n_tokens_mistral': 1648, 'n_tokens_neox': 1522, 'n_words': 368}