I'm using Facebook Duckling to parse some text but the results include some odd dimensions:
String text = "Tomorrow, February 28";
String result = Duckling.parseText(text);
Result:
[
{
"body": "Tomorrow, February 28",
"start": 0,
"value": {
"values": [
{
"value": "2022-02-28T00:00:00.000-08:00",
"grain": "day",
"type": "value"
}
],
"value": "2022-02-28T00:00:00.000-08:00",
"grain": "day",
"type": "value"
},
"end": 21,
"dim": "time",
"latent": false
},
{
"body": "28'",
"start": 19,
"value": {
"value": 28,
"type": "value",
"minute": 28,
"unit": "minute",
"normalized": {
"value": 1680,
"unit": "second"
}
},
"end": 22,
"dim": "duration",
"latent": false
},
{
"body": "28'",
"start": 19,
"value": {
"value": 28,
"type": "value",
"unit": "foot"
},
"end": 22,
"dim": "distance",
"latent": false
}
]
This result is odd since from the context of the query the text "28" is clearly referring to the day of month but Duckling also returns data as if it were referring to the Distance dimension.
Is there a way to make Duckling context aware and have it only return results matching the full query? Passing "dimensions" as argument is not ideal since I don't know the dimensions in advance.
Thanks
Related
It is necessary to group items from List A if they have the same "timestamp" and then add the grouped items, and all the rest to a new List B.
Keep in mind that the "value" from List A needs to be mapped to a new corresponding field depending on the item "type". Also, "type" needs to be set in List B to "blood_pressure_measurement", in case of a successful grouping for the same "timestamp".
Also, for the items that were not grouped, the "value" also needs to be mapped to a new corresponding field depending on the item "type".
I would higly appreciate if someone would share a working Dart code with me that I can use in my Flutter app. Thank you very much!
EXAMPLE BELOW:
This is the List A, that I am starting with:
List A = [
{
"type": "systolic_blood_pressure",
"value": 120,
"timestamp": "2022-10-31 18:40:59.000",
"sourceName": "com.omronhealthcare.omronconnect",
},
{
"type": "diastolic_blood_pressure",
"value": 80,
"timestamp": "2022-10-31 18:40:59.000",
"sourceName": "com.omronhealthcare.omronconnect",
},
{
"type": "heart_rate",
"value": 60,
"timestamp": "2022-10-31 18:40:59.000",
"sourceName": "com.omronhealthcare.omronconnect",
},
{
"type": "systolic_blood_pressure",
"value": 130,
"timestamp": "2021-11-07 12:20:40.000",
"sourceName": "com.omronhealthcare.omronconnect",
},
{
"type": "diastolic_blood_pressure",
"value": 90,
"timestamp": "2021-11-07 12:20:40.000",
"sourceName": "com.omronhealthcare.omronconnect",
},
{
"type": "heart_rate",
"value": 80,
"timestamp": "2021-11-07 12:20:40.000",
"sourceName": "com.omronhealthcare.omronconnect",
},
{"type": "weight",
"value": 100,
"timestamp": "2022-02-02 13:10:20.000",
"sourceName": "com.omronhealthcare.omronconnect",
},
{"type": "weight",
"value": 98,
"timestamp": "2022-03-01 09:11:10.000",
"sourceName": "com.omronhealthcare.omronconnect",
},
];
And this is list B I need as a result.
List B = [
{
"type": "blood_pressure_measurement",
"systolic_blood_pressure": "120",
"diastolic_blood_pressure": "80",
"heart_rate": "60",
"timestamp": "2022-10-31 18:40:59.000",
"sourceName": "com.omronhealthcare.omronconnect",
},
{
"type": "blood_pressure_measurement",
"systolic_blood_pressure": "130",
"diastolic_blood_pressure": "90",
"heart_rate": "80",
"timestamp": "2021-11-07 12:20:40.000",
"sourceName": "com.omronhealthcare.omronconnect",
},
{
"type": "weight",
"weight": "98",
"timestamp": "2022-02-02 13:10:20.000",
"sourceName": "com.omronhealthcare.omronconnect",
},
{"type": "weight",
"weight": "98",
"timestamp": "2022-03-01 09:11:10.000",
"sourceName": "com.omronhealthcare.omronconnect",
},
];
I searched for different options and packages to manipulate the list, but I do not want to group the items only for the ListView widget, I need to change the real data itself in the list variable.
I have create a connector to azureEventhub , it works fine to pull the data into the topic ,
My use case is to filter the messages that I m pullling basing on the message type .
Example :
{
"messageType": "Transformed",
"timeStamp": 1652113146105,
"payload": {
"externalId": "24323",
"equipmentType": "TemperatureSensor",
"measureType": "Temperature",
"normalizedData": {
"equipmentData": [
{
"key": "ReadingValue",
"value": 23,
"valueType": "number",
"measurementUnit": "celsius",
"measurementDateTime": "2022-05-09T16:18:34.0000000Z"
}
]
},
"dataProviderName": "LineMetrics"
},
},
{
"messageType": "IntegratorGenericDataStream",
"timeStamp": 1652113146103,
"payload": {
"dataSource": {
"type": "sensor",
},
"dataPoints": [
{
"type": "Motion",
"value": 0,
"valueType": "number",
"dateTime": "2022-05-09T16:18:37.0000000Z",
"unit": "count"
}
],
"dataProvider": {
"id": "ba84cbdb-cbf8-4d4f-9a55-93b43f671b5a",
"name": "LineMetrics",
"displayName": "Line Metrics"
}
},
}
I wanted to apply a filter on a value like shown in the pic:
enter image description here
the error that appears to me :
enter image description here
Need help with a JOLT specification for converting the JSON from the shared input format to the expected format.
[
{
"Header": {
"TeamCD": 2
},
"Player": [
{
"PlayerNumber": 1,
"ShortName": "John",
"UniformNO": 11,
"SmartStart": 20200201,
"SmartEnd": 99999999
},
{
"PlayerNumber": 2,
"ShortName": "James",
"UniformNO": 12,
"SmartStart": 20200201,
"SmartEnd": 99999999
}
]
}
]
Desired output:
[
{
"Field": "TeamCD",
"Type": "20"
"Value": 2,
"Vendor": "Vendor1"
},
{
"Field": "PlayerNumber",
"Type": "23"
"Value": 1,
"Vendor": "Vendor1"
},
{
"Field": "ShortName",
"Type": "24"
"Value": "John",
"Vendor": "Vendor1"
},
{
"Field": "PlayerNumber",
"Type": "23"
"Value": 2,
"Vendor": "Vendor1"
},
{
"Field": "ShortName",
"Type": "24"
"Value": "James",
"Vendor": "Vendor1"
}
]
I am trying to achieve this using JoltTransformJSON now. Is this achievable using JoltTransformJSON? I have it running on Nifi, if not possible with Jolt what are my options?
Name | Value 1 | Value 2
BTC | 1 | 2
ETH | 1 | 2
to this:
Tried to used this as an example: https://vega.github.io/vega-lite/examples/bar_grouped.html,
but I can't make it work.
Can someone please point me to the right direction? Thank you in advance.
Instead of using column provided in your question, You can simply use layers and keep the x axis as common and provide value1 and value2 in y axis of each layer respectively and simply provide some offset to show it as a grouped bar chart. Below is the basic spec configuration and editor:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "A simple bar chart with embedded data.",
"title": "My chart",
"width": 200,
"data": {
"values": [
{"name": "BTH", "value1": 28, "value2": 24, "legendTitle": "value1"},
{"name": "ETH", "value1": 55, "value2": 25, "legendTitle": "value2"}
]
},
"encoding": {
"x": {"field": "name", "type": "nominal", "axis": {"labelAngle": 0}}
},
"layer": [
{
"mark": {"type": "bar", "xOffset": -20, "size": 30, "color": "skyblue"},
"encoding": {
"y": {
"field": "value1",
"type": "quantitative",
"axis": {"title": null, "ticks": false}
}
}
},
{
"mark": {"type": "bar", "size": 30, "xOffset": 18, "color": "orange"},
"encoding": {
"y": {
"field": "value2",
"type": "quantitative",
"axis": {"title": null, "ticks": false}
}
}
},
{
"mark": {"type": "text"},
"encoding": {
"fill": {
"field": "legendTitle",
"scale": {"range": ["skyBlue", "orange"]},
"legend": {"title": null, "symbolType": "square", "orient": "bottom"}
}
}
}
]
}
I receive a ContextUpdate event from Orion, and I set a rule to count the numer of the received event, possibly with the same "entityId", over a specific time window.
In the derived event of the aggregate EPA, I want that the "DeviceID" attribute assume the same value of the "entityId" of the received event.
But, both with "Defered" or "Immediate" evaluation policy, in the DeviceID attribute of the consumer output (text file), I've got:
"DeviceID":"[Ljava.lang.Object;#4456c43f"
Any hint?
Thanks.
Here is the json configuration:
{
"epn": {
"events": [{
"name": "DCUPiazzaCarraraContextUpdate",
"createdDate": "Thu Oct 22 2015",
"attributes": [{
"name": "entityId",
"type": "String",
"dimension": 0
}, {
"name": "entityType",
"type": "String",
"dimension": 0
}, {
"name": "battery",
"type": "Double",
"dimension": 0
}, {
"name": "temperature",
"type": "Double",
"dimension": 0
}, {
"name": "stato",
"type": "Boolean",
"dimension": 0
}, {
"name": "rssi",
"type": "Integer",
"dimension": 0
}, {
"name": "lqi",
"type": "Integer",
"dimension": 0
}, {
"name": "timestamp",
"type": "String",
"dimension": 0
}, {
"name": "numprog",
"type": "Integer",
"dimension": 0
}, {
"name": "dcu",
"type": "String",
"dimension": 0
}]
}, {
"name": "DCUAbsence",
"createdDate": "Sat Nov 07 2015",
"attributes": [{
"name": "entityId",
"type": "String",
"dimension": 0
}, {
"name": "entityType",
"type": "String",
"dimension": 0
}, {
"name": "AlertType",
"type": "String",
"dimension": 0
}, {
"name": "eventnum",
"type": "Integer",
"dimension": 0
}, {
"name": "DeviceID",
"type": "String",
"dimension": 0
}, {
"name": "DeviceContext",
"type": "String",
"dimension": 0
}]
}],
"epas": [{
"name": "AbsenceDCU",
"createdDate": "Sat Nov 07 2015",
"epaType": "Aggregate",
"context": "AbsenceDCUComp",
"inputEvents": [{
"name": "DCUPiazzaCarraraContextUpdate",
"consumptionPolicy": "Reuse",
"instanceSelectionPolicy": "First"
}],
"computedVariables": [{
"name": "eventnum",
"aggregationType": "Count",
"DCUPiazzaCarraraContextUpdate": "1"
}],
"evaluationPolicy": "Immediate",
"cardinalityPolicy": "Unrestricted",
"internalSegmentation": [],
"derivedEvents": [{
"name": "DCUAbsence",
"reportParticipants": false,
"expressions": {
"entityId": "\"Alert\"",
"entityType": "\"PiazzaCarrara\"",
"AlertType": "\"006\"",
"eventnum": "eventnum",
"DeviceID": "DCUPiazzaCarraraContextUpdate.entityId",
"DeviceContext": "DCUPiazzaCarraraContextUpdate.entityType"
}
}]
}],
"contexts": {
"temporal": [{
"name": "AbsenceDCUWindow",
"createdDate": "Sat Nov 07 2015",
"type": "TemporalInterval",
"atStartup": false,
"neverEnding": false,
"initiators": [{
"initiatorType": "Event",
"initiatorPolicy": "Ignore",
"name": "DCUPiazzaCarraraContextUpdate"
}],
"terminators": [{
"terminatorType": "RelativeTime",
"terminationType": "Discard",
"relativeTime": "5000"
}]
}],
"segmentation": [{
"name": "AbsenceDCUID",
"createdDate": "Thu Dec 17 2015",
"participantEvents": [{
"name": "DCUPiazzaCarraraContextUpdate",
"expression": "DCUPiazzaCarraraContextUpdate.entityId"
}, {
"name": "DCUAbsence",
"expression": "DCUAbsence.DeviceID"
}]
}],
"composite": [{
"name": "AbsenceDCUComp",
"createdDate": "Thu Dec 17 2015",
"temporalContexts": [{
"name": "AbsenceDCUWindow"
}],
"segmentationContexts": [{
"name": "AbsenceDCUID"
}]
}]
},
"consumers": [{
"name": "OnFileAlert",
"createdDate": "Thu Oct 22 2015",
"type": "File",
"properties": [{
"name": "filename",
"value": "/var/log/tomcat7/Alert.json"
}, {
"name": "formatter",
"value": "json"
}, {
"name": "delimiter",
"value": ";"
}, {
"name": "tagDataSeparator",
"value": "="
}, {
"name": "SendingDelay",
"value": "1000"
}, {
"name": "dateFormat",
"value": "dd/MM/yyyy-HH:mm:ss"
}],
"events": [{
"name": "DCUAbsence"
}, {
"name": "DCUPiazzaCarraraContextUpdate"
}]
}],
"producers": [],
"name": "CounterExample"
}
}
In an EPA of type Aggregate, since many events from that type can arrive during the context, when you refer to an input event attribute in the derivation expression, you get an array that holds the attribute of all the participant input events of that type.
In your example, DCUPiazzaCarraraContextUpdate.entityId will hold an array of entityId.
If you want a single value you can either use array access function to get one value from the array, or since you use a segmentation context over the entityId, you can get the entityId from that context.
For getting the attribute from the context use context."segmentation-context-name" expression, which in your case is:
context.AbsenceDCUID
In the general case, you can get a specific entry from the array using array access functions. For example, getting the last value from the array:
ArrayGet(DCUPiazzaCarraraContextUpdate.entityId, ArraySize(DCUPiazzaCarraraContextUpdate.entityId)-1)