Documentation
¶
Overview ¶
Package natural contains a multitude of natural language parsers.
Index ¶
- Constants
- Variables
- func FormatMessage(msg *sarif.Message)
- func FormatSimple(msg sarif.Message) string
- func ParseSimple(text string) (sarif.Message, bool)
- func ParseValue(v string) interface{}
- func SplitQuoted(s string, sep string) ([]string, bool)
- func SplitWords(s string) []string
- func TrimQuotes(s string) string
- type Context
- type Intent
- type ParseResult
- type Phrasebook
- type RegularParser
- type SentenceRule
- type SentenceRuleSet
Constants ¶
View Source
const (
ThisAlgorithmBecomingSkynetCost = 999999999
)
Variables ¶
View Source
var DefaultPhraseResponses = map[string]string{
"compliment": "thanks",
"thanks": "acknowledgement",
"greeting/initial": "greeting/reply",
"greeting/reply": "greeting/reply",
"wake": "greeting/reply",
"farewell": "farewell",
"success": "compliment",
"affirmative": "compliment",
}
View Source
var DefaultRules = SentenceRuleSet{
"ping": "ping",
"associate [sentence] with [action]": "natural/learn",
"parse [text]": "natural/parse",
"record that [text]": "event/new",
"#[_action]": "tagged",
"#[_action] [text]": "tagged",
"remind me in [duration] to [text]": "schedule",
}
Functions ¶
func FormatMessage ¶
func FormatSimple ¶
func ParseValue ¶
func ParseValue(v string) interface{}
func SplitWords ¶
func TrimQuotes ¶
Types ¶
type Intent ¶
type ParseResult ¶
type ParseResult struct { Text string `json:"text"` Intents []*Intent `json:"intents"` ExtraInfo interface{} `json:"extra_info"` }
func (*ParseResult) Merge ¶
func (r *ParseResult) Merge(other *ParseResult, weight float64)
func (ParseResult) String ¶
func (r ParseResult) String() string
type Phrasebook ¶
func NewPhrasebook ¶
func NewPhrasebook() *Phrasebook
func (*Phrasebook) Answer ¶
func (b *Phrasebook) Answer(phrase string) string
func (*Phrasebook) Get ¶
func (b *Phrasebook) Get(context string) string
func (*Phrasebook) GetReverse ¶
func (b *Phrasebook) GetReverse(phrase string) string
type RegularParser ¶
type RegularParser struct {
// contains filtered or unexported fields
}
func NewRegularParser ¶
func NewRegularParser() *RegularParser
func (*RegularParser) Learn ¶
func (p *RegularParser) Learn(rule, action string) error
func (*RegularParser) Load ¶
func (p *RegularParser) Load(s SentenceRuleSet) error
func (*RegularParser) Rules ¶
func (p *RegularParser) Rules() SentenceRuleSet
type SentenceRule ¶
func CompileSentenceRule ¶
func CompileSentenceRule(s, action string) (r *SentenceRule, err error)
type SentenceRuleSet ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.