File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -112,9 +112,27 @@ var importCmd = &cobra.Command{
112
112
csvDate , _ := time .Parse (csvDateFormat , record [dateColumn ])
113
113
if allowMatching || ! existingTransaction (generalLedger , csvDate , inputPayeeWords [0 ]) {
114
114
// Classify into expense account
115
- _ , likely , _ := classifier .LogScores (inputPayeeWords )
115
+ scores , likely , _ := classifier .LogScores (inputPayeeWords )
116
116
if likely >= 0 {
117
- expenseAccount .Name = string (classifier .Classes [likely ])
117
+ matchScore := 0.0
118
+ matchIdx := - 1
119
+ for j , score := range scores {
120
+ if j == 0 {
121
+ matchScore = score
122
+ }
123
+ if string (classifier .Classes [j ]) == csvAccount .Name {
124
+ continue
125
+ }
126
+ if score > matchScore {
127
+ matchScore = score
128
+ matchIdx = j
129
+ }
130
+ }
131
+ if matchIdx >= 0 {
132
+ expenseAccount .Name = string (classifier .Classes [matchIdx ])
133
+ } else {
134
+ expenseAccount .Name = string (classifier .Classes [likely ])
135
+ }
118
136
}
119
137
120
138
// Parse error, set to zero
You can’t perform that action at this time.
0 commit comments