Can't create a Ruta Annotation after upgrade to Ruta 2.8.0 - uima

I have some Ruta script for recognizing peaces of html. See:
DECLARE SkipRegion;
DECLARE EnhancedMarkup(STRING markupName, STRING markupType);
ADDRETAINTYPE(MARKUP);
// replacement of attributes and '/', '<' and '>' symbols is done to get the tag name
MARKUP{-> CREATE(EnhancedMarkup, "markupName" = replaceAll(replaceAll(MARKUP.ct, "\\s[^=]+=[\"'][^\"']+[\"']", ""), "[\\/<>]", ""), "markupType" = "unknown")};
FOREACH(markup) EnhancedMarkup{} {
markup{startsWith(markup.ct, "<") -> SETFEATURE("markupType", "start")};
markup{startsWith(markup.ct, "</") -> SETFEATURE("markupType", "end")};
markup{endsWith(markup.ct, "/>") -> SETFEATURE("markupType", "empty")};
}
// mark the regions not to be looked through
// So whe have a SkipRegion Annotation like '<sub>Zie ook art. 1 van de Werkloosheidswet</sub>'
(start:EnhancedMarkup{start.markupType == "start"} # end:EnhancedMarkup{end.markupType == "end"}) {
start.markupName == end.markupName -> MARK(SkipRegion)
};
SkipRegion{-> UNMARK(MARKUP)};
REMOVERETAINTYPE(MARKUP);
ADDFILTERTYPE(SkipRegion);
When I put the next text into Ruta <sub>Zie ook <nadruk opmaak="cursief">art. 1</nadruk> van de Werkloosheidswet</sub>
I expected that i have the next Annotations:
[
{
"name": "enhancedMarkup",
"type": "Commons.EnhancedMarkup",
"value": "<sub>",
"startPosition": 0,
"endPosition": 5,
"source": "RUTA_ANNOTATION"
},
{
"name": "skipRegion",
"type": "Commons.SkipRegion",
"value": "<nadruk opmaak=\"cursief\">art. 1</nadruk>",
"startPosition": 13,
"endPosition": 53,
"source": "RUTA_ANNOTATION"
},
{
"name": "enhancedMarkup",
"type": "Commons.EnhancedMarkup",
"value": "<nadruk opmaak=\"cursief\">",
"startPosition": 13,
"endPosition": 38,
"source": "RUTA_ANNOTATION"
},
{
"name": "enhancedMarkup",
"type": "Commons.EnhancedMarkup",
"value": "</nadruk>",
"startPosition": 44,
"endPosition": 53,
"source": "RUTA_ANNOTATION"
},
{
"name": "enhancedMarkup",
"type": "Commons.EnhancedMarkup",
"value": "</sub>",
"startPosition": 77,
"endPosition": 83,
"source": "RUTA_ANNOTATION"
},
{
"name": "skipRegion",
"type": "Commons.SkipRegion",
"value": "<sub>Zie ook <nadruk opmaak="cursief">art. 1</nadruk> van de Werkloosheidswet</sub>",
"startPosition": 0,
"endPosition": 83,
"source": "RUTA_ANNOTATION"
}
]
This was working in Ruta v2.7, but it's not working anymore in Ruta v2.8. Then all the Annotation above mentioned are present except the next Annotation is missing:
{
"name": "skipRegion",
"type": "Commons.SkipRegion",
"value": "<sub>Zie ook <nadruk opmaak="cursief">art. 1</nadruk> van de Werkloosheidswet</sub>",
"startPosition": 0,
"endPosition": 83,
"source": "RUTA_ANNOTATION"
}

Related

Remove empty space from Streamlit Echarts

I am rendering a gauge component in the following way, within my Streamlit app:
option = {
"series": [
{
"type": "gauge",
"startAngle": 180,
"endAngle": 0,
"min": min_range_val,
"max": max_range_val,
"center": ["40%", "40%"],
"splitNumber": 5,
"axisLine": {
"lineStyle": {
"width": 6,
"color": [
[0.25, "#FF403F"],
[0.5, "#ffa500"],
[0.75, "#FDDD60"],
[1, "#64C88A"],
],
}
},
"pointer": {
"icon": "path://M12.8,0.7l12,40.1H0.7L12.8,0.7z",
"length": "12%",
"width": 30,
"offsetCenter": [0, "-60%"],
"itemStyle": {"color": "auto"},
},
"axisTick": {"length": 10, "lineStyle": {"color": "auto", "width": 2}},
"splitLine": {"length": 15, "lineStyle": {"color": "auto", "width": 5}},
"axisLabel": {
"color": "#464646",
"fontSize": 12,
"distance": -60,
},
"title": {"offsetCenter": [0, "-20%"], "fontSize": 20},
"detail": {
"fontSize": 30,
"offsetCenter": [0, "0%"],
"valueAnimation": True,
"color": "auto",
"formatter": "{value}%",
},
"data": [{"value": value, "name": caption}],
}
]
}
st_echarts(option, width="450px", height="350px", key="gauge")
However, it seems like an additional empty extra white space is added at the bottom of the component (as from the following image).
How can I effectively remove that and keep only a tiny margin all around the gauge?
The following parameters must be added:
radius: '120%',
center: ['50%', '80%']
The latter one should be adjusted according to specific use cases.

How get total distance and time from waypoints in HERE REST API

I need to get the total distance and time from waypoints in HERE REST API.
Now i use the routing api:
https://route.api.here.com/routing/7.2/calculateroute.json
"app_id=" + API_ID
"&app_code=" + APP_CODE
"&waypoint0=geo!" + fromCoordsLocation
"&waypoint1=geo!" + toCoordsLocation
"&mode=fastest;car"
and read them from json summary object (Response->Route->Summary). This method returns all the maneuvers and for long distances the callback is slow. there is something that allows only the summary (or the total distance and time) to be received?
Check out these additional properties so you can customize the request as you want. In this case I used representation = overview, your request will be
https://route.api.here.com/routing/7.2/calculateroute.json
"app_id=" + API_ID
"&app_code=" + APP_CODE
"&waypoint0=geo!" + fromCoordsLocation
"&waypoint1=geo!" + toCoordsLocation
"&mode=fastest;car&representation=overview"
The response will be decreased to 78 lines with default 232 lines:
{
"response": {
"metaInfo": {
"timestamp": "2019-11-14T10:03:16Z",
"mapVersion": "8.30.102.151",
"moduleVersion": "7.2.201945-5699",
"interfaceVersion": "2.6.74",
"availableMapVersion": [
"8.30.102.151"
]
},
"route": [
{
"waypoint": [
{
"linkId": "-53623477",
"mappedPosition": {
"latitude": 52.4999825,
"longitude": 13.3999652
},
"originalPosition": {
"latitude": 52.5,
"longitude": 13.4
},
"type": "stopOver",
"spot": 0.3538462,
"sideOfStreet": "left",
"mappedRoadName": "Neuenburger Straße",
"label": "Neuenburger Straße",
"shapeIndex": 0,
"source": "user"
},
{
"linkId": "+1215312511",
"mappedPosition": {
"latitude": 52.4992955,
"longitude": 13.4491968
},
"originalPosition": {
"latitude": 52.5,
"longitude": 13.45
},
"type": "stopOver",
"spot": 1.0,
"sideOfStreet": "left",
"mappedRoadName": "Schlesische Straße",
"label": "Schlesische Straße",
"shapeIndex": 56,
"source": "user"
}
],
"mode": {
"type": "fastest",
"transportModes": [
"car"
],
"trafficMode": "disabled",
"feature": []
},
"summary": {
"distance": 3847,
"trafficTime": 869,
"baseTime": 667,
"flags": [
"noThroughRoad",
"builtUpArea",
"park",
"privateRoad"
],
"text": "The trip takes <span class=\"length\">3.8 km</span> and <span class=\"time\">11 mins</span>.",
"travelTime": 667,
"_type": "RouteSummaryType"
}
}
],
"language": "en-us"
}
}

Alexa Presentation Language Document rendering while speaking

I am trying to render an Alexa Presentation Language document while Alexa is speaking her speech. I tried with a pager with several pages and the AutoPager command. The problem I am trying to solve is that the document is rendered when Alexa starts speaking but the command is started when the speech is finished, and I would like to see the three pages moving while speaking.
I am using the RenderDocumet and the executeCommand and the speak directives of responseBuilder.
The Document Template:
PagerDoc —>
{
"type": "APL",
"version": "1.0",
"theme": "dark",
"import": [],
"resources": [],
"styles": {},
"layouts": {},
"mainTemplate": {
"parameters": [
"datasource"
],
"item": [{
"type": "Container",
"items": [
{
"type": "Sequence",
"id": "pagerComponentId",
"scrollDirection": "vertical",
"numbered": true,
"width": "100vw",
"height": "100vh",
"alignItems": "center",
"justifyContent": "center",
"direction": "column",
"items": [
{
"type": "Image",
"source": "${datasource.app.properties.images.robot1}",
"position": "relative",
"width": "100vw",
"height": "100vh"
},
{
"type": "Image",
"source": "${datasource.app.properties.images.robot2}",
"position": "relative",
"width": "100vw",
"height": "100vh"
}
]
}
]
}
]
}
}
And the Directives:
var response = handlerInput.responseBuilder;
return response
.addDirective({
type : 'Alexa.Presentation.APL.RenderDocument',
token: 'pagerToken',
document : pagerDoc,
datasources : {
"app": {
"properties": {
"images": {
"robot1": "https://xxx/robot1.png",
"robot2": "https://xxx/robot2.png"
}
}
}
}
})
.addDirective({
type: 'Alexa.Presentation.APL.ExecuteCommands',
token: 'pagerToken',
commands: [
{
"type": "Parallel",
"commands": [
{
"type": "Scroll",
"componentId": "pagerComponentId",
"distance": 1
}
]
})
.speak(speechOutput)
.reprompt(repromptOutput)
.getResponse();
Could somebody tell me what should I do? If this is possible with Alexa?
Thanks a lot in advance and best regards,
Fernando
It's not posible yet. If you wait until the release of APL 1.1 (coming soon)
APL 1.1 will add onMount to the APL document which should allow for the execution of commands as soon as a document is loaded (eg. before alexa speaks)

AWS CloudFormation: Template format error: At least one Resources member must be defined

I am sure this template worked previously, but when I validate in the designer now it says:
12/5/2018, 9:41:47 AM - Template contains errors.: Template format
error: At least one Resources member must be defined.
I can't figure out why. I have only the one resource, and it's defined?
{
"AWSTemplateFormatVersion": "2010-09-09",
"Metadata": {
"AWS::CloudFormation::Designer": {
"7edb75f7-c18f-41d8-972e-959e2326ffda": {
"size": {
"width": 60,
"height": 60
},
"position": {
"x": 255,
"y": 217
},
"z": 0,
"embeds": []
}
}
},
"Resources": {
"DemoEc2Stack": {
"Type": "AWS::EC2::Instance",
"Properties": {
"KeyName": "InSiteAutoScaleKey",
"DisableApiTermination": false,
"ImageId": "ami-redacted",
"InstanceType": "t2.micro",
"Monitoring": false,
"SecurityGroupIds": [
"sg-redacted"
],
"Tags": [
{
"Key": "Name",
"Value": "api-demo-cloudformed"
}
]
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "7edb75f7-c18f-41d8-972e-959e2326ffda"
}
}
}
}
}
Problem solved. Such a stupid one! I was on the 'Resources' tab when I was pasting in my CF template from VS Code. I needed to be in the 'Template' tab of the Stack designer in AWS Console. Ugh. I want to jump off a cliff O.O

how to code sap.m.sample.ListGrouping by using js view in openui5

hi i need List grouping control by using js view.but openui5 provides code by using xml view.
https://openui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.ListGrouping/preview
how to convert this code into js view and how to make ListGrouping able to selection for both element level and group level and change this as dropdown box
List.view.xml
<mvc:View
controllerName="sap.m.sample.ListGrouping.List"
xmlns:l="sap.ui.layout"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<List
items="{
path: '/ProductCollection',
sorter: {
path: 'SupplierName',
descending: false,
group: true
},
groupHeaderFactory: '.getGroupHeader'
}"
headerText="Products" >
<StandardListItem
title="{Name}"
description="{ProductId}"
icon="{ProductPicUrl}"
iconDensityAware="false"
iconInset="false" />
</List>
</mvc:View>
List.controller.js
sap.ui.define([
'jquery.sap.global',
'sap/m/GroupHeaderListItem',
'sap/ui/core/mvc/Controller',
'sap/ui/model/json/JSONModel'
], function(jQuery, GroupHeaderListItem, Controller, JSONModel) {
"use strict";
var ListController = Controller.extend("sap.m.sample.ListGrouping.List", {
onInit : function (evt) {
// set explored app's demo model on this sample
var oModel = new JSONModel(jQuery.sap.getModulePath("sap.ui.demo.mock", "/products.json"));
this.getView().setModel(oModel);
},
getGroupHeader: function (oGroup){
return new GroupHeaderListItem( {
title: oGroup.key,
upperCase: false
} );
}
});
return ListController;
});
how to write the same code by using js view
I have tried like as follows, but i am getting Error: Missing template or factory function for aggregation items of Element sap.m.List#__list0 !
List.view.js
sap.ui.jsview("oui5mvc.List", {
getControllerName : function() {
return "oui5mvc.List";
},
createContent : function(oController) {
odbbshiftGlobalId = this.getId();
var oMyFlexbox = new sap.m.FlexBox({
items: [
oList = new sap.m.List({
width: '500px',
group: true,
groupHeaderFactory: '.getGroupHeader',
items: [
]
}),
]
});
oMyFlexbox.placeAt(this.getId()).addStyleClass("tes");
}
});
List.controller.js
sap.ui.controller("oui5mvc.List", {
onInit: function() {
var data = {
"ProductCollection": [
{
"ProductId": "1239102",
"Name": "Power Projector 4713",
"Category": "Projector",
"SupplierName": "Titanium",
"Description": "A very powerful projector with special features for Internet usability, USB",
"WeightMeasure": 1467,
"WeightUnit": "g",
"Price": 856.49,
"CurrencyCode": "EUR",
"Status": "Available",
"Quantity": 3,
"UoM": "PC",
"Width": 51,
"Depth": 42,
"Height": 18,
"DimUnit": "cm",
"ProductPicUrl": "https://openui5.hana.ondemand.com/test-resources/sap/ui/demokit/explored/img/HT-6100.jpg"
},
{
"ProductId": "2212-121-828",
"Name": "Gladiator MX",
"Category": "Graphics Card",
"SupplierName": "Technocom",
"Description": "Gladiator MX: DDR2 RoHS 128MB Supporting 512MB Clock rate: 350 MHz Memory Clock: 533 MHz, Bus Type: PCI-Express, Memory Type: DDR2 Memory Bus: 32-bit Highlighted Features: DVI Out, TV Out , HDTV",
"WeightMeasure": 321,
"WeightUnit": "g",
"Price": 81.7,
"CurrencyCode": "EUR",
"Status": "Discontinued",
"Quantity": 10,
"UoM": "PC",
"Width": 34,
"Depth": 14,
"Height": 2,
"DimUnit": "cm",
"ProductPicUrl": "https://openui5.hana.ondemand.com/test-resources/sap/ui/demokit/explored/img/HT-1071.jpg"
},
{
"ProductId": "K47322.1",
"Name": "Hurricane GX",
"Category": "Graphics Card",
"SupplierName": "Red Point Stores",
"Description": "Hurricane GX: DDR2 RoHS 512MB Supporting 1024MB Clock rate: 550 MHz Memory Clock: 933 MHz, Bus Type: PCI-Express, Memory Type: DDR2 Memory Bus: 64-bit Highlighted Features: DVI Out, TV-In, TV-Out, HDTV",
"WeightMeasure": 588,
"WeightUnit": "g",
"Price": 219,
"CurrencyCode": "EUR",
"Status": "Out of Stock",
"Quantity": 25,
"UoM": "PC",
"Width": 34,
"Depth": 14,
"Height": 2,
"DimUnit": "cm",
"ProductPicUrl": "https://openui5.hana.ondemand.com/test-resources/sap/ui/demokit/explored/img/HT-1072.jpg"
},
],
"ProductCollectionStats": {
"Counts": {
"Total": 14,
"Weight": {
"Ok": 7,
"Heavy": 5,
"Overweight": 2
}
},
"Groups": {
"Category": {
"Projector": 1,
"Graphics Card": 2,
"Accessory": 4,
"Printer": 2,
"Monitor": 3,
"Laptop": 1,
"Keyboard": 1
},
"SupplierName": {
"Titanium": 3,
"Technocom": 3,
"Red Point Stores": 5,
"Very Best Screens": 3
}
},
"Filters": [
{
"type": "Category",
"values": [
{
"text": "Projector",
"data": 1
},
{
"text": "Graphics Card",
"data": 2
},
{
"text": "Accessory",
"data": 4
},
{
"text": "Printer",
"data": 2
},
{
"text": "Monitor",
"data": 3
},
{
"text": "Laptop",
"data": 1
},
{
"text": "Keyboard",
"data": 1
}
]
},
{
"type": "SupplierName",
"values": [
{
"text": "Titanium",
"data": 3
},
{
"text": "Technocom",
"data": 3
},
{
"text": "Red Point Stores",
"data": 5
},
{
"text": "Very Best Screens",
"data": 3
}
]
}
]
}
};
var oTemplate11 = new sap.m.StandardListItem({title : "{Name}"});
oList.setModel(new sap.ui.model.json.JSONModel(data));
oList.bindItems("/ProductCollection");
oList.placeAt('content');
},
getGroupHeader: function (oGroup){
return new sap.m.GroupHeaderListItem( {
title: oGroup.key,
upperCase: false
});
},
});
Your call to bind items to the list is not entirely correct.
The method takes an object with binding information as parameter instead of just the path to the model property. See the documentation for bindItems and bindAggregation in general.
In your case it should look like
oList.bindItems({
path: "/ProductCollection",
template: new sap.m.StandardListItem({
title: "{Name}",
description: "{ProductId}",
icon: "{ProductPicUrl}"
})
});