Skip to content

Commit 9e1b7c2

Browse files
committed
Updated based on code review
Signed-off-by: nathannaveen <[email protected]>
1 parent eedd0e5 commit 9e1b7c2

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

internal/scorer/scorer.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"fmt"
1919
"io"
2020
"path"
21+
"reflect"
2122
"strconv"
2223
"strings"
2324
"unicode"
@@ -52,10 +53,7 @@ func (s *Scorer) Score(signals []signal.Set) float64 {
5253
for _, s := range signals {
5354
// Get all the signal data from the set change it to a float.
5455
for k, v := range signal.SetAsMap(s, true) {
55-
switch r := v.(type) {
56-
case float64, float32, int, int16, int32, int64, uint, uint16, uint32, uint64, byte:
57-
record[k] = r.(float64)
58-
}
56+
record[k] = reflect.ValueOf(v).Convert(reflect.TypeOf(float64(0))).Float()
5957
}
6058
}
6159
return s.a.Score(record)
@@ -84,7 +82,7 @@ func NameFromFilepath(filepath string) string {
8482
f := path.Base(filepath)
8583
ext := path.Ext(f)
8684

87-
modified := func(r rune) rune {
85+
modifier := func(r rune) rune {
8886
// Change any non-alphanumeric character into an underscore
8987
if !unicode.IsDigit(r) && !unicode.IsLetter(r) {
9088
return '_'
@@ -97,5 +95,5 @@ func NameFromFilepath(filepath string) string {
9795
f = strings.TrimSuffix(f, ext)
9896

9997
// Append "_score" to the end
100-
return strings.Map(modified, f) + "_score"
98+
return strings.Map(modifier, f) + "_score"
10199
}

0 commit comments

Comments
 (0)