IBM Watson Dialog API: detailed <entityRules> documentation - ibm-watson

The IBM Watson Dialog API documentation on the following page refers to an entityRules node for expert dialog designers to extract the system-programmed entities but does not say anything else about the node:
http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/dialog/reference_nodes.shtml#reference_entityRules
Is there more detailed documentation on how this node can be used?

You can use entities to create your own data type. So in the doc, we see the example
<entities>
<entity name="currency" entityExample="dollar" entityType="GENERIC">
<value name="USD" value="USD">
<grammar>
<item>dollar </item>
<item>buck</item>
</grammar>
</value>
<value name="EUR" value="EUR">
<grammar>
<item>euro</item>
<item>eur</item>
<item>european buck</item>
</grammar>
</value>
<entityRules></entityRules>
</entity>
</entities>
This "currency" entity has a couple of value types (USD and EUR) but it could be extended to have more rows with more examples of each value. We could also add more values (say YEN, AUD etc or Japanese Yen, Australia Dollar etc).
The next thing would be to utilize the entity in a variation. So you could add a variation in an Input node, example:
I want to convert (currency) to (currency) tomorrow!
You can use any entities in a variation by simply including brackets around it.
You can also assign entity info into a profile variable so you can later access it and utilize it in your Dialog logic. Example variation:
I want to convert (currency)={CURRENCY1} to (currency)={CURRENCY2} tomorrow!
In this example, CURRENCY1 and CURRENCY2 are profile variables, that at run time, contain the entity match info.
Hope this helps.

Related

Geoserver SLD Style - Space in propertyName

I'm trying to set up an sld style in Geoserver which references a column in a PostGIS view "Route Type". I'd like to have spaces in my column names as my goal is to create user friendly views for all my spatial data. With the sld below I get an error. I've tried a substituting the space for   as well as <![CDATA[Property Name]]>
None of these resolve the issue.
Is it possible to have spaces in propertyName?
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
<NamedLayer>
<Name>Truck Routes and Restrictions</Name>
<UserStyle>
<Title>Truck Routes and Restrictions</Title>
<FeatureTypeStyle>
<Rule>
<Name>Designated Municipal Truck Route</Name>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>Route Type</ogc:PropertyName>
<ogc:Literal>*Designated Municipal Truck Route*</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke">#006600</CssParameter>
<CssParameter name="stroke-width">3</CssParameter>
</Stroke>
</LineSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
As I read here PropertyName should be able to be retrieved by Web Feature Service. And next I read How to request WFS propertyName containing parentheses, where I read all this kind of elements must match XML element naming, which don't allows any spaces.
So you can't use space in PropertyName. You should use "my column names" in way that will be not able to see for yours users.

XML Value buried inside the node

I'm brand new to XML, but not SQL. I have data structured by our app vendor as follows that I'm trying to load up into a table:
<windowsets>
<windows>
<question>
<id Value="81b25d-9385-sk3" />
<displayname Value="Thermal Break" />
<answername Value="Yes" />
</question>
<question>
<id Value="73v32k-2743-fd9" />
<displayname Value="Panel Profile" />
<answername Value="Medium Stille" />
</question>
</windows>
</windowsets>
Through other posts here I found and got as far as creating:
select
t.x.value('(id [#Value]/text())[1]','varchar(100)') QuestionID,
t.x.value('(displayname [#Value]/text())[1]','varchar(255)') DisplayName,
t.x.value('(answername [#Value]/text())[1]','varchar(255)') AnswerName
from #xmlData.nodes('//windowsets/windows/question') as T(X)
But it returns nulls for all columns, and I'm guessing that's because it's expecting the format of:
<displayname>Panel Profile</displayname>
So being the XML novice and all the searching I've done hasn't help me understand how to change the code to pull it when the value is buried in node (not even sure of correct terminology I'm so new).
THANK you for your help!
It is called attributes.
To read attributes from xml try something like this
select
t.x.value('(id/#Value)[1]','varchar(100)') QuestionID,
t.x.value('(displayname/#Value)[1]','varchar(255)') DisplayName,
t.x.value('(answername/#Value)[1]','varchar(255)') AnswerName
from #xmlData.nodes('//windowsets/windows/question') as T(X)
This is not an new answer, just some explanation and to much for a comment:
The part within the square brackets is called predicate and is kind of a filter. Your expression
displayname [#Value]/text())[1]
will read the text() of <displayname> and will check, if the attribute #Value exists. Anyway, there is no element's text, so it will return NULL.
You must navigate down the path like .../displayname/#Value if you want to read the attribute's value.
This answer shows some examples how XML deals with empty members.

JAXB Example in camel

Can any one provide me simple example in camel with JAXB using spring XML? I searched on net but did not find anything.
I just want to create simple Student class with fields name, id and convert it into xml.
Not sure what in particular you're struggling with, but here are some snippets:
<util:map id="jaxbNamespacePrefixMap">
<!-- In my case, we dont want a prefix for our namespace; YMMV -->
<entry key="http://www.nmcourts.gov" value=""/>
</util:map>
<marshal>
<jaxb prettyPrint="true" contextPath="generated.gov.nmcourts.ecitation.shared.odyssey"
partClass="generated.gov.nmcourts.ecitation.shared.odyssey.NMCitationEFileBatch" partNamespace="EFileBatch"
namespacePrefixRef="jaxbNamespacePrefixMap"/>
</marshal>
<unmarshal>
<jaxb prettyPrint="true" contextPath="generated.gov.nmcourts.ecitation.shared.odyssey"
partClass="generated.gov.nmcourts.ecitation.shared.odyssey.NMCitationEFileBatch"
partNamespace="EFileBatch" namespacePrefixRef="jaxbNamespacePrefixMap" />
</unmarshal>
What do you need exactly?
http://camel.apache.org/jaxb shows perfectly well how to marshal to xml via spring.

Amazon MWS: getting error 99019 for XML productFeeds (SubmitFeed of type _POST_PRODUCT_DATA_)

When I try to add a product (via a SubmitFeed of type "_POST_PRODUCT_DATA_") to the Amazon Market via the Amazon MWS API I get the following error:
[Marketplace : Amazon.de] A valid value is required in either the
"quantity" or "fulfillment_center_id" field.
But there is no "quantity" or "fulfillment_center_id" field in my Product.xsd nor in the official documentation. Also the exact same feed does work without an error on my Amazon MWS sandbox account. What am I missing?
Complete XML:
<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope>
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>XXX</MerchantIdentifier>
</Header>
<MessageType>Product</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Product>
<SKU>123456</SKU>
<StandardProductID>
<Type>EAN</Type>
<Value>767715012826</Value>
</StandardProductID>
<ProductTaxCode>A_GEN_TAX</ProductTaxCode>
<Condition>
<ConditionType>New</ConditionType>
<ConditionNote>Zustand/condition: neu OVP</ConditionNote>
</Condition>
<DescriptionData>
<Title>Bellydance for Fitness and Fun</Title>
<Manufacturer>New World 2011</Manufacturer>
</DescriptionData>
<ProductData>
<Music>
<ProductType>
<MusicPopular>
<MediaType>audioCD</MediaType>
<NumberOfDiscs>1</NumberOfDiscs>
<Genre>New Age</Genre>
</MusicPopular>
</ProductType>
</Music>
</ProductData>
</Product>
</Message>
</AmazonEnvelope>
Make sure that you use the correct "Merchant Token" (NOT merchant id) in the tag "MerchantIdentifier" inside your feed (this isn't well documented).
<MerchantIdentifier>YOUR_MERCHANT_TOKEN</MerchantIdentifier>
You should see your Merchant Token by navigating to Sellercentral > Settings > Account Info and clicking on Your Merchant Token inside the box Business Information. If the Merchant Token isn't there (which was a common error in the past), contact the Seller Support and ask for the correct Merchant Token: Please send me my Merchant Token (NOT merchant id) for use with 3rd party software.
Try to omit additional tags describing the product, especially the whole <ProductData> section inside the <Product> element. Whenever i specified the <ProductData> section I got error 99019.
The field names in MWS error messages do not match the XML structure. I'm assuming they match the flat file (CSV) columns, but haven't actually checked.
You stated "I try to add a product", while I'm guessing that above error happened when subitting an inventory feed, which is why you won't find the anything of that sort in Product.xsd.
The corresponding XML elements are Quantity and FulfillmentCenterID, both defined in Inventory.xsd.

Solr DataImportHandler: Can I get a dynamic field name from xml attribute with XPathEntityProcessor?

I have some XML to ingest into Solr, which sounds like a use case that is intended to be solved by the DataImportHandler. What I want to do is pull the column name from one XML attribute and the value from another attribute. Here is an example of what I mean:
<document>
<data ref="reference.foo">
<value>bar</value>
</data>
</document>
From this xml snippet, I want to add a field with name reference.foo and value bar. The DataImportHandler includes a XPathEntityProcessor for processing XML documents. I've tried using it and it works perfectly if I give it a known column name (e.g, <field column="ref" xpath="/document/data/#ref">) but have not been able to find any documentation or examples to suggest either how to do what I want, or that it cannot be done. So:
Can I do this using XPathEntityProcessor? If so, how?
If not, can I do this some other way with DataImportHandler?
Or am I left with writing my own import handler?
I haven't managed to find a way to do this without bringing in a transformer, but by using a simple ScriptTransformer I worked it out. It goes something like this:
...
<script>
function makePair(row) {
var theKey = row.get("theKey");
var theValue = row.get("theValue");
row.put(theKey, theValue);
row.remove("theKey");
row.remove("theValue");
return row;
}
</script>
...
<entity name="..."
processor="XPathEntityProcessor"
transformer="script:makePair"
forEach="/document"
...>
<field column="theKey" xpath="/document/data/#ref" />
<field column="theValue" xpath="/document/data/value" />
</entity>
...
Hope that helps someone!
Note, if your dynamicField is multivalued, you have to iterate over theKey since row.get("theKey") will be a list.
What you want to do is select the node keying on an attribute value.
From your example, you'd do this:
<field column="ref" xpath="/document/data[#ref='reference.foo']"/>

Resources