Jump to content

Wolfram|Alpha workflow


Recommended Posts

I converted David Ferguson's Wolfram|Alpha extension to a workflow (and made some tweaks along the way  ;))

 

It requires you have an AppID of your own (get one here). Note: Make sure you wait a few minutes before entering the code; Wolfram|Alpha's servers seem to take a moment to register the AppID.

 

It provides feedback with the answer and input interpretation. If you action an item, it will output all the available information to Growl. Pressing ⌥↩ will copy the answer to the clipboard; ⌘↩ will open your query in Wolfram|Alpha (in the default browser).

 

Here's a picture of the workflow editor:

Wolfram%7CAlpha-Workflow.jpg

 

Here's what it looks like in action:

Wolfram%7CAlpha-Preview.jpg

 

Hope you like it! :D

 


 

Update (May 15, 2013): Fixed another bug that prevented saving of AppID

 

Update (March 5, 2013): Fixed bug that prevented the workflow from saving AppID on certain setups

 

Update (Feb 25, 2013): Fixed garbled text issues, added 'Selection is OS X' argument to hotkey

Edited by Tyler Eich
Link to comment

Hi there,

 

I can't seem to get the AppID to register. Every time I try to input the ID I get from the WA website it tries to validate and then keeps returning the message "xxxxx-xxxxxxxxx" Is Not A Valid AppID.

 

Anyone else having this problem? 

 

Yep, I'm having the same problem.

Link to comment

Just tried it with a new AppID; I tried it right away and it didn't work. I tried it again after about 3 minutes and it worked. It uses this code to validate the AppID:

$q = $argv[1];
$id = urlencode($q);
$xml_string = $w->request("http://api.wolframalpha.com/v2/validatequery?input=hello+world&appid=$id");

 

 

Try loading 'http://api.wolframalpha.com/v2/validatequery?input=hello+world&appid=YOUR-ID-HERE' in a browser. If you get an 'error=true' message, it's something on Wolfram|Alpha's side; maybe it takes a few minutes for the AppID to register.

 

Thanks!

Link to comment

This is a fantastic workflow! Has the potential to replace a bunch of others e.g. currency conversion, weather etc.

 

Is it possible to wait a very short amount of time after the last keystroke before string is submitted to wolfram? It seems to submit as soon as I start typing, but without allowing me to finish typing (even when typing pretty fast). This means that I waste time waiting for the results to come back from (obviously) unfinished queries before it gets to submitting the finished query. Try a currency conversion like "10USD in GBP" to see what I mean.

 

Ideally it would only submit if there haven't been any keystrokes in, say, the last 0.25 seconds.

Link to comment

This is a fantastic workflow! Has the potential to replace a bunch of others e.g. currency conversion, weather etc.

 

Is it possible to wait a very short amount of time after the last keystroke before string is submitted to wolfram? It seems to submit as soon as I start typing, but without allowing me to finish typing (even when typing pretty fast). This means that I waste time waiting for the results to come back from (obviously) unfinished queries before it gets to submitting the finished query. Try a currency conversion like "10USD in GBP" to see what I mean.

 

Ideally it would only submit if there haven't been any keystrokes in, say, the last 0.25 seconds.

I know exactly what you mean! I wish the script would run faster, too. Wolfram|Alpha is a bit sluggish, and launching the script with only a few characters is wasteful.

Right now, the workflow waits until at least three characters have been entered (as suggested by David Ferguson). I would love it if I could throttle the script, but I can't. Andrew might add a feature like this later on; it has been suggested by a few people (http://www.alfredforum.com/topic/535-throttle-script-filters/).

Thanks for the feedback, and I'm glad you like it! :)

Link to comment

I can't get this to work. I enter my AppID, alfred tells me it's saved and then when I invoke the command it keeps telling me to provide an appID. It's been this way for a couple days now so it doesn't seem to be an issue waiting for something on WA's end. 

 

Any ideas?

 

Could you check '~/Library/Application Support/Alfred 2/Workflow Data/tylereich.wolframalpha/settings.plist' and see if your API key is stored within? If you need help reading the .plist file, let me know ;)

Link to comment

Could you check '~/Library/Application Support/Alfred 2/Workflow Data/tylereich.wolframalpha/settings.plist' and see if your API key is stored within? If you need help reading the .plist file, let me know ;)

 

I don't even have the tylereich.wolframalpha folder. Even after deleting and reinstalling the workflow. When I log into the wolfram alpha dev site it says that there has been 4 queries on my appid. Odd. I'm not sure if this will help but it's caused a couple other Alfred related issues for me so far. My startup disk is on different drive than my home folder. Both internal drives but one SSD, one traditional. 

Link to comment

I don't even have the tylereich.wolframalpha folder. Even after deleting and reinstalling the workflow. When I log into the wolfram alpha dev site it says that there has been 4 queries on my appid. Odd. I'm not sure if this will help but it's caused a couple other Alfred related issues for me so far. My startup disk is on different drive than my home folder. Both internal drives but one SSD, one traditional. 

 

The queries on your AppID are probably from when the workflow validated your ID.

 

I'm not sure what could be causing your issue  :huh:. I deleted my tylereich.wolframalpha folder and it was immediately recreated when I launched the script. It could be an issue with David Ferguson's Workflows class, or with PHP itself, but I sincerely doubt either is at fault.

 

I doubt this will help, but could you try running the script from the terminal? Open Alfred's preferences > workflows, right-click the Wolfram|Alpha entry, 'Show in Finder', and locate the script called 'wolfram.php'. Open Terminal and type 'php -f ', drag 'wolfram.php' into Terminal to load its path, then type '-- "hello world"'. Hit enter and see what comes out.

 

If you need help, let me know  :)

Link to comment

The queries on your AppID are probably from when the workflow validated your ID.

 

I'm not sure what could be causing your issue  :huh:. I deleted my tylereich.wolframalpha folder and it was immediately recreated when I launched the script. It could be an issue with David Ferguson's Workflows class, or with PHP itself, but I sincerely doubt either is at fault.

 

I doubt this will help, but could you try running the script from the terminal? Open Alfred's preferences > workflows, right-click the Wolfram|Alpha entry, 'Show in Finder', and locate the script called 'wolfram.php'. Open Terminal and type 'php -f ', drag 'wolfram.php' into Terminal to load its path, then type '-- "hello world"'. Hit enter and see what comes out.

 

If you need help, let me know  :)

 

 

Here's what it outputs (assuming I ran it correctly): 

 

 

Usage: php [options] [-f] <file> [--] [args...]
       php [options] -r <code> [--] [args...]
       php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
       php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
       php [options] -- [args...]
       php [options] -a
 
  -a               Run as interactive shell
  -c <path>|<file> Look for php.ini file in this directory
  -n               No php.ini file will be used
  -d foo[=bar]     Define INI entry foo with value 'bar'
  -e               Generate extended information for debugger/profiler
  -f <file>        Parse and execute <file>.
  -h               This help
  -i               PHP information
  -l               Syntax check only (lint)
  -m               Show compiled in modules
  -r <code>        Run PHP <code> without using script tags <?..?>
  -B <begin_code>  Run PHP <begin_code> before processing input lines
  -R <code>        Run PHP <code> for every input line
  -F <file>        Parse and execute <file> for every input line
  -E <end_code>    Run PHP <end_code> after processing all input lines
  -H               Hide any passed arguments from external tools.
  -s               Output HTML syntax highlighted source.
  -v               Version number
  -w               Output source with stripped comments and whitespace.
  -z <file>        Load Zend extension <file>.
 
  args...          Arguments passed to script. Use -- args when first argument
                   starts with - or script is read from stdin
 
  --ini            Show configuration file names
 
  --rf <name>      Show information about function <name>.
  --rc <name>      Show information about class <name>.
  --re <name>      Show information about extension <name>.
  --ri <name>      Show configuration for extension <name>.
Link to comment

It took me a whlie to get this working but it's pretty awesome! However, I have noticed that there are sometimes display problems for what should be recognized characters. : http://i.imgur.com/IOFfSoX.png

Is there any way this can be fixed? Maybe the ASCII/Character encoding needs to be modified specifically for Wolfram?

IOFfSoX.png

 

Good catch! I went a little crazy with UTF8 encoding  :P

 

The original download link has been updated  :)

Link to comment
  • 2 weeks later...

I can't get this to work. I enter my AppID, alfred tells me it's saved and then when I invoke the command it keeps telling me to provide an appID. It's been this way for a couple days now so it doesn't seem to be an issue waiting for something on WA's end. 

 

Any ideas? 

  

I don't even have the tylereich.wolframalpha folder. Even after deleting and reinstalling the workflow. When I log into the wolfram alpha dev site it says that there has been 4 queries on my appid. Odd. I'm not sure if this will help but it's caused a couple other Alfred related issues for me so far. My startup disk is on different drive than my home folder. Both internal drives but one SSD, one traditional. 

These issues should be fixed now; check the original post for details :)

Link to comment
  • 2 weeks later...

Thanks for this workflow, but I'm having a problem with it. When I do a search, the results show up properly in the search window if I wait before hitting enter but whenever I press enter the Growl notification looks like this:

 

%202013-03-18%2011-53-19.jpg

 

I was really hoping to use it in the same way I used David Ferguson's V1 extension by simply entering the search, hitting enter and having the results appear in a growl notification.

It looks like your Growl is set to use Notification Center instead of a normal theme. One solution: disable Growl's use of Notification Center and use a normal Growl theme (my favorite is Mono by Christopher Lobay—http://beautifulpixels.com/macintosh/mono-growl-theme/).

If you want a better way to include Growl in NC, try Bark (http://barkplug.in/). I forget which apps use NC and which ones use Growl because Bark does such a good job integrating the two. Plus, you can decide which apps you want to appear in NC and which apps you want to use a normal Growl style for (like Alfred ;) )

Link to comment

Thank you very much for the quick reply, Tyler. I accidentally deleted my initial post. :(

 

That indeed took care of the problem!

 

As I mentioned, I am used to just entering my searches and hitting enter in the V1 extension. It seems the workflow requires the parsing of the search to be complete before hitting enter in order for the proper results to appear in the growl notification.

 

Is there any way around that?

Link to comment
  • 4 weeks later...

I have my own API, and I set it, but no matter what it always says that I never provided my appid..

 

Did you get a notification saying your Wolfram|Alpha ID had been set? If so, do you have a file called 'settings.plist' at '~/Library/Application Support/Alfred 2/Workflow Data/tylereich.wolframalpha/'?

Link to comment

Did you get a notification saying your Wolfram|Alpha ID had been set? If so, do you have a file called 'settings.plist' at '~/Library/Application Support/Alfred 2/Workflow Data/tylereich.wolframalpha/'?

Yes I did get a notification, and no I have a file that says settings.plist.plist

Link to comment

No matter what I do, I keep getting a notification:  Warning: Invalid argument supplied foreach( ) in /Users/msmith6869/Dropbox...

 

I use dropbox to syn my alfred prefs.  I have no file in the '~/Library/Application Support/Alfred 2/Workflow Data/tylereich.wolframalpha/' folder. Any ideas?

Link to comment

No matter what I do, I keep getting a notification:  Warning: Invalid argument supplied foreach( ) in /Users/msmith6869/Dropbox...

 

I use dropbox to syn my alfred prefs.  I have no file in the '~/Library/Application Support/Alfred 2/Workflow Data/tylereich.wolframalpha/' folder. Any ideas?

You aren't using the 'Dropbox/Apps/' folder for syncing, are you? That folder has some issues; the latest versions of Alfred don't let you use it because of that.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...