Documentation
¶
Index ¶
- Variables
- func Close()
- func CountMatches(quiz string, options []string, trainingStr string, testingStr string, ...)
- func FetchHashQuestion(questionHash string) (answerHash string)
- func FetchQuestion(question string) (str string)
- func GetFromAPI(quiz string, options []string) (res map[string]int)
- func Hamming(a, b string) int
- func Run(port string, autoclick int, hashquiz int)
- func RunWeb(port string)
- func SetQuestion(question *Question)
- func ShowAllQuestions()
- func StoreHashQuestion(question *Question) error
- func StoreQuestion(question *Question) error
- func StoreWholeQuestion(question *Question) error
- type AnwserImage
- type ChooseResp
- type EncodedQuestion
- type Image
- type MatchInfo
- type Question
- type QuestionCols
- type QuizContext
- type WholeQuestionCols
- type Words
Constants ¶
This section is empty.
Variables ¶
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 )
var ( QuestionBucket = "Question" WholeQuestionBucket = "WholeQuestion" HashQuestionBucket = "HashQuestion" )
var ( Autoclick int Hashquiz int )
Functions ¶
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 ¶
FetchHashQuestion get question answer hash of a given quiz hash
func FetchQuestion ¶
FetchQuestion get question answer of a given quiz
func GetFromAPI ¶
GetFromAPI searh the quiz via popular search engins, evaluate each option giving a score indicating the highest possible answer
func Hamming ¶
Hamming distance is simply the minimum number of substitutions required to change one string into the other.
func SetQuestion ¶
func SetQuestion(question *Question)
func ShowAllQuestions ¶
func ShowAllQuestions()
func StoreHashQuestion ¶
StoreHashQuestion store the hash question and hash correct answer to db
func StoreQuestion ¶
func StoreWholeQuestion ¶
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 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 ¶
FetchRandomQuestion get a random whole question
func GetQuestion ¶
type QuestionCols ¶
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 ¶
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 (*WholeQuestionCols) GetData ¶
func (q *WholeQuestionCols) GetData() []byte