matcher

package
v0.0.0-...-6dfde0d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2017 License: GPL-3.0 Imports: 6 Imported by: 0

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.

func ToHuman

func ToHuman(match float64) float64

Types

type ErrOutOfRange

type ErrOutOfRange struct {
	Index int
	Val   int
}

func (*ErrOutOfRange) Error

func (e *ErrOutOfRange) Error() string

type ErrScan

type ErrScan struct {
	Val interface{}
}

func (ErrScan) Error

func (e ErrScan) 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

func (PoliticalMap) Value

func (p PoliticalMap) Value() (driver.Value, error)

Value satisfies driver.Valuer interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL