What does confusion points: matches stand by? - bixby

I am trying to train utterances and whenever I am giving value to enum type concept it tells me confusion point matches. What does it meany by confusion point matches?

You’ll need a vocab file to back the symbols.
Such as this one. Note that the path is important - make sure it's in your locale.
vocab(Planet) {
"Mercury" { "Mercury" }
"Venus" { "Venus" }
"Earth" { "Earth" "The Old Earth" }
"Mars" { "Mars" "The Red Planet" }
"Jupiter" { "Jupiter" }
"Saturn" { "Saturn" }
"Uranus" { "Uranus" }
"Neptune" { "Neptune" }
"Pluto" { "Pluto" }
}
here’s the associated enum for that vocab:
enum (Planet) {
description (The resort's affiliated planetary system (include the planet and its moons). Since the list and vocab is exhaustive, we can use an enum.)
symbol (Mercury)
symbol (Venus)
symbol (Earth)
symbol (Mars)
symbol (Jupiter)
symbol (Saturn)
symbol (Uranus)
symbol (Neptune)
symbol (Pluto)
}

I would check if you have a vocab file for the enum types. If there is no vocab file, the enums will not be recognized by natural language.

Related

How do I define vocabulary "tuples" in Bixby?

I have an enum defining names of altbrains (publications) like so:
enum (AltBrainsNames) {
description (AltBrainsNames)
symbol (Inside the Helmet)
symbol (Impeachment Sage)
symbol (Iran Conflict Tracker)
symbol (Historical Carbon Dioxide Emissions)
symbol (Picard)
symbol (Quotation Bank)
symbol (US Elections)
}
With a corresponding vocab.bxb file to match variations on the names to these "official" names.
What I really want is the Bixby to pass along a string identifier that corresponds to each symbol -- like (Impeachment Sage, impeachmentsage) so that the identifier can be used as a parameter in a request to a restdb. What's a simple way of setting up these tuple relationships?
Fred
The symbol for your enum concept can be the string identifier in your restDb. Here's one pattern:
Modify your existing enum to follow this format
enum (AltBrainsNames) {
description (AltBrainsNames Identifiers)
symbol (insideTheHelmut)
symbol (impeachmentSage)
symbol (iranConflictTracker)
symbol (historicalCarbonDioxideEmissions)
symbol (picard)
symbol (quotationBank)
symbol (USElections)
}
Your tuple to connect the user-friendly name to the identifier.
structure (NameSelection) {
property (name) {
type (AltBrainsNames)
min (Required) max (One)
}
property (title) {
type (core.Text)
min (Required) max (One)
visibility (Private)
}
}
Get a list of names
action (GetAltBrainsNames) {
type(Constructor)
output (NameSelection)
}
Provide a list of names, and prompt the user to select one
action (MakeNameSelection) {
type(Calculation)
collect {
input (selection) {
type (NameSelection)
min (Required) max (One)
default-init {
intent {
goal: GetAltBrainsNames
}
}
}
}
output (AltBrainsNames)
}
Your vocabulary can support the user saying synonyms for symbol
vocab (AltBrainsNames) {
"insideTheHelmut" { "insideTheHelmut" "inside the helmut" "helmut"}
"impeachmentSage" { "impeachmentSage" "impeachment sage" "impeachment" "sage"}
"iranConflictTracker" {"iranConflictTracker" "iran conflict tracker"}
"historicalCarbonDioxideEmissions" { "historicalCarbonDioxideEmissions" "historical carbon dioxide emissions"}
"picard" { "picard"}
"quotationBank" {"quotationBank" "quotation bank" "quotations"}
"USElections" {"USElections" "us elections" }
}

Issue in giving plurals in Bixby dialogs

I had a question regarding plurals in dialog.
Let's say I have a structure
structure (MyStructure) {
property (MyConcept) {
type {EnumConcept} max (Many)
}
}
And a Value dialog for it:
dialog (Value) {
match: MyConcept(this)
if (this == 'ABC') {
switch(plural(this)) {
case (One) { template("single1") }
default { template ("plural1") }
}
}
if (this == 'DEF') {
switch(plural(this)) {
case (One) { template("single2") }
default { template ("plural2") }
}
}
}
By using
Code:
#{value(myStructure.myConcept.plural('Many'))}
I am able to get "plural1" or "plural2" when myStructure has below values and size of myConcept is 1:
myStructure = [
{ myConcept: ABC },
{ myConcept: ABC },
{ myConcept: ABC },
{ myConcept: ABC }
]
When size of myConcept is 2 and myStructure has below values,
myStructure = [
{ myConcept: ABC },
{ myConcept: ABC },
{ myConcept: DEF },
{ myConcept: DEF }
]
using the Code:
#{value(myStructure.myConcept.plural('Many'))}
is giving NLG as
"single1 and single2"
What I want in the NLG:
"plural1 and plural2"
Can someone please help us in giving proper plural NLG for each element of the unique "myConcept" present in the list of "myStructure"?
What I want is to apply plurality to each individual value of an array.
size(myStructure.myConcept) = 2.
I want to apply plural to both the values of myConcept.
I do not think in dialogs we have an for-each kind of thing available.
It's a little hard to tell what's going on in the code above. If this answer isn't helpful, consider sharing the full source code somewhere for live debugging.
You can try something like
#{value(myStructure.myConcept.plural(plural(myStructure.myConcept))}
The docs has an example like:
#{concept(restaurantStyle.plural(plural(restaurant)))}
Source: https://bixbydevelopers.com/dev/docs/reference/ref-topics/el-ref#node-evaluation-functions in the plural(node) section.

How do I pass Javascript Object to Bixby's Action Output?

I am building an app that search for anime quotes. So, I have the following data, which is 331 Objects (which I call them 'Quote Cards') long and so it will also be updated in future as I add more and more quotes. The problem I having is in creating concepts for JS's array items such as keywords, and imageTag. and also the the character names which are listed as property. I am also willing to change the output as long as I can keep category, and keywords array items. Those are necessary for my quote cards
[
{
$id: "Cold_Souls_1",
animeTitle: "Fullmetal Alchemist Brotherhood",
animePoster:{
referenceImage: 'https://qph.fs.quoracdn.net/main-qimg-da58c837c7197acf364cb2ada34fc5fb.webp',
imageTags: ["Grey","Yellow","Blue","Metal Body","Machine", "Robot","Yellow Hair Boy"],
},
animeCharacters:{
"Edward Elric": [
{
quote: "A lesson without pain is meaningless. For you cannot gain something without sacrificing something else in return. But once you have recovered it and made it your own... You will gain an irreplaceable Fullmetal heart.",
keywords: ["lesson", "pain", "return", "meaningless", "gain","sacrificing", "recover"],
category: "Life Lesson"
}
]
}
},....................
]
In Bixby, you would model a structure that represents the JSON response.
structure (Anime) {
description (The output of your action)
property (title) {
type(viv.core.Text)
visibility (Private)
}
property (poster){
type(AnimePoster)
visibility (Private)
}
property (characters) {
type (AnimeCharacter)
max (Many)
visibility (Private)
}
}
structure (AnimePoster) {
property (referenceImage) {
type (viv.core.Text)
visibility (Private)
}
property (imageTags) {
type (viv.core.Text)
max (Many)
visibility (Private)
}
}
structure (AnimeCharacter) {
property (name) {
type (viv.core.Text)
visibility (Private)
}
property (quote) {
type (viv.core.Text)
visibility (Private)
}
property (keywords) {
type (viv.core.Text)
max (Many)
visibility (Private)
}
property (category) {
type (viv.core.Text)
visibility (Private)
}
}
In your javascript file, you process the JSON structure of animes
// listOfAnimes is the JSON object described in the question
var animes = [];
listOfAnimes.forEach((anime) => {
var characterNames = Object.keys(anime.animeCharacters);
var characters = [];
Object.keys(anime.animeCharacters).forEach((key) => {
characters.push({
name: key,
quote: anime.animeCharacters[key][0].quote, // * warning, can be many
category: anime.animeCharacters[key][0].category// * warning, can be many
});
});
animes.push( {
$id: anime.$id,
title: anime.title,
characters: characters,
poster: {
referenceImage: anime.animePoster.referenceImage,
imageTags: anime.animePoster.imageTags
},
});
});

How can I pass collected values to a replanned action?

When the user says "read john 3:100", I have a ReadBibleVerse action that matches book:john, chapter:3, verse:100. The endpoint will return a 404, since there is no verse 100.
I want that action to capture the error and replan to a "read chapter" request, passing along book:john and chapter:3.
What I have...
action (ReadBibleVerse) {
collect {
input (book) {…}
input (chapter) { type (ChapterNum) … }
input (verse) {…}
}
output (Scripture) {
throws {
unknown-error {
on-catch {
replan {
dialog ("Unknown verse, trying the chapter.")
intent {
goal: Scripture
route: ReadBibleChapter
}}}}}}}
…what I get is "Unknown verse, trying the chapter. I need a book to continue."
I'm clearly hitting the error and, I believe, being "replanned" to ReadBibleChapter, but I'm also getting "I need a book to continue." because I need to explicitly pass along book and chapter?
I found intent.value, which appears to solve my problem, except I can't seem to find the correct format:
value: ChapterNum
value: ChapterNum (chapter)
value: [namespace].ChapterNum { $expr(chapter) }
more various nonsense
…
This should work value {$expr(chapter)}

Is it possible to combine two patterns, one with a match guard, in the same match arm?

I want to check if a string contains '$' and if there is something after the '$':
I tried this code:
fn test(s: String) {
match s.find('$') {
None | (Some(pos) if pos == s.len() - 1) => {
expr1();
}
_ => { expr2(); }
}
}
But it doesn't compile:
error: expected one of `)` or `,`, found `if`
Is it impossible to combine None and Some in one match-arm?
If so, is there a simple way to not duplicate expr1() except moving it into a separate function?
It is impossible to have the match-guard (the if thingy) apply to only one pattern alternative (the things separated by | symbols). There is only one match-guard per arm and it applies to all patterns of that arm.
However, there are many solutions for your specific problem. For example:
if s.find('$').map(|i| i != s.len() - 1).unwrap_or(false) {
expr2();
} else {
expr1();
}

Resources