Actions SDK: Two instances of org.schema.type.Text in same queryPattern fail - actions-on-google

I can't create a queryPattern containing two Text fields, like so:
"parameters": [
{
"name": "text_a",
"type": "org.schema.type.Text"
},
{
"name": "text_b",
"type": "org.schema.type.Text"
}
],
"trigger": {
"queryPatterns": [
"add $org.schema.type.Text:text_b with $org.schema.type.Text:text_a",
"combine $org.schema.type.Text:text_b along with $org.schema.type.Text:text_a"
]
}
This will always result in a failure to match the intent (for example "add something with another").
However, I can use two Color types: If you change "Text" to "Color" in the above, and say "add red with blue" or "combine auburn along with green" then it matches and fires the intent.
I am creating deep-link intents only (i.e., commands, not a back-and-forth dialog), so I don't think DialogFlow will help me?

I suspect that the problem is that AoG is treating text parameters as "greedy", so a second parameter never matches because the first parameter has captured all the text. You don't see this with specific types, because it does more narrow matching for them.
You may actually try to use Dialogflow - it does work for deep linking Intents, although I don't know if it will behave the same way.

Related

Syntax highlighting for context sensitive keywords

I'm trying to create a syntax highlighter for vscode. I've been making progress. However, there is a sequence that I just can't seem to get working.
I'm trying to highlight some identifiers, only within a certain section of code. In the following example, it's the keywords public, private, and abstract. They should only be highlighted after following the introducer keywords 'fn' or 'class', and also being enclosed within brackets.
fn [public] MyFunction() {}
class [private, abstract] MyClass {}
I'm trying variations of the following:
"decorations": {
"name": "decorations.lang",
"match": "(fn|class)\\s*\\[\\s*([a-zA-Z0-9_, ]+)\\s*\\]",
"captures": {
"2": {
"name": "decorations.captures.lang",
"patterns": [
{
"name": "entity.name.function.decorator.lang",
"match": "\\b(public|private|abstract)\\b"
}
]
}
}
}
I checked that the "match" regex would match the above code. I used the following site:
https://rubular.com
The idea is to first match the stuff within the brackets, after seen one of the introducer keywords, and then do a submatch for the specific context keywords. When I check the tokens created, by using the vscode command Developer: Inspect Editor Tokens and Scopes, no match gets made for the stuff in brackets.
What is the correct setup to match those context sensitive keywords?
I rubber ducked myself. Right after I posted the question, the answer occurred to me.
The issue is that the highlighter definition has 2 sections, the "patterns" and the "repository".
{
"patterns": [...],
"repository": {...}
}
The patterns section, being an array, matches the entries in order. If another entry matches first, then rest are not tried. In my case, there was an entry matching the 'fn' and 'class' as keywords. After I moved the ref #decorations higher , within the 'patterns' section, it solved the issue.
However, that then creates an issue that the keywords won't get highlighted, in that case, because the context sensitive keywords are matched first. But, that's another problem.

Where to find Pokedex Entry Description for Pokemon (PokeAPI)

Are there ways I can get a Pokemon's Pokedex entry description? I've tried looking in the API documentation to come with no avail. The closest thing I could find was a Pokedex JSON but even that didn't contain the Pokemon's PD entry description alongside with Pokemon Species. Unless I didn't look hard enough do you know where I can fetch a Pokemon's dex entry description?
Thanks
I guess you missed the flavor-text-entries in apiv2.
This is for pikachu
GET https://pokeapi.co/api/v2/pokemon-species/25
A part of the output
{
"flavor_text": "It has small electric sacs on both its\ncheeks. If threatened, it looses electric\ncharges from the sacs.",
"language": {
"name": "en",
"url": "https://pokeapi.co/api/v2/language/9/"
},
"version": {
"name": "firered",
"url": "https://pokeapi.co/api/v2/version/10/"
}
}
Similarly it's available for other game versions as well.
to add onto #Rinkesh P's answer, you can replace the '\n's with spaces. The '\n' is actually an escape sequence in ASCII. It's mainly used in programming languages such as C, Pearl, and Java. But in most cases, you're probably just gonna load up the description and display it in HTML --So just write up a function to replace it with a space(' ').

Can you list multiple features within the same Schema.org "LocationFeatureSpecification"?

I am working on Schema.org Resort schema for a ton of resorts on a travel website and am trying to find the most efficient ways of filling out the schema with regards to amenities.
The current code looks something like this:
"amenityFeature": [
{
"#type":"http://schema.org/LocationFeatureSpecification",
"name":"Spa",
"value":"true"
},
{
"#type":"http://schema.org/LocationFeatureSpecification",
"name":"Internet Access",
"value":"true"
},
{
"#type":"http://schema.org/LocationFeatureSpecification",
"name":"Tennis Courts",
"value":"true"
}
]
My question is, can I write it like this instead to shorten lines of code:
{
"#type":"http://schema.org/LocationFeatureSpecification",
"name":[
"Spa", "Internet Access", "Tennis Courts"
],
"value":"true"
}
When I test it in Google’s Structured Data Testing Tool, it doesn’t give any errors. Here is what it looks like in the SDTT when I write it the short way:
And here is what it looks like if I do it the first/long way:
If I do it the short way, I want to make sure all those items are getting listed as amenities and not just different names for the same amenity. Otherwise, I'll go the long route.
No, each LocationFeatureSpecification represents one feature:
Specifies a location feature by providing a structured value representing a feature of an accommodation as a property-value pair of varying degrees of formality.
Your second snippet would represent one feature with multiple names.

IBM Chatbot Assistant: Handling Multiple Entities

I have an entity called #spare_part and this entity has 4 values with the following example synonyms each:
both with synonyms filter, oil level indicator
not_defined with a synonym spare part
only_gear with synonyms valve, seal
whole_gear_box with a synonym complete set of gearbox
I want to be able to handle multiple entities given in the same input and address them later on, if needed. With this purpose I have coded the following in JSON editor:
{
"context": {
"sparepartrequest": "#spare_part.values"
},
"output": {
"generic": [
{
"values": [
{
"text": "You want an offer for the following parts: <?
$sparepartrequest.join(', ') ?>."
}
],
"response_type": "text",
"selection_policy": "sequential"
}
]
}
}
I have created a context variable called sparepartrequest as can be seen from the code lines above. For instance when the user says "I want an offer for a filter and a seal", the output of the bot is the following sentence:
You want an offer for the following parts: both, only_gear.
I don´t want the bot to prompt back the names of the values of the entity #spare_part, I rather want it to store the exact input of the user, for our case which would be filter and seal. So if the bot worked as I wanted it to, the output would look like the following:
You want an offer for the following parts: filter, valve.
Again, I believe that this can be handled with JSON Editor. Thank you !
Use two context variables. sparepartrequest as already done and sparepartrequest_literals as follows:
"sparepartrequest_literals":"<? entities['spare_part'].![literal].join(', ') ?>".
Then, in your text response call it by $sparepartrequest_literals to print the mentioned parts or use $sparepartrequest to refer to the detected values.

Parameterizing Resource Names in CloudFormation Template?

This answer here: Is there a way to parameterize cloud formation resource names? didn't really help as I am looking to set the physical name, not the logical one. I was hoping for something along the lines of setting a parameter in the parameters list like:
"ELBName": {
"Type": "String",
"Default": "xxx",
"Description": "The Production Number for this stack (e.g. xxx)"
}
and then
"LoadBalancerName": "prod" + {Ref: "ELBName"}
although that concatenation directly is not possible. Is there any way to do what I want? My end goal is to take a template I've created and use it to create many copies of itself, each with the same resources, but different names, possibly through a nested stack.
Use Fn::Join function to do this:
"LoadBalancerName":{
"Fn::Join":[
"",
[
"prod",
{
"Ref":"ELBName"
}
]
]
}
This will give the name as prod01 assuming ELBName parameter has been passed the value 01