I have written a VXML which for the most part works. I would like to use a grxml now instead of inline grammar.
I created icecream.grxml in the same exact directory AS MY vxml APP and i call it like this
<grammar src="icecream.grxml" type="application/srgs+xml"/>
for example
<form id="formIdicecream">
<grammar src="icecream.grxml" type="application/srgs+xml"/>
<field name="icecream"> <prompt> What is your favorite icecream? </prompt> </field>
<field name="confirm">
<prompt> Your favorite icecream is <value expr="icecream$.utterance"/> </prompt>
</field>
<block> <goto next="#formIddtmf"/> </block>
my icecream.grxml looks like below, when I run my code I get an error :
Grammar activation failed |MSG=error activating grammar|URI=icecream.grxml
#
<!--Header-->
<?xml version="1.0"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar"
xml:lang="en-US"
root="icecream"
mode="voice">
<!--Rules-->
<rule id="icecream">
<one-of>
<item><ruleref
uri="#vanilla" /></item>
<item><ruleref
uri="#chocolate" /></item>
<item><ruleref
uri="#strawberry" /></item>
</one-of>
</rule>
<rule id="vanilla">
<one-of>
<item>vanilla</item>
<item>nilla</item>
</one-of>
</rule>
<rule id="chocolate">
<one-of>
<item>chocolate</item>
<item>colate</item>
</one-of>
</rule>
<rule id="strawberry">
<one-of>
<item>strawberry</item>
<item>straw</item>
</one-of>
</rule>
</grammar>
Related
I am trying to add a button to the AppointmentOrganizerCommandSurface in Outlook just like Giphy is added in this image, but instead, my My Office Add-in is added to the menu.
I would like to add an action button with my custom icon next to the Giphy action.
I tried manipulating manifest.xml. I went through the documentation and followed the steps, but I was unable to figure out what is going on.
Here is the manifest:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0" xsi:type="MailApp">
<Id>61262617-dad8-4e84-a9e4-89b1bab3e6e7</Id>
<Version>1.0.0.0</Version>
<ProviderName>Contoso</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="My Office Add-In"/>
<Description DefaultValue="A template to get started."/>
<IconUrl DefaultValue="https://localhost:3000/assets/icon-64.png"/>
<HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/icon-128.png"/>
<SupportUrl DefaultValue="https://www.contoso.com/help"/>
<AppDomains>
<AppDomain>https://www.contoso.com</AppDomain>
</AppDomains>
<Hosts>
<Host Name="Mailbox"/>
</Hosts>
<Requirements>
<Sets>
<Set Name="Mailbox" MinVersion="1.1"/>
</Sets>
</Requirements>
<FormSettings>
<Form xsi:type="ItemRead">
<DesktopSettings>
<SourceLocation DefaultValue="https://localhost:3000/taskpane.html"/>
<RequestedHeight>250</RequestedHeight>
</DesktopSettings>
</Form>
</FormSettings>
<Permissions>ReadWriteItem</Permissions>
<Rule xsi:type="RuleCollection" Mode="Or">
<Rule xsi:type="ItemIs" ItemType="Message" FormType="Read"/>
</Rule>
<DisableEntityHighlighting>false</DisableEntityHighlighting>
<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
<Requirements>
<bt:Sets DefaultMinVersion="1.3">
<bt:Set Name="Mailbox"/>
</bt:Sets>
</Requirements>
<Hosts>
<Host xsi:type="MailHost">
<DesktopFormFactor>
<FunctionFile resid="Commands.Url"/>
<ExtensionPoint xsi:type="AppointmentOrganizerCommandSurface">
<OfficeTab id="TabDefault">
<Group id="msgReadGroup">
<Label resid="GroupLabel"/>
<Control xsi:type="Button" id="msgReadOpenPaneButton">
<Label resid="TaskpaneButton.Label"/>
<Supertip>
<Title resid="TaskpaneButton.Label"/>
<Description resid="TaskpaneButton.Tooltip"/>
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16"/>
<bt:Image size="32" resid="Icon.32x32"/>
<bt:Image size="80" resid="Icon.80x80"/>
</Icon>
<Action xsi:type="ShowTaskpane">
<SourceLocation resid="Taskpane.Url"/>
</Action>
</Control>
<Control xsi:type="Button" id="ActionButton">
<Label resid="ActionButton.Label"/>
<Supertip>
<Title resid="ActionButton.Label"/>
<Description resid="ActionButton.Tooltip"/>
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16"/>
<bt:Image size="32" resid="Icon.32x32"/>
<bt:Image size="80" resid="Icon.80x80"/>
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>action</FunctionName>
</Action>
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
</DesktopFormFactor>
</Host>
</Hosts>
<Resources>
<bt:Images>
<bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
<bt:Image id="Icon.32x32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
<bt:Image id="Icon.80x80" DefaultValue="https://localhost:3000/assets/icon-80.png"/>
</bt:Images>
<bt:Urls>
<bt:Url id="Commands.Url" DefaultValue="https://localhost:3000/commands.html"/>
<bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html"/>
</bt:Urls>
<bt:ShortStrings>
<bt:String id="GroupLabel" DefaultValue="Contoso Add-in"/>
<bt:String id="TaskpaneButton.Label" DefaultValue="Show Taskpane"/>
<bt:String id="ActionButton.Label" DefaultValue="Perform an action"/>
</bt:ShortStrings>
<bt:LongStrings>
<bt:String id="TaskpaneButton.Tooltip" DefaultValue="Opens a pane displaying all available properties."/>
<bt:String id="ActionButton.Tooltip" DefaultValue="Perform an action when clicked."/>
</bt:LongStrings>
</Resources>
</VersionOverrides>
</OfficeApp>
Thank you in advance.
You need to pin your add-in in the outlook to acheive the same.
You can pin an add-in so it's easily available when you're composing an email message.
Select Settings> View all Outlook settings > Mail > Customize actions.
Select the check box for the add-in that you want to see when you’re composing a message.
I have been working on watson dialog for few days now, and I am able to create a dialog using .xml file after following few tutorials.
<?xml version="1.0" encoding="UTF-8"?>
<dialog xsi:noNamespaceSchemaLocation="WatsonDialogDocument_1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<flow>
<folder label="Main">
<output>
<prompt selectionType="RANDOM">
<item>Hi, I'll show you the latest buzz around a topic of your choice. What topic are you interested in?</item>
</prompt>
<goto ref="getUserInput_2442994"/>
</output>
<output>
<prompt selectionType="RANDOM">
<item>Bye</item>
</prompt>
<getUserInput id="getUserInput_2442994">
<search ref="folder_2442998"/>
</getUserInput>
</output>
</folder>
<folder label="Library">
<folder label="Live Content" id="folder_2447777">
<output>
<prompt selectionType="RANDOM">
<item>Alright. Open this URL to see the tweets: http://insights-search.mybluemix.net/api/1/messages/search?q={Topic}%20AND%20posted%3A2015-07-01%20AND%20sentiment%3A{Sentiment}</item>
</prompt>
</output>
</folder>
<folder label="Live Content" id="folder_2442998">
<input>
<grammar>
<item>*</item>
</grammar>
<action varName="Topic" operator="SET_TO_USER_INPUT"/>
<output>
<prompt selectionType="SEQUENTIAL">
<item>Are you interested in positive or negative tweets?</item>
</prompt>
<getUserInput>
<input>
<grammar>
<item>positive</item>
</grammar>
<action varName="Sentiment" operator="SET_TO">positive</action>
<goto ref="folder_2447777"/>
</input>
<input>
<grammar>
<item>negative</item>
</grammar>
<action varName="Sentiment" operator="SET_TO">negative</action>
<goto ref="folder_2447777"/>
</input>
<input>
<grammar>
<item>*</item>
</grammar>
<action varName="Sentiment" operator="SET_TO">nothing</action>
<goto ref="folder_2442998"/>
</input>
</getUserInput>
</output>
</input>
</folder>
<folder label="Storage"/>
</folder>
<folder label="Global"/>
<folder label="Concepts">
<concept>
<grammar>
<item>positive</item>
<item>good</item>
</grammar>
</concept>
</folder>
</flow>
<entities>
</entities>
<constants>
</constants>
<variables>
<var_folder name="Home">
<var name="Topic" type="TEXT"/>
<var name="Sentiment" type="TEXT"/>
</var_folder>
</variables>
<settings>
</settings>
<specialSettings>
</specialSettings>
</dialog>
I am using nodeJs for my server and wish to switch to JSON instead of XML. As the API reference says,
The dialog template file. Valid extensions are .mct for encrypted
dialog files, .json, and .xml.
I dont find any JSON structure anywhere in the documentation for the dialog file.
Has anyone tried this before and succeeded in using JSON instead of XML? How?
The Dialog service only accepts XML and MCT files. I think you found an error in the documentation.
On the other hand, the service was deprecated on August 15, 2016. Existing instances of the service will continue to function until August 9, 2017. We are encouraging users to migrate to use the Conversation service.
The conversation service has a web tool that lets you create dialogs, you won't have to write XML. It also allows you to export the project as JSON.
I noticed that we can use Watson EntityType to extract time reference from user input, e.g.:
<folder label="Invite Time">
<output id="output_invite_time">
<prompt>
<item>What time is your meeting?</item>
</prompt>
<getUserInput>
<input>
<grammar>
<item>$ (DATE_TIME_RANGE)={var-invite_time}</item>
</grammar>
<action varName="var-invite_time" operator="SET_TO">{var-invite_time.value:FROM_TIME}</action>
<goto ref="output_invite_date"/>
</input>
<output>
<prompt>
<item>I'll need a valid time to continue.</item>
</prompt>
<goto ref="output_invite_time"/>
</output>
</getUserInput>
</output>
</folder>
I'm trying to figure out how to use other (supported?) EntityTypes like Generic, Location, Amount, etc. But the result is sometimes unexpected. For example "nice house in Denver, Colorado" for Location entity results in "nice"; or specifying "yesterday" for date results in incorrect date.
My simplified dialog file as follow:
<?xml version="1.0" encoding="UTF-8"?>
<dialog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="WatsonDialogDocument_1.0.xsd">
<flow>
<folder label="Main" id="Main">
<output id="start">
<prompt selectionType="RANDOM">
<item>DIALOG START - asking for user input</item>
</prompt>
<goto ref="processUserInput_start"/>
</output>
<getUserInput id="processUserInput_start">
<search ref="library_supported-intents"/>
<default>
<output>
<prompt selectionType="RANDOM">
<item>I am sorry, I did not understand your intents. Please choose intent1.</item>
</prompt>
</output>
</default>
</getUserInput>
</folder>
<folder label="Library" id="Library">
<folder label="Main Input" id="library_supported-intents">
<input>
<grammar>
<item>intent1</item>
</grammar>
<output>
<prompt selectionType="RANDOM">
<item>OK. Executing intent 1</item>
</prompt>
<goto ref="intent1-detail-generic"/>
</output>
</input>
</folder>
<folder label="Intent 1 Input Generic" id="library_intent1-generic">
<output id="intent1-detail-generic">
<prompt>
<item>Please specify generic</item>
</prompt>
<getUserInput>
<search ref="library_supported-intents"/>
<input>
<grammar>
<item>$ (ZIPCODE)={var-param_generic}</item>
</grammar>
<action varName="var-param_generic" operator="SET_TO">{var-param_generic.value:main}</action>
<goto ref="intent1-detail-location"/>
</input>
<output>
<prompt>
<item>I'll need a valid generic to continue.</item>
</prompt>
<goto ref="intent1-detail-generic"/>
</output>
</getUserInput>
</output>
</folder>
<folder label="Intent 1 Input Location" id="library_intent1-location">
<output id="intent1-detail-location">
<prompt>
<item>Please specify Location</item>
</prompt>
<getUserInput>
<search ref="library_supported-intents"/>
<input>
<grammar>
<item>$ (LOCATION)={var-param_location}</item>
</grammar>
<action varName="var-param_location" operator="SET_TO">{var-param_location.source}</action>
<goto ref="intent1-detail-amount"/>
</input>
<output>
<prompt>
<item>I'll need a valid location to continue.</item>
</prompt>
<goto ref="intent1-detail-location"/>
</output>
</getUserInput>
</output>
</folder>
<folder label="Intent 1 Input Location" id="library_intent1-amount">
<output id="intent1-detail-amount">
<prompt>
<item>Please specify Amount</item>
</prompt>
<getUserInput>
<search ref="library_supported-intents"/>
<input>
<grammar>
<item>$ (AMOUNT)={var-param_amount}</item>
</grammar>
<action varName="var-param_amount" operator="SET_TO">{var-param_amount.value:main}</action>
<goto ref="intent1-detail-time"/>
</input>
<output>
<prompt>
<item>I'll need a valid amount to continue.</item>
</prompt>
<goto ref="intent1-detail-amount"/>
</output>
</getUserInput>
</output>
</folder>
<folder label="Intent 1 Input Time" id="library_intent1-time">
<output id="intent1-detail-time">
<prompt>
<item>Please specify time</item>
</prompt>
<getUserInput>
<search ref="library_supported-intents"/>
<input>
<grammar>
<item>$ (DATE_TIME_RANGE)={var-param_time}</item>
</grammar>
<action varName="var-param_time" operator="SET_TO">{var-param_time.value:FROM_TIME}</action>
<goto ref="intent1-detail-date"/>
</input>
<output>
<prompt>
<item>I'll need a valid time to continue.</item>
</prompt>
<goto ref="intent1-detail-time"/>
</output>
</getUserInput>
</output>
</folder>
<folder label="Intent 1 Input Date" id="library_intent1-date">
<output id="intent1-detail-date">
<prompt>
<item>Please specify date</item>
</prompt>
<getUserInput>
<search ref="library_supported-intents"/>
<input>
<grammar>
<item>$ (DATE_TIME_RANGE)={var-param_date}</item>
</grammar>
<action varName="var-param_date" operator="SET_TO">{var-param_date.value:FROM_DATE}</action>
<output>
<prompt>
<item>You've specified {var-param_time} on {var-param_date}.</item>
</prompt>
</output>
<goto ref="processUserInput_start"/>
</input>
<output>
<prompt>
<item>I'll need a valid date to continue.</item>
</prompt>
<goto ref="intent1-detail-date"/>
</output>
</getUserInput>
</output>
</folder>
</folder>
<folder label="Concepts" id="Concepts"></folder>
</flow>
<entities>
<entity name="ZIPCODE" entityType="GENERIC">
<value name="10024" value="10024"/>
<value name="07928" value="07928"/>
<value name="95118" value="95118"/>
<value name="95120" value="95120"/>
<value name="uszipcode" value="!^[0-9]{5}$"/>
<entityRules></entityRules>
</entity>
</entities>
<variables>
<var_folder name="Home">
<var name="IntentClass" type="TEXT"/>
<var name="Class1" type="TEXT"/>
<var name="Class1_Confidence" type="NUMBER" initValue="0" description="Confidence score for Class1 from NL classifier"/>
<var name="var-param_date" type="TEXT" description="Date object"/>
<var name="var-param_time" type="TEXT" description="Time object"/>
<var name="var-param_generic" type="TEXT" description="Generic Object"/>
<var name="var-param_location" type="TEXT" description="Location Object"/>
<var name="var-param_amount" type="TEXT" description="Amount Object"/>
</var_folder>
</variables>
</dialog>
I'm not sure if I use it the right way given the sample tutorial only mentioned {ProfVar.value:main} or {ProfVar.value:name}. I could not find FROM_TIME and FROM_DATE for DATE_TIME_RANGE in the official documentation.
What entity types are supported and how can I properly extract entity specific info in Watson Dialog?
I'm trying to figure out how to use other (supported?) EntityTypes like Generic, Location, Amount, etc. But the result is sometimes unexpected. For example "nice house in Denver, Colorado" for Location entity results in "nice"; or specifying "yesterday" for date results in incorrect date.
"Nice" is the city in France. So it gave the correct response.
The issue is that Dialogs entity extraction is very basic. From your sample:
$ (LOCATION)={var-param_location}
This will find the first entity and stop looking. To demonstrate the limitation, lets say you want to get three possible locations within a users response.
$ (LOCATION)={var-param_location}
$ (LOCATION)={var-param_location} (LOCATION)={var-param_location2}
$ (LOCATION)={var-param_location} * (LOCATION)={var-param_location2}
$ (LOCATION)={var-param_location} (LOCATION)={var-param_location2} (LOCATION)={var-param_location3}
$ (LOCATION)={var-param_location} * (LOCATION)={var-param_location2} (LOCATION)={var-param_location3}
$ (LOCATION)={var-param_location} * (LOCATION)={var-param_location2 * (LOCATION)={var-param_location3}
$ (LOCATION)={var-param_location} (LOCATION)={var-param_location2 * (LOCATION)={var-param_location3}
As you can see, it will start getting messy real fast. It is really only meant for where you expect one entity or an explicit amount of entities being returned.
If you want to get a more accurate entity/keyword extraction, then send it to something like AlchemyAPI first. Have the API return the keyword/entities, then work with them.
I pass a filename to ant script via
ant -Dfilepath=/foo/bar/foobar.suffix
I want to copy it to a destination and if it is a .js file generate a compiled version of it.
This works but currently the compile task runs on all files not just .js file.
How do I exclude non .js files in the "runjscompile" task?
In a fileset I would do this (but I don't get how to apply this on the task):
<fileset dir="${foo}" casesensitive="yes">
<exclude name="**/*.min.js" />
<include name="**/*.js" />
</fileset>
My build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="test" basedir="." default="build">
<taskdef name="jscomp" classname="com.google.javascript.jscomp.ant.CompileTask" classpath="/home/bar/bin/compiler.jar" />
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="/usr/share/java/ant-contrib.jar" />
</classpath>
</taskdef>
<property name="serverRoot" value="/home/bar/server/public_html" />
<property name="foo" value="${serverRoot}/foo/" />
<property name="workspaceRoot"
value="/home/bar/Zend/workspaces/DefaultWorkspace/" />
<property name="foo_service" value="${workspaceRoot}/foo_service/" />
<property name="filepath" value="${filepath}" />
<target name="build" depends="transferFile, runjscompile" />
<target name="transferFile" description="overwrite old file">
<basename property="filename" file="${filepath}" />
<dirname property="path" file="${filepath}" />
<pathconvert property="path.fragment" pathsep="${line.separator}">
<propertyresource name="path" />
<mapper type="regexp" from="^/[^/]+/(.*)" to="\1" />
</pathconvert>
<echo message="copy ${workspaceRoot}${filepath} to ${foo}${path.fragment}${filename}" />
<copy file="${workspaceRoot}${filepath}" tofile="${foo}${path.fragment}${filename}"
overwrite="true" force="true" />
<property name="destFile" value="${foo}${path.fragment}${filename}" />
</target>
<target name="runjscompile">
<echo message="compile ${destFile}" />
<basename property="file" file="${destFile}" />
<basename property="prefix" file="${destFile}" suffix=".js" />
<dirname property="directory" file="${destFile}" />
<echo message="Compressing file ${file} to ${directory}/${prefix}.min.js" />
<jscomp compilationLevel="simple" debug="false" output="${directory}/${prefix}.min.js" forceRecompile="true">
<sources dir="${directory}">
<file name="${file}" />
</sources>
</jscomp>
</target>
</project>
Add another target which checks the file suffix with a <condition> and sets a property if it matches, then make the jscompile target conditional on that. Following your fileset example you probably want something like:
<target name="check.js">
<condition property="do.jscompile">
<!-- check for filepath that ends .js but not .min.js -->
<matches string="${filepath}" pattern=".*(?<!\.min)\.js$$" />
</condition>
</target>
<target name="build" depends="check.js, transferFile, runjscompile" />
<target name="runjscompile" if="do.jscompile">
I need to index 5 different kinds of xml files. They share similar structure with slight differences in each of them.
example 1:
<?xml version="1.0"?>
<manifest>
<metadata>
<isbn>9780815341291</isbn>
<title>Essential Cell Biology,Third Edition</title>
<authors>
<author>Alberts;Bruce</author>
<author>Bray;Dennis</author>
</authors>
<categories>
<category>SCABC</category>
<category>SCDEF</category>
</categories>
</metadata>
<resources>
<audioresource>
<uuid>123456789</uuid>
<source>03_Mutations_Origin_Cancer.mp3</source>
<mimetype>audio/mpeg</mimetype>
<title>Part Three - Mutations and the Origin of Cancer</title>
<description>123</description>
<chapters>
<chapter>1</chapter>
</chapters>
</audioresource>
</resources>
</manifest>
example 2:
<?xml version="1.0"?>
<manifest>
<metadata>
<isbn>9780815341291</isbn>
<title>Essential Cell Biology,Third Edition</title>
<authors>
<author>FN:Alberts;Bruce</author>
<author>FN:Bray;Dennis</author>
</authors>
<categories>
<category>SCABC</category>
<category>SCGHI</category>
</categories>
</metadata>
<resources>
<glossaryresource>
<uuid>123456789</uuid>
<term>A subunit </term>
<definition>The portion of a bacterial exotoxin that interferes with normal host cell function. </definition>
<chapters>
<chapter>10</chapter>
</chapters>
</glossaryresource>
</resources>
</manifest>
My dih-config.xml is as below:
<dataConfig>
<dataSource name="fileReader" type="FileDataSource" encoding="UTF-8"/>
<document>
<entity name="dir" rootEntry="false" dataSource="null" processor="FileListEntityProcessor" fileName="^.*\.xml$" recursive="true" baseDir="X:/tmp/npr">
<entity name="audioresource"
rootEntity="true"
dataSource="fileReader"
url="${dir.fileAbsolutePath}"
stream="false"
logTemplate=" processing ${dir.fileAbsolutePath}"
logLevel="debug"
processor="XPathEntityProcessor"
forEach="/manifest/metadata | /manifest/metadata/authors | /manifest/metadata/categories | /manifest/metadata/resources | /manifest/resources/audioresource | /manifest/resources/audioresource/chapters"
transformer="DateFormatTransformer">
<field column="category" xpath="/manifest/metadata/categories/category" />
<field column="author" xpath="/manifest/metadata/authors/author" />
<field column="book_title" xpath="/manifest/metadata/title" />
<field column="isbn" xpath="/manifest/metadata/isbn"/>
<field column="id" xpath="/manifest/resources/audioresource/uuid"/>
<field column="mimetype" xpath="/manifest/resources/audioresource/mimetype" />
<field column="title" xpath="/manifest/resources/audioresource/title"/>
<field column="description" xpath="/manifest/resources/audioresource/description"/>
<field column="chapter" xpath="/manifest/resources/audioresource/chapters/chapter"/>
<field column="source" xpath="/manifest/resources/audioresource/source"/>
</entity>
</entity>
</document>
</dataConfig>
I'm not quite familiar with xpath. I can't use wildcard in element name, can I? Tried it and it didn't work.
Many thanks in advance.
I'm currently investigating a similar issue. Have you tried creating an XSLT? The entity element has an optional "xsl" attribute.