Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Match ¶
func Match(p1, p2 PoliticalMap) (float64, error)
Match returns the % match between two PoliticalMaps Only match subquadrants will be compared. If one or both maps has 0 points at a subquadrant, it will be ignored.
Types ¶
type ErrOutOfRange ¶
func (*ErrOutOfRange) Error ¶
func (e *ErrOutOfRange) Error() string
type PoliticalMap ¶
type PoliticalMap [16]int
PoliticalMap is a 4x4 map of poltical opinions. Everytime a question is answered, a point is added to a sub quadrant.
--------------------- | 0 | 1 | 2 | 3 | --------------------- | 4 | 5 | 6 | 7 | --------------------- | 8 | 9 | 10 | 11 | --------------------- | 12 | 13 | 14 | 15 | ---------------------
func Merge ¶
func Merge(maps ...PoliticalMap) (p PoliticalMap, err error)
Merge merges two or more maps by averaging their values at each subquadrant
func (*PoliticalMap) Add ¶
func (p *PoliticalMap) Add(aMap []int, mask []int, agree bool) error
Add records an answer and places it in the map. NOTE: In case you forget, as you have 100 times, yes, the mask is necessary! If, for instance, you disagree with something mapped to MMiddleLeft, without the mask, both the Far Left AND the whole Right Wing will get points added! With the mask, only the Far Left will get highlighted.
func (*PoliticalMap) Center ¶
func (p *PoliticalMap) Center() (int, int)
Center finds the center of gravity of the map for faster lookups in SQL Based on actual center of gravity math for two dimenions. There are some people that will come up with a weird coordinate, but it should be the minority. Most people should have fairly large clusters in one spot, so it'll make the initial SQL look up easier to match them. TODO: Actually test this with real people and real questions
func (*PoliticalMap) IsEmpty ¶
func (p *PoliticalMap) IsEmpty() bool
IsEmpty will check for empty poltical maps. These cause big problems when trying to match
func (*PoliticalMap) Scan ¶
func (p *PoliticalMap) Scan(src interface{}) error
Scan satisfies sql.Scanner interface