Author Topic: Four Square  (Read 2322 times)

0 Members and 1 Guest are viewing this topic.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Four Square
« on: November 15, 2013, 12:41:58 PM »
So, this is a command that I have fun with when I'm bored. It's kind of a 'serendipitous discovery' tool for the virtual tourist, but you could also use it practically.

The basic idea is: "Four Square, find popular X in [city] Y." Phrasing of your choosing, natch.

Look up microbreweries, museums, sushi joints -- whatever makes sense in the Four Square context.

VC scrapes Four Square and provides the top-rated Four Square results for destinations that I might want to check out. It then asks if I want to see the Four Square map to find out more. Usually I do.

I happen to like libraries. This morning I was introduced to the Canada Water Library in south-east London via my whimsical Four Square query ("Find popular libraries in London"), after which I looked up the history of the Canada Water district etc. Neat discovery for a Canadian!

If this sounds incredibly lame and uninteresting to you, try asking your better halves what they want to look up in the fantasy destinations of their choice, and then give the old Four Square command a go.  ;)

For this command:

I'm using two payload lists in order to improve recognition. You could also use payloadXML of course. In my case, I should probably do that because there's a character limit on payload lists, so I can't include all the cities I might be interested in. This is the kind of thing where you'd want to customize the lists to your own interests (within limits of Four Square's likely content).

I also cloned the command and created a new group, in which I swapped in payload dictation for the payload lists, but I gave that group a lower priority. This means that VC first tries to listen for recognizable payloads from my prioritized command that relies on the lists, and only if it fails at that will it try the free dictation route.

You can change a group's priority by right-clicking on the group's icon and editing its properties: http://voxcommando.com/mediawiki/index.php?title=Groups#Group_Properties

Below is the xml for just the prioritized Four Square group (because I'm lazy).

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.3.1-->
<commandGroup open="True" name="FourSquare" enabled="True" prefix="" priority="3" requiredProcess="" description="">
  <command id="481" name="Open four square" enabled="true" alwaysOn="False" confirm="True" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Launch.OpenURL</cmdType>
      <params>
        <param>{Var.FourSquare}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Open four square</phrase>
  </command>
  <command id="490" name="Scrape" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>FourSquare</param>
        <param>https://foursquare.com/explore?mode=url&amp;near={2}&amp;q={1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Map.CreateTable</cmdType>
      <params>
        <param>FS_TopResults</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>https://foursquare.com/explore?mode=url&amp;near={2}&amp;q={1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>class="venueName"&gt;.*?&lt;a.*?&gt;(.*?)&lt;/a</param>
        <param>.  </param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Map.Set</cmdType>
      <params>
        <param>FS_TopResults</param>
        <param>{i}</param>
        <param>{Match.{i}}, {2}</param>
      </params>
      <cmdRepeat>5</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>class="venueName"&gt;.*?&lt;a.*?&gt;(.*?)&lt;/a&gt;.*?venueScore.*?title\="(.*?)\"&gt;</param>
        <param>.  </param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.MatchConcat</cmdType>
      <params>
        <param>.{CR}</param>
        <param>3</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.Replace</cmdType>
      <params>
        <param> - People</param>
        <param> people</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.Replace</cmdType>
      <params>
        <param>&amp;#39;</param>
        <param>'</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.Replace</cmdType>
      <params>
        <param>&amp;amp;</param>
        <param>and</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.Replace</cmdType>
      <params>
        <param>/</param>
        <param> out of </param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Top results: {CR}{LastResult}.</param>
        <param>10000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>The top Four Square results were: {LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.SpeakSync</cmdType>
      <params>
        <param>Would you like to see these on the Foursquare map?</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.TellVox</cmdType>
      <params>
        <param>Open four square</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Four Square</phrase>
    <phrase>Find popular, Find me, Name some, Give me some</phrase>
    <payloadList>restaurants,libraries,museums,pubs,microbreweries,pool halls,billiard joints,brunch joints,cafés,Thai food,Indian food,Chinese food,Italian food,French food,food,sushi,pizza,vegetarian restaurants</payloadList>
    <phrase optional="true">in</phrase>
    <payloadList>Amsterdam, Berlin, Brussels, Budapest,Chennai, Chicago, Copenhagen, Delhi, Edinburgh, Frankfurt, Geneva, Glasgow, Hong Kong, London, Manchester, Marseille, Montreal, Moscow, Mumbai, Munich, NYC, Oslo, Paris, Prague,San Francisco,Stockholm, Tokyo, Toronto, Van</payloadList>
  </command>
  <command id="626" name="Find out more" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Map.Get</cmdType>
      <params>
        <param>FS_TopResults</param>
        <param>{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Launch.OpenURL</cmdType>
      <params>
        <param>http://www.google.com/search?q={LastResult}&btnI</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Tell me more about, Find out more about, Google</phrase>
    <phrase>Four Square result number</phrase>
    <payloadRange>1,5</payloadRange>
  </command>
</commandGroup>

cheers

EDIT: I've updated this command group to include a new "Find out more" command. You can now do a Google lucky search for any of the top Four Square results. This uses VC's nifty maps feature. http://voxcommando.com/mediawiki/index.php?title=Maps

May 2014 edit: The Four Square site's html has changed since my initial post. I've updated the regex in the XML of the Scrape command above, so it should work again. This is something you may have to do periodically. If you're having trouble figuring out the regular expression pattern yourself, feel free to ask for help.
« Last Edit: July 08, 2014, 11:42:39 AM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Four Square
« Reply #1 on: November 15, 2013, 05:37:12 PM »
Wow.  There is a lot of good stuff in here.  I hope that other users will try this out and try to understand how it works.  Once you understand how to do this you will be able to accomplish many neat things.

Thanks Nime5ter for taking the time to post this.  ::bow

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Four Square
« Reply #2 on: November 15, 2013, 06:47:14 PM »
Yeah the one and only

VC-Queen

 ::bow
« Last Edit: November 16, 2013, 05:51:39 AM by Kalle »
***********  get excited and make things  **********

mdsh

  • $upporter
  • Sr. Member
  • *****
  • Posts: 127
  • Karma: 4
    • View Profile
Re: Four Square
« Reply #3 on: November 19, 2013, 02:21:31 AM »
Thank you very much for this post. I think this would be really good for a newbie like me to look at and try and understand the steps. I will try and do this ASAP .... Once ive set up my new vera lite and zwave gear.

Many thanks again