api

package
v0.0.0-...-9884358 Latest Latest
Warning

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

Go to latest
Published: May 24, 2017 License: LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnalyzeHandler

func AnalyzeHandler(rw http.ResponseWriter, r *http.Request)

AnalyzeHandler takes a text and returns statistics on the composition: number of characters, words, rank and more.

func JSONResponse

func JSONResponse(rw http.ResponseWriter, b []byte)

JSONResponse sets the Content-Type header to application/json and returns the response.

func RankHandler

func RankHandler(rw http.ResponseWriter, r *http.Request)

RankHandler returns the average rank and other information about a text

func SplitHandler

func SplitHandler(rw http.ResponseWriter, r *http.Request)

SplitHandler returns a tokenized version of the Chinese text supplied to it.

func WordsHandler

func WordsHandler(rw http.ResponseWriter, r *http.Request)

WordsHandler returns a tokenized version of the Chinese text supplied to it (like SplitHandler), along with information on these words, like individual rank

Types

type AnalyzeResponse

type AnalyzeResponse struct {
	Score      float64    `json:"score"`
	HSK        float64    `json:"hsk"`
	Percentile percentile `json:"percentile"`
}

type Operations

type Operations struct {
	RedisPool *redis.Pool
}
var Ops *Operations

func NewOperations

func NewOperations(server string, password string) (o *Operations)

func (*Operations) GetRank

func (o *Operations) GetRank(s string) (rank int)

GetRank returns the rank of a key from the Redis key/value store.

func (*Operations) GetRanks

func (o *Operations) GetRanks(words []string) (ranks []int)

GetRank returns the ranks of words from the Redis key/value store.

type RankResponse

type RankResponse struct {
	Rank  rank  `json:"rank"`
	Words words `json:"words"`
}

type SplitResponse

type SplitResponse struct {
	Text []string `json:"text"`
}

type Word

type Word struct {
	Value string
	Rank  int
}

type WordsResponse

type WordsResponse struct {
	Word string `json:"word"`
	Rank int    `json:"rank"`
}

Jump to

Keyboard shortcuts

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