solver

package module
v0.0.0-...-5f8a548 Latest Latest
Warning

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

Go to latest
Published: May 13, 2019 License: MIT Imports: 34 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Go-Quizzer is an app to automatically solve quiz for you

Technologies that I played around in this side project:

  1. MITM server: goproxy

  2. In-memory NoSQL database: boltDB

  3. Image to text conversion

    a. OCR: tesseract, Google Vision API

    b. Image hashing: dHash, aHash

  4. Machine Learing for matching the closest option to quiz body, given google/wiki searching results as reference.

    a. Sliding window sketch methodology

    b. SVM and kernal tricks

    • Gaussian kernal
    • Exponential kernel

    c. Weight matrix

    d. Covariance matrix

    All of these were implemented in Golang from scratch, which gave me significantly higher quizzing accuracy than the naive frequency-counting approach used by most relevant projects.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	//JB jieba chinese words segregation
	JB *gojieba.Jieba
	//CorpusWord the chiese vocabulary
	CorpusWord map[string]zhCNvocabulary
	//N_opt number of question options
	N_opt = 4
)
View Source
var (
	QuestionBucket      = "Question"
	WholeQuestionBucket = "WholeQuestion"
	HashQuestionBucket  = "HashQuestion"
)
View Source
var (
	Autoclick int
	Hashquiz  int
)

Functions

func Close

func Close()

func CountMatches

func CountMatches(quiz string, options []string, trainingStr string, testingStr string, res map[string]int)

CountMatches sliding window, count the common chars between [neighbor of the option in search text] and [quiz]

func FetchHashQuestion

func FetchHashQuestion(questionHash string) (answerHash string)

FetchHashQuestion get question answer hash of a given quiz hash

func FetchQuestion

func FetchQuestion(question string) (str string)

FetchQuestion get question answer of a given quiz

func GetFromAPI

func GetFromAPI(quiz string, options []string) (res map[string]int)

GetFromAPI searh the quiz via popular search engins, evaluate each option giving a score indicating the highest possible answer

func Hamming

func Hamming(a, b string) int

Hamming distance is simply the minimum number of substitutions required to change one string into the other.

func Run

func Run(port string, autoclick int, hashquiz int)

func RunWeb

func RunWeb(port string)

RunWeb run a webserver

func SetQuestion

func SetQuestion(question *Question)

func ShowAllQuestions

func ShowAllQuestions()

func StoreHashQuestion

func StoreHashQuestion(question *Question) error

StoreHashQuestion store the hash question and hash correct answer to db

func StoreQuestion

func StoreQuestion(question *Question) error

func StoreWholeQuestion

func StoreWholeQuestion(question *Question) error

StoreWholeQuestion store the whole question to db

Types

type AnwserImage

type AnwserImage struct {
	Total int `json:"total"`
	// End       bool   `json:"end"`
	// Sid       string `json:"sid"`
	// Ran       int    `json:"ran"`
	// Ras       int    `json:"ras"`
	// Kn        int    `json:"kn"`
	// Cn        int    `json:"cn"`
	// Gn        int    `json:"gn"`
	// Lastindex int    `json:"lastindex"`
	// Ceg       string `json:"ceg"`
	List []Image `json:"list"`
}

AnwserImage result from image.so.com

type ChooseResp

type ChooseResp struct {
	Data struct {
		UID         int  `json:"uid"`
		Num         int  `json:"num"`
		Answer      int  `json:"answer"`
		Option      int  `json:"option"`
		Yes         bool `json:"yes"`
		Score       int  `json:"score"`
		TotalScore  int  `json:"totalScore"`
		RowNum      int  `json:"rowNum"`
		RowMult     int  `json:"rowMult"`
		CostTime    int  `json:"costTime"`
		RoomID      int  `json:"roomId"`
		EnemyScore  int  `json:"enemyScore"`
		EnemyAnswer int  `json:"enemyAnswer"`
	} `json:"data"`
	Errcode int `json:"errcode"`
}

type EncodedQuestion

type EncodedQuestion struct {
	Data struct {
		EncryptedData string `json:"encryptedData"`
	} `json:"data"`
	Errcode int `json:"errcode"`
}

type Image

type Image struct {
	// ID            string `json:"id"`
	// QqfaceDownURL bool   `json:"qqface_down_url"`
	// Downurl       bool   `json:"downurl"`
	// Grpmd5        bool   `json:"grpmd5"`
	// Type          int    `json:"type"`
	// Src           string `json:"src"`
	// Color         int    `json:"color"`
	// Index         int    `json:"index"`
	// Title         string `json:"title"`
	// Litetitle     string `json:"litetitle"`
	Width   string `json:"width"`
	Height  string `json:"height"`
	Imgsize string `json:"imgsize"`
	// Imgtype       string `json:"imgtype"`
	// Key           string `json:"key"`
	// Dspurl        string `json:"dspurl"`
	// Link          string `json:"link"`
	// Source        int    `json:"source"`
	Img       string `json:"img"`
	ThumbBak  string `json:"thumb_bak"`
	Thumb     string `json:"thumb"`
	ThumbBak_ string `json:"_thumb_bak"`
	Thumb_    string `json:"_thumb"`
	// Imgkey        string `json:"imgkey"`
	ThumbWidth int `json:"thumbWidth"`
	// Dsptime       string `json:"dsptime"`
	ThumbHeight int `json:"thumbHeight"`
}

Image instance from image.so.com result

type MatchInfo

type MatchInfo struct {
	Success bool `json:"success"`
	Matches []struct {
		MatchID            string `json:"matchId"`
		MatchIDNumber      int    `json:"matchIdNumber"`
		MatchURL           string `json:"matchURL"`
		CreateDate         string `json:"createDate"`
		UpdateDate         string `json:"updateDate"`
		MatchStatus        int    `json:"matchStatus"`
		CurrentPlayerIndex int    `json:"currentPlayerIndex"`
		Letters            string `json:"letters"`
		RowCount           int    `json:"rowCount"`
		ColumnCount        int    `json:"columnCount"`
		TurnCount          int    `json:"turnCount"`
		MatchData          string `json:"matchData"`
		ServerData         struct {
			Language  int   `json:"language"`
			UsedTiles []int `json:"usedTiles"`
			Tiles     []struct {
				T string `json:"t"`
				O int    `json:"o"`
			} `json:"tiles"`
			UsedWords  []string `json:"usedWords"`
			MinVersion int      `json:"minVersion"`
		} `json:"serverData"`
		Participants []struct {
			UserID                string      `json:"userId"`
			UserName              string      `json:"userName"`
			PlayerIndex           int         `json:"playerIndex"`
			PlayerStatus          string      `json:"playerStatus"`
			LastTurnStatus        string      `json:"lastTurnStatus"`
			MatchOutcome          string      `json:"matchOutcome"`
			TurnDate              string      `json:"turnDate"`
			TimeoutDate           interface{} `json:"timeoutDate"`
			AvatarURL             string      `json:"avatarURL"`
			IsFavorite            bool        `json:"isFavorite"`
			UseBadWords           bool        `json:"useBadWords"`
			BlockChat             bool        `json:"blockChat"`
			DeletedFromPlayerList bool        `json:"deletedFromPlayerList"`
			Online                bool        `json:"online"`
			ChatsUnread           int         `json:"chatsUnread"`
			MuteChat              bool        `json:"muteChat"`
			AbandonedMatch        bool        `json:"abandonedMatch"`
			IsBot                 bool        `json:"isBot"`
			BannedChat            bool        `json:"bannedChat"`
		} `json:"participants"`
	} `json:"matches"`
}

MatchInfo ...

type Question

type Question struct {
	Data struct {
		Quiz        string   `json:"quiz"`
		Options     []string `json:"options"`
		Num         int      `json:"num"`
		School      string   `json:"school"`
		Type        string   `json:"type"`
		Contributor string   `json:"contributor"`
		EndTime     int      `json:"endTime"`
		CurTime     int      `json:"curTime"`
		ImageID     string   `json:"imageId"`
	} `json:"data"`
	CalData struct {
		RoomID string

		Answer     string
		AnswerPos  int
		TrueAnswer string
		Odds       []float32
		ImageTime  int64
		User       string
		Choice     int
		Voice      int
		// contains filtered or unexported fields
	} `json:"caldata"`
	HashData struct {
		Quiz       string   `json:"quiz"`
		Options    []string `json:"options"`
		TrueAnswer string
	} `json:"hashdata"`
	Errcode int `json:"errcode"`
}

func FetchRandomQuestion

func FetchRandomQuestion(topic string) (question *Question)

FetchRandomQuestion get a random whole question

func GetQuestion

func GetQuestion(roomID, quizNum string) *Question

type QuestionCols

type QuestionCols struct {
	Answer string `json:"a"`
	Update int64  `json:"ts"`
}

func DecodeQuestionCols

func DecodeQuestionCols(bs []byte, update int64) *QuestionCols

func NewQuestionCols

func NewQuestionCols(answer string) *QuestionCols

func (*QuestionCols) GetData

func (q *QuestionCols) GetData() []byte

type QuizContext

type QuizContext struct {
	Words []string `json:"words"`
	Quiz  string   `json:"quiz"`
}

QuizContext ...

type WholeQuestionCols

type WholeQuestionCols struct {
	Number  int      `json:"n"`
	School  string   `json:"sch"`
	Type    string   `json:"typ"`
	Options []string `json:"opt"`
	Answer  string   `json:"a"`
	EndTime int      `json:"te"`
	CurTime int      `json:"tc"`
	Update  int64    `json:"ts"`
}

func NewWholeQuestionCols

func NewWholeQuestionCols(num int, school string, typ string, options []string,
	answer string) *WholeQuestionCols

func (*WholeQuestionCols) GetData

func (q *WholeQuestionCols) GetData() []byte

type Words

type Words []struct {
	Word string `json:"word"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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