Documentation ¶
Index ¶
- Constants
- type BoundingBox
- type Char
- type ComposeFunc
- type Configuration
- type ExportConfiguration
- type GuidesConfiguration
- type Item
- type JiixConfiguration
- type JiixText
- type LanguageCode
- type Linebreak
- type MarginConfiguration
- type Metadata
- type MyScript
- type Node
- func (n *Node) Ahead(count int) *Node
- func (n *Node) Behind(count int) *Node
- func (n *Node) InsertAfter(o *Node)
- func (n *Node) InsertBefore(o *Node)
- func (n *Node) IsHead() bool
- func (n *Node) IsTail() bool
- func (n *Node) Next() *Node
- func (n *Node) Prev() *Node
- func (n *Node) Remove()
- func (n *Node) Token() *Token
- func (n *Node) Update(t *Token)
- type PipelineFunc
- type Point
- type PointerType
- type RawContentConfiguration
- type RawRecognitionConfiguration
- type RawTextConfiguration
- type Recognizer
- type Request
- type Result
- type Stroke
- type StrokeGroup
- type TextConfiguration
- type Token
- type Word
Constants ¶
const ( LangEN LanguageCode = "en_US" LangDE LanguageCode = "de_DE" Pen PointerType = "PEN" Touch PointerType = "TOUCH" Eraser PointerType = "ERASER" )
const Version = "0.1.1"
Version is the semantic version
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoundingBox ¶
type BoundingBox struct { X float64 `json:"x"` Y float64 `json:"y"` Width float64 `json:"width"` Height float64 `json:"height"` }
Coordinates are in **millimeters**
func (BoundingBox) IsZero ¶
func (b BoundingBox) IsZero() bool
type Char ¶
type Char struct { Label string `json:"label"` Word int `json:"word"` Grid []Point `json:"grid"` BoundingBox BoundingBox `json:"bounding-box,omitempty"` Items []Item `json:"items,omitempty"` }
type ComposeFunc ¶
ComposeFunc is a function that generates an output document from the given set of tokens. THe result is written to the given writer.
func NewMarkdownComposer ¶
func NewMarkdownComposer() ComposeFunc
NewMarkdownComposer creates a new composer which generates output in markdown format.
func NewPlaintextComposer ¶
func NewPlaintextComposer() ComposeFunc
NewPlaintextComposer creates a new composer which creates plain text output for a regicnition result.
type Configuration ¶
type Configuration struct { Language LanguageCode `json:"lang"` Text *TextConfiguration `json:"text,omitempty"` Export *ExportConfiguration `json:"export,omitempty"` RawContent *RawContentConfiguration `json:"raw-content,omitempty"` }
Configuration is the root object for configuration options to a batch call.
func NewConfiguration ¶
func NewConfiguration(lang LanguageCode, guides, bbox, chars, words bool) Configuration
NewConfiguration creates a new configuration object with the given values.
type ExportConfiguration ¶
type ExportConfiguration struct { Jiix JiixConfiguration `json:"jiix"` ImageResolution int64 `json:"image-resolution"` }
ExportConfiguration holds settings for the API response.
func NewExportConfiguration ¶
func NewExportConfiguration(bbox, chars, words bool) *ExportConfiguration
NewExportConfiguration creates an export config.
type GuidesConfiguration ¶
type GuidesConfiguration struct {
Enable bool `json:"enable"`
}
type Item ¶
type Item struct { ID string `json:"id"` Type string `json:"type"` Timestamp string `json:"timestamp"` // 2021-01-09 13:23:42.196250 Label string `json:"label"` Baseline float64 `json:"baseline"` XHeight float64 `json:"x-height"` LeftSideBearing float64 `json:"left-side-bearing"` BoundingBox BoundingBox `json:"bounding-box"` }
type JiixConfiguration ¶
type JiixConfiguration struct { Strokes bool `json:"strokes"` BoundingBox bool `json:"bounding-box"` Style bool `json:"style"` Text JiixText `json:"text"` }
JiixConfiguration holds options for the JIIX format.
JIIX is the "deep dive" format from the MyScript API.
func NewJiixConfiguration ¶
func NewJiixConfiguration(bbox, chars, words bool) JiixConfiguration
NewJiixConfiguration creates a JIIX configuration with the given flags.
If bbox is set, each recognition result is additionally described by a bounding box which refers to the input drawing.
If words is set, the result will contain additional entries for each word, if chars is also set, the character index for each word is included.
type LanguageCode ¶
type LanguageCode string
type MarginConfiguration ¶
type MyScript ¶
type MyScript struct {
// contains filtered or unexported fields
}
MyScript is the client for the MyScript ReST API.
func NewMyScript ¶
NewMyScript sets up a new client.
It requires the application key and the HMAC key from ypur MyScript account.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is an element in a doubly linked list of Tokens.
func Dehyphenate ¶
Dehyphenate merges words that are separated by a hyphen.
func (*Node) InsertAfter ¶
InsertAfter adds the given not after this one
func (*Node) InsertBefore ¶
InsertBefore inserts the given Node before this one
type PipelineFunc ¶
PipelineFunc is a function that can be chained to process a set of tokens.
The output is the modified set of tokens. A PipelineFunc may change, remove or insert tokens.
func BuildPipeline ¶
func BuildPipeline(p ...PipelineFunc) PipelineFunc
BuildPipeline combines several pipeline functions into one.
type PointerType ¶
type PointerType string
type RawContentConfiguration ¶
type RawContentConfiguration struct { Recognition RawRecognitionConfiguration `json:"recognition"` Text RawTextConfiguration `json:"text"` }
func NewRawContentConfiguration ¶
func NewRawContentConfiguration() *RawContentConfiguration
type RawTextConfiguration ¶
type Recognizer ¶
type Recognizer struct {
// contains filtered or unexported fields
}
The Recognizer organizes calls to the MyScript API to convert notbooks from handwriting to a recognize Result.
The recognizer also manages caching to avoid repeated calls to the API if a page has not changed.
func NewRecognizer ¶
func NewRecognizer(appKey, hmacKey, cacheDir string) *Recognizer
NewRecognizer creates a recognizer withthe given credentials for the MyScript API.
If cacheDir is non-empty, it will be used to cache responses from the API. If it is empty, caching is disabled.
func (*Recognizer) Recognize ¶
func (r *Recognizer) Recognize(doc *rmtool.Document, l LanguageCode) (map[string]*Node, error)
Recognize performs handwriting recognition on all pages of the given document. It resturns a map of page-IDs and recognition results.
type Request ¶
type Request struct { Width int64 `json:"width"` Height int64 `json:"height"` // ContentType controls the "recognition type" of the MyScript API. // It must be one of Text, Diagram, Math, Raw Content, Text Document ContentType string `json:"contentType"` // Must be DIGITAL_EDIT when the ReST API is used. ConversionState string `json:"conversionState"` XDpi int64 `json:"xDPI"` YDpi int64 `json:"yDPI"` Theme string `json:"theme"` StrokeGroups []StrokeGroup `json:"strokeGroups"` Configuration Configuration `json:"configuration"` }
Request is the root element for requests against the batch enpoint.
type Result ¶
type Result struct { ID string `json:"id"` Version string `json:"version"` Type string `json:"type"` Label string `json:"label"` BoundingBox BoundingBox `json:"bounding-box"` Words []Word `json:"words"` Chars []Char `json:"chars"` Linebreaks []Linebreak `json:"linebreaks"` }
Result is the response returned by the MyScript batch enpoint.
The Label field contains the complete recognized text. If the "words" option was enabled, the liust of Words contains the individual words and whitespace.
type Stroke ¶
type Stroke struct { ID string `json:"id,omitempty"` // opt PointerType PointerType `json:"pointerType,omitempty"` // opt PointerID int `json:"pointerId,omitempty"` // opt X []int `json:"x"` Y []int `json:"y"` Timestamp []int64 `json:"t"` Pressure []float64 `json:"p"` // opt }
A Stroke is a single stroke of digital ink.
It consists of a series of X,Y coordinates and their related timestamps and optional pressure values.
The Timestamp can be based on "0" as long as it increases from point to point.
type StrokeGroup ¶
A StrokeGroup contains the digital ink strokes, i.e. the actual handwriting.
func ConvertLayer ¶
func ConvertLayer(tOffset int64, l lines.Layer) (StrokeGroup, int64)
ConvertLayer convert a Layer from a reMarkable drawing to a MyScript stroke group.
func NewStrokeGroup ¶
func NewStrokeGroup() StrokeGroup
NewStrokeGroup creates and empty stroke group.
type TextConfiguration ¶
type TextConfiguration struct { Guides GuidesConfiguration `json:"guides"` Margin MarginConfiguration `json:"margin"` Configuration RawTextConfiguration `json:"configuration"` }
TextConfiguration holds settings holds settings for text recognition.
func NewTextConfiguration ¶
func NewTextConfiguration(guides bool) *TextConfiguration
NewTextConfiguration creates a default configuration.
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token represents a single text element that was reconized from the handwriting input. The fully reconized text consists of a list of tokens.
RULES for tokenization:
- consecutive whitespace is split into multiple tokens - punctuation is a single token
func (*Token) IsDash ¶
IsDash tells if this token is a dash ("-"), including several unicode variants.
func (*Token) IsPunctuation ¶
IsPunctuation tells if this token belongs to the punctuation group.
func (*Token) IsWhitespace ¶
IsWhitespace tells whether this token is a single whiotespace character. For a typical recognition result, this will be either a single space or newline.
func (*Token) IsWord ¶
IsWord tells if this token is a "word".
This is determined by looking at the recongnized characters. This may still be a poorly recognized word.
func (*Token) StartsUpper ¶
StartsUpper tells if this token starts with an uppercase letter
type Word ¶
type Word struct { Label string `json:"label"` ReflowLabel string `json:"reflow-label"` FirstChar int `json:"first-char,omitempty"` LastChar int `json:"last-char,omitempty"` BoundingBox BoundingBox `json:"bounding-box,omitempty"` Candidates []string `json:"candidates,omitempty"` Items []Item `json:"items,omitempty"` }
Word is a single recognized "word", including whitespace or punctuation.
The recognized content is held in the `Label`; concatenating all labesl gives the full text. See: https://developer.myscript.com/docs/interactive-ink/1.4/reference/web/jiix/#word-object