I am trying to write a capsule that will ask the user for a geo.SearchRegion and give them the opportunity to search again after they have results.
The issue is that I need to train the language model on geo.LocalityName (to get a city name). I have created my own alias of that:
name (LocalityName) {
description (alias of geo.LocalityName)
extends (geo.LocalityName)
features {
transient
}
}
which works fine. The problem is that when I do the same with geo.SearchRegion I lose the built in ability to match a LocalityName to a SearchRegion.
structure (SearchRegion) {
description (alias of geo.SearchRegion)
extends (geo.SearchRegion)
features {
transient
}
}
So when I have the following Evaluate action:
action (Evaluate) {
description (Find the value)
type (Search)
collect {
input (type) {
type (StatsType)
min (Required) max (One)
default-init {
intent {
goal: GetAllTypes
}
}
}
input-group (location) {
requires (OneOf)
collect {
input (searchRegion) {
type (geo.SearchRegion)
min (Optional) max (One)
default-select {
with-learning
with-rule {
select-first
}
}
}
input (postalCode) {
type (PostalCode)
min (Optional) max (One)
default-select {
with-learning
with-rule {
select-first
}
}
}
}
}
}
output (Result)
}
It works, but will not allow me to re-do the search. When I change geo.SearchRegion to SearchRegion it no longer works, since it can't match the locality name.
What should I do to enable the user to search again?
I would recommend changing that input to a computed-input (Documentation) in the action and define its prompt behavior as prompt-behavior(AlwaysElicitation). This will result in Bixby requesting the user for a location every time.
Related
I have an enum EEndpoints that maps to string addresses of local nodes. I want to create an interface/hard-coded object based off of this enum. This is my idea:
export enum EEndpoints
{
MY_REMOTE_NODE = "MY_REMOTE_NODE",
}
export interface EndpointAddresses
{
PublisherAddress: string,
RequestAddress: string,
}
export interface EndpointAddressList
{
for (key in EEndpoints)
{
[key] = EndpointAddresses;
}
}
In my code I would then be required to define a constant that implements EndpointAddressList:
const RemoteNodeEndpoints: EndpointAddressList =
{
MY_REMOTE_NODE: {
PublisherAddress: "tcp://127.0.0.1:3000",
RequestAddress: "tcp://127.0.0.1:3001",
},
}
Alternatively, it would also be nice to define an interface that itself implements EndpointAddressList, i.e:
interface ImplementedEndpointAddressList
{
MY_REMOTE_NODE: {
PublisherAddress: "tcp://127.0.0.1:3000",
RequestAddress: "tcp://127.0.0.1:3001",
},
}
I'm also open to feedback if using an enum as the basis for properties in an interface is an anti-pattern. However, it does seem like a useful tool for me to centrally define a set of hard-coded endpoints and then have compile time checks that I have configured the sub-properties of those endpoints.
I've a SwiftUI navigation view showing a list of players. I designed the view model protocols as follows.
protocol PlayerListStateProviding: ObservableObject {
var players: [PlayerModel] { get set }
}
protocol PlayerListDeleting {
var moc: NSManagedObjectContext { get set }
func delete(at indexSet: IndexSet)
}
extension PlayerListDeleting where Self: PlayerListStateProviding {
func delete(at indexSet: IndexSet) {
moc.delete(players.remove(at: indexSet.first!))
objectWillChange.send() // this doesn't compile with the following error "Value of type 'Self.ObjectWillChangePublisher' has no member 'send'"
}
}
I'm not sure what this error is and how to avoid it. However when I remove the extension and create concrete class, I could send the signal with no problem.
To use default observable object publisher in protocol you should limit it to corresponding type (because it is in extension to ObservableObject), as in
extension PlayerListDeleting where Self: PlayerListStateProviding,
Self.ObjectWillChangePublisher == ObservableObjectPublisher {
func delete(at indexSet: IndexSet) {
moc.delete(players.remove(at: indexSet.first!))
objectWillChange.send()
}
}
Hi I want to make a "Query" and put a filter for returning all pages that has "Show on a menu" checked. I did not find a way to do that.. Is it possible?
Try something like this:
using Orchard.Localization;
using Orchard.Projections.Descriptors.Filter;
using Orchard.Navigation;
using IFilterProvider = Orchard.Projections.Services.IFilterProvider;
namespace MyProject.Filters
{
public class MenuPartFilter : IFilterProvider {
public Localizer T { get; set; }
public ProductPartFilter() {
T = NullLocalizer.Instance;
}
public void Describe(DescribeFilterContext describe)
{
describe.For(
"Content", // The category of this filter
T("Content"), // The name of the filter (not used in 1.4)
T("Content")) // The description of the filter (not used in 1.4)
// Defines the actual filter (we could define multiple filters using the fluent syntax)
.Element(
"MenuParts", // Type of the element
T("Menu Parts"), // Name of the element
T("Menu parts"), // Description of the element
ApplyFilter, // Delegate to a method that performs the actual filtering for this element
DisplayFilter // Delegate to a method that returns a descriptive string for this element
);
}
private void ApplyFilter(FilterContext context) {
// Set the Query property of the context parameter to any IHqlQuery. In our case, we use a default query
// and narrow it down by joining with the MenuPartRecord.
context.Query = context.Query.Join(x => x.ContentPartRecord(typeof (MenuPartRecord)));
}
private LocalizedString DisplayFilter(FilterContext context) {
return T("Content with MenuPart");
}
}
}
I have a Page class as
class SignUpPage extends Page {
static url = "signup"
static at = { waitFor { title.startsWith("Join") } }
static content = {
firstNameField { $("input", name:"firstName") }
lastNameField { $("input", name:"lastName") }
emailField { $("input", name:"email") }
passwordField { $("input", name:"password") }
}
}
I want to add a populateFields method to this class. This will allow me to call this method to populate the text fields from my test cases. This method has one argument passed in - a Map that allows me to override certain field values as necessary from my test cases.
The problem is that I don't know how I can iterate over the 'content' of the page. To make this clearer look at the code below:
class SignUpPage extends Page {
static url = "signup"
// .. as defined above ..
def populateFields(customValues = [:]) {
// I want to iterate of the textFields here
// Something like...
textFields = this.metaclass.methods.findAll {
it.name.endsWith("Field")
}
textFields.each {
// populate with data
}
}
}
This doesn't work.
How do I get the content of the closure 'content'?
I think that there is a much easier way of implementing it and you don't need to iterate over contents of your page object. Given the keys in your map are name attributes of the inputs you want to modify, you can do the following:
def populateFields(customValues = [:]) {
def form = $('form') //can be any element that is enclosing all of your inputs
customValues.each { key, value ->
form[key] = value
}
}
Have a look at the section on form control shortcuts in the manual to understand how it works.
If content becomes too complicated to use the available tools you could always create a list of the page contents in your content.
static content = {
username { module $(... }
contactTitle { $(... }
contactGivenName { $(... }
contactFamilyName { moduleList $(... }
pageFields {
[
username,
contactTitle,
contactGivenName,
contactFamilyName,
]
}
}
def populateFields(valueList) {
pageFields.each {
it.value(somevaluefromList)
}
}
Suppose I have a handle class like:
interface IHasHandle<TObject> {
IHandle<TObject> Handle { get; }
}
interface IHandle<out TObject> {
TObject Value { get; }
}
I would like to the use this class to give me the most derived output type in a hierarchy. What I have now looks like:
interface IAnimal : IHasHandle<IAnimal> { ... }
interface IMammal : IAnimal, IHasHandle<IMammal> { ... }
interface IFeline : IMammal, IHasHandle<IFeline> { ... }
class Tiger : IFeline {
IHandle<IAnimal> IHasHandle<IAnimal>.Handle { get { ... } }
IHandle<IMammal> IHasHandle<IMammal>.Handle { get { ... } }
IHandle<IFeline> IHasHandle<IFeline>.Handle { get { ... } }
public IHandle<Tiger> Handle { get { ... } }
}
This means that when I have an IAnimal, I can always get IHandle, when I have IMammal, I can get IHandle, etc.
Does anyone have any general comments on this structure or ideas for how to avoid having every possible implementation?
Even before .NET 4.0 it was possible to do things like:
interface IAnimal<TSpecies> : IHasHandle<TSpecies> where TSpecies : IAnimal<TSpecies> { ... }
interface IMammal<TSpecies> : IAnimal<TSpecies> where TSpecies : IMammal<TSpecies> { ... }
interface IFeline<TSpecies> : IMammal<TSpecies> where TSpecies : IFeline<TSpecies> { ... }
class Tiger : IFeline<Tiger> {
IHandle<Tiger> IHasHandle<Tiger>.Handle { get { ... } }
}
Of course, this won't prevent you from making some class EvilCat : IFeline<Tiger>, but it provides quite a good way for getting rid of an extra unneeded Handle implementations in Tiger. And if you'll declare IHasHandle generic parameter as out one in this sample of code, you'll be able to cast Tiger (which implements IHasHandle<Tiger>) to IHasHandle<IMammal> for example.