Wednesday, March 30, 2011

unintentional multilingual woes of a tool for computational linguistics

I stumbled upon the home page for a toolkit for those interested in various matters germane to computational linguistics while searching for information about Eclipse and 64-bit Windows 7 (how much conflict can one ask for?). If you know Hindi (or Marathi), you know why I had to leave my desk laughing when I saw the name of the toolkit (no pun intended there). Seriously!

offshore rush hour

I see a lot more of the kerfuffle at ramps and roads and badly synchronised traffic lights leading to the various interstates today. This could clearly be just a combination of the rains that have subsided, the time and the general preponderance of unscalable urban design. It could also be because a lot of people are rushing to work to get a few really productive hours, because their counterparts across the shores are busy watching the India/Pakistan cricket match today. No more phone calls laced with blather; no more nighmarish vistas of horrible code. Just some peace and quiet. Unless the gamesmen of the tricolour decide to emulate dominoes, of course.

Saturday, March 26, 2011

bing goes boing with axis2

If you've read posts hereabouts before, you know quite well how I feel about Axis2. You will understand, I hope, my lack of surprise at finding yet another piece of elegant congruence that Axis2 had wrecked by usurping the throne from ye olde Axis. Axis worked well with Commons HTTPClient and that library from the Apache Commons, like so many others, made life easier for a lot of developers. When Axis2 reared its ugly head from the sea of mediocrity and ambitious juvenile over-engineering, it made sure that this association was squashed. Here is how.

Have you ever tried using the Bing Maps web services using Axis? The curious aspect of these web services lay in how one had to request a token. This amounted to a request that used digest authentication instead of basic authentication. This was not such a problem if you had used ye olde Axis.

Unfortunately, you had moved into the future and had generated client code using the WSDLs and the tools in the JAX-WS RI. You then prepared to use this code atop the Axis2 JAX-WS stack (at which point you did not heed the pealing of alarm bells in the distance). Voila! The stack could do nothing for the first HTTP 401 response. There you were, in the middle of the ocean, staring at sharks as they discussed the latest episode of the hottest new sea soap opera, while waiting for a good time to transfer you to the dinner plate.

You had seen this code work with the standard Java Development Kit. Why was Axis2 being so different and difficult? You look at the code you wrote to use the generated client classes to see what you did wrong, to see if you had missed a step. You see the call to Authenticator.setDefault with the credentials. You know this is all you need to do. And yet.

Oh! goes your brain. Axis needed the Commons HTTPClient to help it with digest authentication. Surely, Axis2 could use Commons HTTPClient as well (after all, some of the developers on Axis2 had also committed code to Commons HTTPClient). You open axis2.xml and the first wave of horror hits you. The configuration already uses a class derived from Commons HTTPClient. The second wave of horror hits you almost immediately. They wrote their own middling class that left all the glory of Commons HTTPClient behind and treated it now as a messenger.

At this point, you hunt for something to hurt, wound, maim and dismember as you gnash your teeth.

Miraculously, Commons HTTPClient has a few tricks of its own and all you really need is the magic below.

import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScheme;
import org.apache.commons.httpclient.auth.CredentialsNotAvailableException;
import org.apache.commons.httpclient.auth.CredentialsProvider;
import org.apache.commons.httpclient.params.DefaultHttpParams;

    CredentialsProvider provider = new CredentialsProvider()
    {

      @Override
      public Credentials getCredentials(AuthScheme scheme, String host,
          int port, boolean proxy)
          throws CredentialsNotAvailableException
      {
        Credentials creds = 
           new UsernamePasswordCredentials("BingMapsUserName",
                           "BingMapsPassword");

        return creds;
      }
    };

    DefaultHttpParams.getDefaultParams().setParameter(
        "http.authentication.credential-provider", provider);

And that, as several not-so-famous people have said before, is all. You can get rid of Authenticator.setDefault(new AuthenticatorImpl("BingMapsUserName", "BingMapsPassword")). Don't forget to replace BingMapsUserName and BingMapsPassword with the values that you use. I'm sure you can figure that out. If you can't, you deserve to continue reaping the benefits of Axis2.

As soon as you find the right opportunity, walk away very slowly from Axis2. Go find something else that doesn't look like a school project.

Saturday, March 19, 2011

the king has not left the building

I love the cover of Full Dark, No Stars. I also like how it assures me that Mr. Stephen King has not cast off his writing cape and settled down into a chair to watch the sunset. A diet of Harlan Ellison seems to have eroded my ability to welcome and relish a large novel. I seem to prefer starting off with a few short stories before progressing to novellas. This might explain why Lisey's Story still stands unread on my bookshelf. This was despite the fact that Cell and Duma Key went back to the library shelves after I had read and enjoyed them, as did Under the Dome. Then again, Just after Sunset didn't work that well for me. It was as uneven as King's previous collections, but Full Dark, No Stars has changed all that. Perhaps this is because novellas seem to strike a good balance between short stories and novels. The four stories in this compilation contain all the elements familiar to fans of King's work -- 1922 mixes times of depression with an ode to Bonnie and Clyde and serves it up with elements from Poe. The story is narrated by Wilfred James, who confesses to and describes the murder of his wife. The narrative isn't as feverish as that of The Tell-Tale Heart and when the story is done, you may wonder if Mr. James was lying.

I had saved this novella for the end, but it was not a great way for me to end the collection. I should have tackled this right after my first pick, Fair Extension, where King explores the familiar Faustian bargain. Once Dave Streeter has signed the dotted line with George Elvid (hint: shuffle the letters in the last name), a cousin of Leland Gaunt, no doubt, King describes the unfolding of events like a long news story. It reminded me of Frederick Forsyth's The Art of the Matter.

Big Driver is the story of a woman who pays the price of taking a shortcut and then exacts her revenge. This is the stuff of EC comics with all humour of any kind stripped away. Rape is serious business and King makes sure every smile we crack is with Tess and never at her. The appropriate presence of films like The Last House on the Left and The Brave One is an Eastwoodian touch -- they do not beg to be treated as clever as they would have been in a Tarantino script.

A Good Marriage explores a good idea that I would imagine has been explored before (pointers welcome): imagine that you were the wife of someone like Mr. Brooks. Darcy Anderson discovers her husband's dark secret in a way that a character in a Stephen King story would and then tries to come to terms with it. King was inspired to write this story after the general public refused to accept that Paula Radar, the wife of Dennis Radar, the BTK killer, had been married to him for about thirty years and never knew anything about his evil deeds. The possibility is chilling as is the story.

Each story has a character killing someone (indirectly in Fair Extension) and ends with the character coming to terms with the deed, perhaps even being at peace after experiencing the moral conflict familiar to those who abhor violence. The writing is uncomplicated and boasts the ease, comfort and familiarity that King surely has come to enjoy after all these years. It's time to find a copy at a book sale and fill the spot once I (hopefully) manage to begin Lisey's Story.

 
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.