Exemplo n.º 1
0
func (scoreRanges ScoreRanges) Populate(raw [][]string) {
	for ind, row := range raw {
		if ind == 0 {
			continue
		}
		scoreRanges[int(utils.SToIP(row[0]))].Upper = utils.SToIP(row[1])
		scoreRanges[int(utils.SToIP(row[0]))].Lower = utils.SToIP(row[2])
	}
}
Exemplo n.º 2
0
func (table XYLookupTable) Populate(raw [][]string) {
	for ind, row := range raw {
		if ind == 0 {
			continue
		}
		table[utils.SToIP(row[0])] = [2]int64{utils.SToIP(row[1]), utils.SToIP(row[2])}
	}
	fmt.Println(len(table))
}
Exemplo n.º 3
0
func MakeLocationSeverities(raw [][]string) LocationSeverities {
	severities := make(LocationSeverities)
	for ind, row := range raw {
		if ind == 0 {
			continue
		}
		severities[row[0]] = utils.SToIP(row[1])
	}
	return severities
}
Exemplo n.º 4
0
func MarshalCrimes(raw [][]string) Crimes {
	crimes := make(Crimes, len(raw)-1)
	for ind, row := range raw {
		if ind == 0 {
			continue
		}
		ind--
		crimes[ind].CaseId = row[0]
		crimes[ind].DateOfOcc = row[1]
		crimes[ind].PrimaryDesc = row[2]
		crimes[ind].SecondaryDesc = row[3]
		crimes[ind].LocationDesc = row[4]
		tempDidArrest := row[5]
		if tempDidArrest == "Y" || tempDidArrest == "TRUE" || tempDidArrest == "true" {
			crimes[ind].Arrest = true
		} else if tempDidArrest == "N" || tempDidArrest == "FALSE" || tempDidArrest == "false" {
			crimes[ind].Arrest = false
		} else {
			panic(fmt.Sprintln("Could not find arrest value for,", tempDidArrest))
		}
		tempWasDom := row[6]
		if tempWasDom == "Y" || tempWasDom == "TRUE" || tempWasDom == "true" {
			crimes[ind].Domestic = true
		} else if tempWasDom == "N" || tempWasDom == "FALSE" || tempWasDom == "false" {
			crimes[ind].Domestic = false
		} else {
			panic(fmt.Sprintln("Could not find arrest value for,", tempWasDom))
		}
		crimes[ind].Beat = utils.SToIP(row[7])
		crimes[ind].District = utils.SToIP(row[8])
		temp := fmt.Sprintln(crimes[ind].PrimaryDesc, crimes[ind].SecondaryDesc)
		if len(temp) < 1 {
			fmt.Println(crimes[ind].PrimaryDesc, crimes[ind].SecondaryDesc)
		}
		if len(row[2]) < 1 || len(row[3]) < 1 {
			fmt.Println("Failed with,", row[2], row[3])
			panic("failed parsing crimes")
		}
	}
	return crimes
}
Exemplo n.º 5
0
func MakeRawCoefficients(rows [][]string) RawCoefficients {
	raw := RawCoefficients{
		PrimaryDesc:   make([]string, len(rows)),
		SecondaryDesc: make([]string, len(rows)),
		Coefficient:   make([]int64, len(rows)),
	}
	for i := 1; i < len(rows); i++ {
		raw.PrimaryDesc[i] = rows[i][0]
		raw.SecondaryDesc[i] = rows[i][1]
		raw.Coefficient[i] = utils.SToIP(rows[i][2])
	}
	return raw
}