本文整理匯總了Golang中github.com/paulfchristiano/dwimmer/dynamics.Dwimmer.Answer方法的典型用法代碼示例。如果您正苦於以下問題:Golang Dwimmer.Answer方法的具體用法?Golang Dwimmer.Answer怎麽用?Golang Dwimmer.Answer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/paulfchristiano/dwimmer/dynamics.Dwimmer
的用法示例。
在下文中一共展示了Dwimmer.Answer方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ElicitAction
func ElicitAction(d dynamics.Dwimmer, context *term.SettingT, setting *term.Setting) dynamics.Transition {
for {
Q := FallThrough.T(represent.Setting(setting))
result := dynamics.SubRun(d, Q, context)
switch result.Head() {
case TakeTransition:
transition, err := represent.ToTransition(d, result.Values()[0])
if err == nil {
return transition
}
case core.OK:
default:
result, err := d.Answer(TransitionGiven.T(result, Q))
if err == nil {
transition, err := represent.ToTransition(d, result)
if err == nil {
return transition
}
}
}
}
}
示例2: GetHints
//TODO only do this sometimes, or control better the length, or something...
func GetHints(d dynamics.Dwimmer, context *term.SettingT, s *term.SettingS, n int) []string {
suggestions, err := d.Answer(similarity.SuggestedActions.T(
represent.Setting(s.Setting),
represent.Int(n),
), context)
if err != nil {
return []string{}
}
suggestionList, err := represent.ToList(d, suggestions)
if err != nil {
return []string{}
}
result := []string{}
for _, suggestion := range suggestionList {
actionC, err := represent.ToActionC(d, suggestion)
if err != nil {
continue
}
actionS := actionC.Uninstantiate(s.Names)
result = append(result, actionS.String())
}
reverseHints(result)
return result
}