另一种选择是在训练中使用 viv.geo.SearchTerm,在您的操作中使用 viv.geo.NamedPoint。这会让用户说出诸如“1 Market Street, California”之类的不完整内容,Bixby 将使用 HERE 地图搜索在旧金山找到此内容。
要使用,设置一个 NamedPoint 概念(在导入 viv.geo 之后)
structure (InputAddress) {
role-of (geo.NamedPoint)
}
然后在您的操作中,您可以执行以下操作:
input (namedPoint) {
type (InputAddress)
min (Required) max (One)
default-select {
with-learning
with-rule {
select-first
}
}
}
在本例中,使用 learning 和 select-first 将自动选择第一个地址。如果没有这个,Bixby 将自动建议地址。
namedPoint 然后将被传递到您的端点,您可以根据需要进行解析。
在训练中,使用 geo.SearchTerm - 例如:
[g:GetAddressAction] My address is {[g:InputAddress] (665 Clyde Ave Mountain View California)[v:geo.SearchTerm]}
或者对于提示,您可以使用:
[g:GetAddressAction:continue:InputAddress] {[g:InputAddress] (60 S Market)[v:geo.SearchTerm]}
您可以通过使用 viv.geo.ResolveAddressByPlaceID 目标让 Bixby 处理地址来获得格式更完整的地址。这是使用 NamedPoint 和 ResolveAddressByPlaceID 的完整操作。注意 cmets 中相关文档的链接
action (GetAddressAction) {
type(Search)
description (Get Address)
collect {
// See https://bixbydevelopers.com/dev/docs/dev-guide/developers/library.geo#using-searchterm - used in training
// and https://bixbydevelopers.com/dev/docs/dev-guide/developers/library.geo#namedpoint - used below and for computed-input
input (namedPoint) {
type (InputAddress)
min (Required) max (One)
default-select {
with-learning
with-rule {
select-first
}
}
// hidden - Hide if all you need is address
}
computed-input (address){
type (geo.Address)
min (Optional) max (One)
compute {
intent {
goal: viv.geo.ResolveAddressByPlaceID
value: $expr(namedPoint.placeID)
}
}
}
}
output (geo.Address)
}