Skip to content

Commit

Permalink
Use exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvio Böhler committed Jan 9, 2022
1 parent 0a5448e commit 3e472ae
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions lib/journal/ast/bayes/bayes.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ type Model struct {
accounts int
accountCounts map[*journal.Account]int
tokenCounts map[string]map[*journal.Account]int

exclude *journal.Account
}

// NewModel creates a new model.
func NewModel() *Model {
func NewModel(exclude *journal.Account) *Model {
return &Model{
accounts: 0,
accountCounts: make(map[*journal.Account]int),
Expand All @@ -43,23 +45,27 @@ func (m *Model) Update(t *ast.Transaction) {
for _, p := range t.Postings {
m.accounts++
m.accountCounts[p.Credit]++
for _, token := range tokenize(t, &p, p.Credit) {
tc, ok := m.tokenCounts[token]
if !ok {
tc = make(map[*journal.Account]int)
m.tokenCounts[token] = tc
if p.Credit != m.exclude {
for _, token := range tokenize(t, &p, p.Credit) {
tc, ok := m.tokenCounts[token]
if !ok {
tc = make(map[*journal.Account]int)
m.tokenCounts[token] = tc
}
tc[p.Credit]++
}
tc[p.Credit]++
}
m.accounts++
m.accountCounts[p.Debit]++
for _, token := range tokenize(t, &p, p.Debit) {
tc, ok := m.tokenCounts[token]
if !ok {
tc = make(map[*journal.Account]int)
m.tokenCounts[token] = tc
if p.Debit != m.exclude {
m.accounts++
m.accountCounts[p.Debit]++
for _, token := range tokenize(t, &p, p.Debit) {
tc, ok := m.tokenCounts[token]
if !ok {
tc = make(map[*journal.Account]int)
m.tokenCounts[token] = tc
}
tc[p.Debit]++
}
tc[p.Debit]++
}

}
Expand Down

0 comments on commit 3e472ae

Please sign in to comment.