I used builtin.number in my LUIS app trying to collect a 4 digit pin number. The following is what's returned from LUIS when my input is "one two three four".
"entities": [
{
"entity": "one",
"type": "builtin.number",
"startIndex": 0,
"endIndex": 2,
"resolution": {
"value": "1"
}
},
{
"entity": "two",
"type": "builtin.number",
"startIndex": 4,
"endIndex": 6,
"resolution": {
"value": "2"
}
},
{
"entity": "three",
"type": "builtin.number",
"startIndex": 8,
"endIndex": 12,
"resolution": {
"value": "3"
}
},
{
"entity": "four",
"type": "builtin.number",
"startIndex": 14,
"endIndex": 17,
"resolution": {
"value": "4"
}
},
As you can see, it's returning individual digits in both text and digit format. Seems to me that it's more important to return the whole digit than the individual ones. Is there a way to do it so that I get '1234' as result for builtin.number?
Thanks!
It's not possible to do what you're asking for by only using LUIS. The way LUIS does its tokenization is that it recognizes each word/number individually due to the whitespace. It goes without saying that 'onetwothreefour' will also not return 1234.
Additionally, users are unable to modify the recognition of the prebuilt entities on an individual model level. The recognizers for certain languages are open-source, and contributions from the community are welcome.
All of that said, a way you could achieve what you're asking for is by concatenating the numbers. A JavaScript example might be something like the following:
var pin = '';
entities.forEach(entity => {
if (entity.type == 'builtin.number') {
pin += entity.resolution.value;
}
}
console.log(pin); // '1234'
After that you would need to perform your own handling/regexp, but I'll leave that to you. (after all, what if someone provides "seven eight nine ten"? Or "twenty seventeen"?)
Related
I am working with an API that returns the following JSON:
{
"rows": [
{
"keys": [
"search term 1",
"https://example.com/article-about-keyword-1/"
],
"clicks": 24,
"impressions": 54,
"ctr": 0.4444444444444444,
"position": 2.037037037037037
},
{
"keys": [
"search term 2",
"https://example.com/article-about-keyword-2/"
],
"clicks": 17,
"impressions": 107,
"ctr": 0.1588785046728972,
"position": 2.663551401869159
}
],
"responseAggregationType": "byPage"
}
And I'm trying to use JSONata to change it to something more like this:
{
"rows": [
{
"keyword": search term 1,
"URL": https://example.com/article-about-keyword-1/,
"clicks": 24,
"impressions": 54,
"ctr": 0.4444444444444444,
"position": 2.037037037037037
},
{
"keyword": search term 2,
"URL": https://example.com/article-about-keyword-2/,
"clicks": 17,
"impressions": 107,
"ctr": 0.1588785046728972,
"position": 2.663551401869159
}
],
"responseAggregationType": "byPage"
}
Basically, I'm trying the break the 'keys' part out into 'Keyword' and 'URL'.
Have been playing around for a while in https://try.jsonata.org/ but I'm not getting very far. Any help appreciated.
Splitting the keys array should be achievable by accessing each element there by its index (given that the keyword and the URL are guaranteed to appear on the same index).
Here’s the full JSONata expression to translate from your source file to the desired target shape:
{
"rows": rows.{
"keyword": keys[0],
"URL": keys[1],
"clicks": clicks,
"impressions": impressions,
"ctr": ctr,
"position": position
}[],
"responseAggregationType": responseAggregationType
}
By the way, I’ve built this solution in 2 minutes by using the Mappings tool that my team is building at Stedi.
I am setting up a LUIS service for dutch.
I have this sentence:
Hi, ik ben igor -> meaning Hi, I'm igor
Where Hi is an simple entity called Hey, that can have multiple different values such as (hey, hello, ..) which I specified as a list in the phrases.
And Igor is a simple entity called Name
In the dashboard I can see that Igor has been correctly mapped as a Name entity, but the retrieved result is the following:
{
"query": "Hi, ik ben igor",
"topScoringIntent": {
"intent": "Greeting",
"score": 0.462906122
},
"intents": [
{
"intent": "Greeting",
"score": 0.462906122
},
{
"intent": "None",
"score": 0.41605103
}
],
"entities": [
{
"entity": "hi",
"type": "Hey",
"startIndex": 0,
"endIndex": 1,
"score": 0.9947428
}
]
}
Is it possible to solve this? I do not want to make a phrase list of all the names that exist.
Managed to train LUIS to even recognize asdaasdasd:
{
"query": "Heey, ik ben asdaasdasd",
"topScoringIntent": {
"intent": "Greeting",
"score": 0.5320666
},
"intents": [
{
"intent": "Greeting",
"score": 0.5320666
},
{
"intent": "None",
"score": 0.236944184
}
],
"entities": [
{
"entity": "asdaasdasd",
"type": "Name",
"startIndex": 13,
"endIndex": 22,
"score": 0.8811139
}
]
}
To be honest I do not have a great guide on how to do this:
Add multiple example utterances with example entity position
Did this for about 5 utterances
No phrase list necessary
I'm going to accept this as an answer, but once someone explains in-depth and technically what is happening behind the covers, I will accept that answer.
I want to plot a graph between place and time. Y-axis will show 5 countries (USA, UK, Canada, France, Germany) and X-axis will show the time. The data is in pairs of (date, place). I am trying to display it by replacing the numeric values of Y-Y-axis with strings but no luck. Any simple working example will be helpful.
The value axis' labelFunction would be perfect for this task. With it, you can define a custom function that would be called for each label, which in turn could replace the number with a string. I.e.:
"valueAxes": [{
// other value axis settings
// ...
"labelFunction": function(value) {
var labels = {
"1": "USA",
"2": "UK",
"3": "Canada",
"4": "France",
"5": "Germany"
};
return labels[value] || "";
}
}]
Another option that you have is to disable value axis labels altogether ("labelsEnabled": false) and using guides to place country labels at specific values. I.e.:
"valueAxes": [{
"labelsEnabled": false,
"guides": [{
"value": 1,
"label": "USA"
}, {
"value": 2,
"label": "UK"
}, {
"value": 3,
"label": "Canada"
}, {
"value": 4,
"label": "France"
}, {
"value": 5,
"label": "Germany"
}]
}]
Whichever works for your purposes better, or seems easier.
I've looked through the documentation, but perhaps I've overlooked what I assume to be a straightforward task. Is it possible to provide a custom binding function so that, in an array of objects, each object corresponds to one cell, rather than each object corresponding to a full row? Would this binding maintain the reference to the original object so that the data would change after being modified in the spreadsheet?
For example, I'd want to create the following sheet:
With JSON in this structure:
[
{
"name": "USA",
"year": 2015,
"sales": 1,
},
{
"name": "USA",
"year": 2016,
"sales": 2,
},
{
"name": "USA",
"year": 2017,
"sales": 3,
},
{
"name": "Canada",
"year": 2015,
"sales": 4,
},
{
"name": "Canada",
"year": 2016,
"sales": 5,
},
{
"name": "Canada",
"year": 2017,
"sales": 6,
}
]
You should look at the columns definition. In there you can define the data source for each column such that it will iterate through your objects and set the values of each column given the id for that column. And yes, it uses references so if you edit them, your objects get edited as well.
I'm using Kendo UI DropDownList but cannot find a way to group values in it. is this feature available?
saw the following post from early 2013 which says that this was on the roadmap, but not sure if it was implemented or not.
http://www.telerik.com/forums/option-group-for-datasource-in-dropdownlist
As of the Q1 2015 release, this is supported on the datasource. It doesn't look like you can do this when binding to local data though.
UserVoice Item
Demo
Grouping actually is supported now, in conjunction with the datasource. Here is a code snippet that will create a dropdown list using Kendo UI 2015.3.1111 and jQuery 1.9.1, grouping by team colors. The datasource, candidates, is a local array of data items. The dropdown list will replace an HTML element on the page, <input id="victim"/>.
var candidates = [
{ "id": 1, "name": "Alice", "team": "Red" },
{ "id": 2, "name": "Bob", "team": "Red" },
{ "id": 3, "name": "Charlie", "team": "Blue" },
{ "id": 4, "name": "Dorothy", "team": "Blue" },
{ "id": 5, "name": "Ed", "team": "Green" },
{ "id": 6, "name": "Frances", "team": "Green" },
{ "id": 7, "name": "George", "team": "Purple" },
{ "id": 8, "name": "Helen", "team": "Purple" },
];
$("#victim").kendoDropDownList({
"dataTextField": "name",
"dataValueField": "id",
"dataSource": { "data": candidates, "group": "team" },
"index": 0
});
This is what the dropdown looks like with stock styling in FireFox:
I hadn't noticed before, but the widget also orders the groups.
Grouping is not supported by the Kendo DropDownList widget.