grammarbot

package module
v0.0.0-...-8e66cee Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: MIT Imports: 6 Imported by: 0

README

grammarbot

A Go API client for GrammrBot API

Installation

go get github.com/LaevusDexter/grammarbot

Usage

Check the grammarbot_test.go

Documentation

Index

Constants

View Source
const MaxLength = 50000

Variables

View Source
var ErrEmpty = errors.New("Text is empty.")
View Source
var ErrExceedLimits = errors.New("Text longer than 50,000 characters is not allowed.")

Functions

func CorrectMatches

func CorrectMatches(text string, matches []*Match) string

CorrectMatches - returns corrected text with first replacements in matches

func CorrectMatchesBytes

func CorrectMatchesBytes(text []byte, matches []*Match) []byte

CorrectMatchesBytes - returns corrected text with first replacements in matches

func Validate

func Validate(text string) bool

func ValidateErr

func ValidateErr(text string) error

Types

type BotInfo

type BotInfo struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	APIVersion  int    `json:"apiVersion"`
	Premium     bool   `json:"premium"`
	PremiumHint string `json:"premiumHint"`
	Status      string `json:"status"`
}

type BotWarnings

type BotWarnings struct {
	IncompleteResults bool `json:"incompleteResults"`
}

type DetectedLanguage

type DetectedLanguage struct {
	Name string `json:"name"`
	Code string `json:"code"`
}

type GrammarBot

type GrammarBot struct {
	Language string
	ApiKey   string
	BaseURI  string
	Version  string
	ApiName  string

	Client *http.Client
}

func New

func New(apiKey string) *GrammarBot

func (GrammarBot) Check

func (api GrammarBot) Check(text string) (*Response, error)

Check - Check a given piece of text for grammatical errors.

func (GrammarBot) CheckBytes

func (api GrammarBot) CheckBytes(text []byte) (*Response, error)

CheckBytes - Check a given piece of text for grammatical errors.

type Match

type Match struct {
	Message      string             `json:"message"`
	ShortMessage string             `json:"shortMessage"`
	Replacements []MatchReplacement `json:"replacements"`
	Offset       int                `json:"offset"`
	Length       int                `json:"length"`
	Context      MatchContext       `json:"context"`
	Sentence     string             `json:"sentence"`
	Type         MatchType          `json:"type"`
	Rule         *MatchRule         `json:"rule"`
}

type MatchContext

type MatchContext struct {
	Text   string `json:"text"`
	Offset int    `json:"offset"`
	Length int    `json:"length"`
}

type MatchReplacement

type MatchReplacement struct {
	Value string `json:"value"`
}

type MatchRule

type MatchRule struct {
	ID          string       `json:"id"`
	Description string       `json:"description"`
	IssueType   string       `json:"issueType"`
	Category    RuleCategory `json:"category"`
}

type MatchType

type MatchType struct {
	TypeName string `json:"typeName"`
}

type RequestLanguage

type RequestLanguage struct {
	Name     string           `json:"name"`
	Code     string           `json:"code"`
	Detected DetectedLanguage `json:"detectedLanguage"`
}

type Response

type Response struct {
	Software BotInfo         `json:"software"`
	Warnings BotWarnings     `json:"warnings"`
	Language RequestLanguage `json:"language"`
	Matches  []*Match        `json:"matches"`
}

func Check

func Check(text string) (*Response, error)

Check - Check a given piece of text for grammatical errors.

func CheckBytes

func CheckBytes(text []byte) (*Response, error)

CheckBytes - Check a given piece of text for grammatical errors.

type RuleCategory

type RuleCategory struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Jump to

Keyboard shortcuts

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