UWP Voice Command Set not working with multiple phrases - win-universal-app

When trying to implement VoiceCommands, I use this set:
<Command Name="searchCommand">
<Example>Search for UWP on Bing </Example>
<ListenFor RequireAppName="BeforeOrAfterPhrase"> search for {search} on {service} </ListenFor>
<Feedback>Searching for {search} on {service}</Feedback>
<Navigate />
</Command>
I added these phrases (where the service is dynamically updated in code, this all works fine):
<PhraseList Label="service">
<!-- Dynamic -->
</PhraseList>
<PhraseTopic Label="search" Scenario="Search">
<!-- Dynamic -->
</PhraseTopic>
Now when I use this command, the API only seems to recognize the last phrase. So if I use 3 phrases, only the last will be recognized.
Command: 'Search for UWP on Bing'
Shows up as: 'Searching for {search} on Bing'
TextSpoken value: 'Search for UWP on Bing' (so the voice to text is working correctly)
When I use 'Search for {search}' in the ListenFor, it correctly returns the right result. But for this feature I am implementing I need 2 (or even 3) phrases in a single command.
It seems that UWP only recognizes the last phrase. Am I correct or should it be possible to use multiple phrases inside a ListenFor element?
Update June 13, 2016:
I have created a repro:

Geert, it looks like you're using Windows Insider build 14342. The issue you're seeing is due to a bug introduced in build 14341 which should be fixed in builds >= 14371.
Hope that helps.

No UWP recognizes multiple phrase inside a ListenFor
I guess you need to more than one ListenFor
<Command Name="searchCommand">
<Example>Search for UWP on Bing </Example>
<ListenFor RequireAppName="BeforeOrAfterPhrase"> search for {search} on {service} </ListenFor>
<ListenFor RequireAppName="BeforeOrAfterPhrase">search for {search}</ListenFor>
<ListenFor RequireAppName="BeforeOrAfterPhrase">search for on {service}</ListenFor>
<Feedback>Searching for {search} on {service}</Feedback>
<Navigate />
</Command>
In this way you can cover all the combination. I guess Cortana is getting confused because of only one ListenFor.

Related

Finding Related Topics using Google Knowledge Graph API

I'm currently working on a behavioral targeting application and I need a considerably large keyword database/tool/provider that enables applications to reach to the similar keywords via given keyword for my app. I've recently found that Freebase, which had been providing a similar service before Google acquired them and then integrated to their Knowledge Graph. I was wondering if it's possible to have a list of related topics/keywords for the given entity.
import json
import urllib
api_key = 'API_KEY_HERE'
query = 'Yoga'
service_url = 'https://kgsearch.googleapis.com/v1/entities:search'
params = {
'query': query,
'limit': 10,
'indent': True,
'key': api_key,
}
url = service_url + '?' + urllib.urlencode(params)
response = json.loads(urllib.urlopen(url).read())
for element in response['itemListElement']:
print element['result']['name'] + ' (' + str(element['resultScore']) + ')'
The script above returns the queries below, though I'd like to receive related topics to yoga, such as health, fitness, gym and so on, rather than the things that has the word "Yoga" in their name.
Yoga Sutras of Patanjali (71.245544)
Yōga, Tokyo (28.808222)
Sri Aurobindo (28.727333)
Yoga Vasistha (28.637642)
Yoga Hosers (28.253984)
Yoga Lin (27.524054)
Patanjali (27.061115)
Yoga Journal (26.635073)
Kripalu Center (26.074436)
Yōga Station (25.10318)
I'd really appreciate any suggestions, and I'm also open to using any other API if there is any that I could make use of. Cheers.
See your point:) So here's the script I use for that using Serpstat's API. Here's how it works:
Script collects the keywords from Serpstat's database
Then, collects search suggestions from Serpstat's database
Finally, collects search suggestions from Google's suggestions
Note that to make script work correctly, it's preferable to fill all input boxes. But not all of them are required.
Keyword — required keyword
Search Engine — a search engine for which the analysis will be carried out. For example, for the US Google, you need to set the g_us. The entire list of available search engines can be found here.
Limit the maximum number of phrases from the organic issue, which will participate in the analysis. You cannot set more than 1000 here.
Default keys — list of two-word keywords. You should give each of them some "weight" to receive some kind of result if something goes wrong.
Format: type, keyword, "weight". Every keyword should be written from a new line.
Types:
w — one word
p — two words
Examples:
"w; bottle; 50" — initial weight of word bottle is 50.
"p; plastic bottle; 30" — initial weight of phrase plastic bottle is 30.
"w; plastic bottle; 20" — incorrect. You cannot use a two-word phrase for the "w" type.
Bad words — comma-separated list of words you want the script to exclude from the results.
Token — here you need to enter your token for API access. It can be found on your profile page.
You can download the source code for script here

XSL-FO conditional-page-master-reference keeps rendering 2+ pages using last page master

I have this layout-master-set definition:
<fo:layout-master-set>
<fo:simple-page-master master-name="all-pages" page-width="210mm" page-height="297mm" margin="20mm 20mm 0mm 20mm" >
<fo:region-body margin-top="25mm" margin-bottom="35mm" />
<fo:region-before extent="20mm" />
<fo:region-after extent="30mm" />
</fo:simple-page-master>
<fo:simple-page-master master-name="last-page" page-width="210mm" page-height="297mm" margin="20mm 20mm 0mm 20mm" >
<fo:region-body margin-top="25mm" margin-bottom="115mm" />
<fo:region-before extent="20mm" />
<fo:region-after extent="110mm" region-name="region-last-page" />
</fo:simple-page-master>
<fo:page-sequence-master master-name="pages">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference page-position="last" master-reference="last-page"/>
<fo:conditional-page-master-reference page-position="any" master-reference="all-pages"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
As you can see, I want the last page to render a much bigger region-after, but instead I get the large region-after on all pages after the first, and the all-pages master is only used for the first page?
Does anyone see a problem with that configuration?
PS: using Fop 0.20.5
The configuration looks okay. But you should give all regions a name to remove ambiguity.
The fo:page-sequence-master is correctly defined, the problem is the FOP version you are using: 0.20.5 dates back to 2003 (!) and had several bugs and missing features.
At the moment the latest released version is 1.1, which creates the pages as expected.
Disclosure: I am a FOP developer (although I haven't been very active for years).

How to create XML in Google custom search Autocomplete?

I try to use the structure at https://developers.google.com/custom-search/docs/queries but it can't upload successfully.
<Autocompletions>
<Autocompletion term="cake" type="1" language=""/>
<Autocompletion term="strawberry.*" type="2" match="2" language=""/>
<Autocompletion term="vanilla" type="2" language=""/>
<Autocompletion term="apple" type="3" language="">
<Promotion id="1" queries="dessert" title="Apple pie for dessert!" url="http://www.example.com/applepieforsale"
start_date="" end_date="" image_url="" description="Apple pie is the best dessert ever!"/>
<Promotion id="2" queries="apple" title="Buy Apple pie" url="http://www.example.com/applepieforsale"
start_date="" end_date="" image_url="" description="We stock the best apple pie in the world, right here."/>
</Autocompletion>
</Autocompletions>
My website is using wordpress; I get the title of posts and want to use it as string query for google custom search.
Please help me figure out how to create XML for autocomplete.
It's not liking the description attributes. It you remove those, then it will work.
Leave all terms in XML like that:
<Autocompletion term="%term-title%" type="%type%" language=""/>
Be careful with the length of the terms, I found that if it is 3 or less words, Google will accept it fine. There is also no big restriction on ammount of entries you're adding (I added 9000 entries in one go). And I added them in Russian, so there are no problems with encoding either.
The final format should be like that:
<Autocompletions>
<Autocompletion term="%term-title%" type="%type%" language=""/>
...
<Autocompletion term="%term-title%" type="%type%" language=""/>
</Autocompletions>
Not terribly well documented by Google, so you have to waste time reading this. Hope it helps :)

Movable Type: How do I generate random number with certain range?

I am not sure this is even possible with just using Movable Type tags but, how do I display random number with in certain range?
For example I have 10 images named 1~10 and every time I rebuild I want to display a random image from that range.
I use MT5.
Thank you in advance!
You can try my version of the MTCollate plugin with random filter. Original documentation is here: http://www.nonplus.net/software/mt/MTCollate.htm - difference is that it adds a sort="~" or "random" filter, but you'll probably be fine using the MTShuffleList block.
I think if you want to show one image and images count is ten, maybe you can show this cord.
<MTSetVarBlock name="imageID"><MTDate format="%S"></MTSetVarBlock>
<MTSetVarBlock name="imageID"><mt:GetVar name="imageID" op="div" value="6" sprintf="%d"></MTSetVarBlock>
<MTSetVar name="imageID" op="++">
src="/images/hoge<mt:GetVar name='imageID'>.jpg"
You can actually do this with PHP if you're so inclined. Movable Type supports the ability to publish to PHP and you can just put the content you want to be randomized inside of a PHP block. All you need to do is change the published archive file type to "php" in the blog settings. Here is the MTML sample:
<?php
$images = array();
<mt:Asset id="1">
$images[] = '<mt:AssetURL/>';
</mt:Asset>
<mt:Asset id="2">
$images[] = '<mt:AssetURL/>';
</mt:Asset>
<mt:Asset id="3">
$images[] = '<mt:AssetURL/>';
</mt:Asset>
$selected_asset = array_rand($images);
?>
Just repeat the Asset tag for each of the specific assets you want. That will generate ten operations to push each image asset's URL into the array. Alternatively, if you want to expose the last ten, you'd just to <mt:Assets lastn="10">

How to use an analyzer in compass-lucene search

How do I add compass analyzer while indexing and searching data in compass.I am using schema based configuration for compass.I want to use StandardAnalyzer with no stopwords.Because I want to index data as it is,without ignoring search terms like AND , OR , IN . The default analyzer will ignore AND , OR , IN from the data I give for indexing.
How do I configure snowball analyzer either thru code or thru xml. If someone could post me an example.
Below is the example. You can also find more details here
<comp:searchEngine useCompoundFile="false" cacheInvalidationInterval="-1">
<comp:allProperty enable="false" />
<!--
By Default, compass uses StandardAnalyzer for indexing and searching. StandardAnalyzer
will use certain stop words (stop words are not indexed and hence not searcheable) which are
valid search terms in the DataSource World. For e.g. 'in' for Indiana state, 'or' for Oregon etc.
So we need to provide our own Analyzer.
-->
<comp:analyzer name="default" type="CustomAnalyzer"
analyzerClass="com.ICStandardAnalyzer" />
<comp:analyzer name="search" type="CustomAnalyzer"
analyzerClass="com.ICStandardAnalyzer" />
<!--
Disable the optimizer as we will optimize the index as a separate batch job
Also, the merge factor is set to 1000, so that merging doesnt happen during the commit time.
Merging is a time consuming process and will be done by the batched optimizer
-->
<comp:optimizer schedule="false" mergeFactor="1000"/>
</comp:searchEngine>

Resources