-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revert: feat: Switching to new exas model
This reverts commit 6f817e8.
- Loading branch information
Showing
15 changed files
with
133 additions
and
34 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package metadata | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/ViBiOh/exas/pkg/model" | ||
) | ||
|
||
type locationAggregate map[string]map[string]int64 | ||
|
||
func newAggregate() locationAggregate { | ||
return make(map[string]map[string]int64) | ||
} | ||
|
||
func (a locationAggregate) ingest(geocoding model.Geocode) { | ||
for _, level := range levels { | ||
a.inc(level, geocoding.Address[level]) | ||
} | ||
} | ||
|
||
func (a locationAggregate) inc(key, value string) { | ||
if len(value) == 0 { | ||
return | ||
} | ||
|
||
if level, ok := a[key]; ok { | ||
level[value]++ | ||
} else { | ||
a[key] = map[string]int64{ | ||
value: 1, | ||
} | ||
} | ||
} | ||
|
||
func (a locationAggregate) value() string { | ||
if len(a) == 0 { | ||
return "" | ||
} | ||
|
||
for _, level := range levels { | ||
if val := a.valueOf(level); len(val) > 0 { | ||
return val | ||
} | ||
} | ||
|
||
return "Worldwide" | ||
} | ||
|
||
func (a locationAggregate) valueOf(key string) string { | ||
values, ok := a[key] | ||
if !ok { | ||
return "" | ||
} | ||
|
||
var sum int64 | ||
for _, v := range values { | ||
sum += v | ||
} | ||
|
||
var names []string | ||
minSum := int64(float64(sum) * aggregateRatio) | ||
|
||
for k, v := range values { | ||
if v > minSum { | ||
names = append(names, k) | ||
} | ||
} | ||
|
||
return strings.Join(names, ", ") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters