Documentation ¶
Index ¶
- Constants
- Variables
- func Call(fn string, args ...interface{}) (interface{}, error)
- func NLP() *ling.Pipeline
- type Arg
- type FMR
- type Grammar
- func (g *Grammar) EarleyParse(text string, starts ...string) (*Parse, error)
- func (g *Grammar) EarleyParseAll(text string, starts ...string) ([]*Parse, error)
- func (g *Grammar) EarleyParseAny(text string, starts ...string) (*Parse, error)
- func (g *Grammar) EarleyParseMaxAll(text string, starts ...string) ([]*Parse, error)
- func (g *Grammar) ExtractAll(text string, starts ...string) ([]*Node, error)
- func (g *Grammar) ExtractMaxAll(text string, starts ...string) ([]*Node, error)
- func (g *Grammar) FrameFMR(text string) ([]string, error)
- func (g *Grammar) MatchFrames(text string) (map[RbKey]*SlotFilling, error)
- func (g *Grammar) Parse(text string, starts ...string) ([]*Node, error)
- func (g *Grammar) ParseAny(text string, starts ...string) ([]*Node, error)
- type Index
- type Node
- type Parse
- type Pos
- type RbKey
- type Rule
- type RuleBody
- type Slot
- type SlotFilling
- type TableColumn
- type TableState
- type Term
- type TermType
Constants ¶
const DOT = "\u2022" // "\u00B7"
DOT indicates the current position inside a TableState
const GammaRule = "\u0263" // "\u0194"
GammaRule is the name of the special "gamma" rule added by the algorithm (this is unicode for 'LATIN SMALL LETTER GAMMA')
Variables ¶
var Debug = false
Debug flag
Functions ¶
Types ¶
type Arg ¶
type Arg struct { Type string `json:"type"` Value interface{} `json:"value"` }
Arg is the type of argument for functions
type Grammar ¶
type Grammar struct { Name string `json:"name"` Rules map[string]*Rule `json:"rules"` Frames map[string]*Rule `json:"frames"` Regexps map[string]string `json:"regexps"` Refined bool `json:"refined"` // contains filtered or unexported fields }
A Grammar stores a Context-Free Grammar
func GrammarFromFile ¶
GrammarFromFile constructs the Context-Free Grammar from file
func GrammarFromString ¶
GrammarFromString constructs the Contex-Free Grammar from string d with name
func (*Grammar) EarleyParse ¶
EarleyParse parses text for rule <start> at beginning
func (*Grammar) EarleyParseAll ¶
EarleyParseAll extracts all submatches in text for rule <start>
func (*Grammar) EarleyParseAny ¶
EarleyParseAny parses text for rule <start> at any position
func (*Grammar) EarleyParseMaxAll ¶
EarleyParseMaxAll extracts all submatches in text for rule <start>
func (*Grammar) ExtractAll ¶
ExtractAll extracts all parse trees in text for rule <start>
func (*Grammar) ExtractMaxAll ¶
ExtractMaxAll extracts all parse trees in text for rule <start>
func (*Grammar) MatchFrames ¶
func (g *Grammar) MatchFrames(text string) (map[RbKey]*SlotFilling, error)
MatchFrames returns the matched frames for NL text
type Node ¶
type Node struct { Value *TableState `json:"value"` Children []*Node `json:"children,omitempty"` // contains filtered or unexported fields }
Node is the AST of tree structure
func (*Node) OriginalText ¶
OriginalText returns the original text of Node n
type Parse ¶
type Parse struct {
// contains filtered or unexported fields
}
Parse stores a parse chart by grammars
func (*Parse) Boundary ¶
func (p *Parse) Boundary(finalState *TableState) *Pos
Boundary returns the start, end position in NL for finalState
func (*Parse) GetFinalStates ¶
func (p *Parse) GetFinalStates() []*TableState
GetFinalStates returns the final states of p
func (*Parse) GetTrees ¶
func (p *Parse) GetTrees(finalState *TableState) []*Node
GetTrees returns all possible parse results
func (*Parse) Tag ¶
func (p *Parse) Tag(finalState *TableState) string
Tag returns the Nonterminal name of finalState
type SlotFilling ¶
A SlotFilling is a frame consists of Slots
func (*SlotFilling) String ¶
func (s *SlotFilling) String() string
type TableColumn ¶
type TableColumn struct {
// contains filtered or unexported fields
}
TableColumn is the TableState set
func (*TableColumn) String ¶
func (tc *TableColumn) String() (out string)
type TableState ¶
type TableState struct { Term *Term `json:"term"` Rb *RuleBody `json:"rb,omitempty"` Start int `json:"start"` End int `json:"end"` Dot int `json:"dot"` }
TableState uses Earley's dot notation: given a production X → αβ, the notation X → α • β represents a condition in which α has already been parsed and β is expected.
func (*TableState) Equal ¶
func (s *TableState) Equal(ts *TableState) bool
Equal func for TableState
func (*TableState) String ¶
func (ts *TableState) String() string
type Term ¶
type Term struct { Value string `json:"value"` Type TermType `json:"type"` Meta interface{} `json:"meta"` }
A Term is the component of RuleBody
type TermType ¶
type TermType byte
TermType of grammar terms
func (TermType) MarshalJSON ¶
MarshalJSON is generated so TermType satisfies json.Marshaler.
func (*TermType) UnmarshalJSON ¶
UnmarshalJSON is generated so TermType satisfies json.Unmarshaler.
Source Files ¶
- api.go
- api_easy.go
- cfgrammar.go
- cfgrammar_comments.go
- cfgrammar_fmr.go
- cfgrammar_regex.go
- cfgrammar_special.go
- cfgrammar_terminal.go
- earley.go
- earley_ast.go
- earley_eval.go
- earley_fmr.go
- earley_stringer.go
- earley_terminal_match.go
- frame_api.go
- funcs.go
- grammar_index.go
- grammar_refine.go
- grammar_tokens.go
- local_grammar.go
- math_funcs.go
- regexp_tagger.go
- termtype_jsonenums.go
- termtype_string.go
- types.go
- types_util.go