A Draft BSP Reference Service - Translation

Fernando Alvarez, who joined UC Berkeley's Bamboo team in April, has implemented a draft "reference service" to serve as an evolving model demonstrating how services to be deployed on the Bamboo Services Platform (BSP) will be architected. The service is a work-in-progress as this blog is written, but there are a couple of things worth pointing out even at this early stage.

First: it works. (Warning: the service is deployed on a development server that is subject to arbitrary change and down time; it may or may not be up when you read this news; and if you're visiting a long while after this post is published it may not be available at all. In fact, this blog is being published on the day that Google announced the service's backing API will be deprecated...)

The service is constructed as a proxy to the Google Language API. It accepts input in one language, and returns a translation into another.

The architecture to which this (initial, provisional) reference service conforms is described on the wiki page BSP Reference Service, which had its first airing at the Scholarly Services team meeting of 25 March 2011. The service's implementation code is still in a "sandbox" area of Bamboo's code repository, because it is in flux. Cf. https://source.projectbamboo.org/svn/btp/sandbox/alvarez/trunk/bsp/translation-service/.

Note that the steps involved in invoking the service are:

  1. Send an HTTP POST to the service, specifying source and target languages in the URL
  2. From the response returned by the service, obtain a URL for the translation result in the Location header
  3. Send an HTTP GET to the URL from the Location header (or just paste it into a web browser). The service will return the translation that is a result of your original POST.

Note that this workflow suggests how the "Result Set Cache" service will work once it is built – POST a resource that is created and can later be obtained via a GET. At present, this functionality is stubbed (that is, it's not working in a fully-developed, reliable way ... it won't even persist between bounces of the service container, on an instance of the FUSE ESB). Also, the value that the BSP will add in terms of identity and group management services is not yet implemented. As I said, this is an early draft ...

Here's how you can try the Translation Service at home. As the screenshots show, we're using Poster, a Firefox plugin, to test the service, but you can use the client of your choice so long as it allows you to set URL, content type, request body, HTTP verb, etc. The information you'll need (for copy-pasting or as a model) is in a table at the end of this post.

(Click the thumbnails to see larger images.)

Here is data you can use to construct the service request:

Request element

Value

URL

http://esb-d3.calnet.berkeley.edu:8181/cxf/bsp/translationservice/translations?source=fr&target=en

Content Type

application/xml

Body

<?xml version="1.0" encoding="UTF-8"?>
<tns:Translation xmlns:tns="http://org.projectbamboo/translationservice"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://org.projectbamboo/translationservice ../../main/resources/TranslationService.xsd ">
  <tns:description>A test</tns:description>
   <tns:sourceDocument>
    <tns:title>Foxtrot</tns:title>
    <tns:language>FR</tns:language>
    <tns:line>
      <tns:lineNumber>1</tns:lineNumber>
      <tns:lineContent>Longtemps, je me suis couché de bonne heure.</tns:lineContent>
    </tns:line>
    <tns:line>
      <tns:lineNumber>2</tns:lineNumber>
      <tns:lineContent>Parfois, à peine ma bougie éteinte, mes yeux se fermaient si vite que je 
        n'avais pas le temps de me dire: «Je m'endors.»</tns:lineContent>
    </tns:line>
  </tns:sourceDocument>
</tns:Translation>

HTTP Verb

Post

And the result:

<Translation>
  <status>Created</status>
  <self>
    http://esb-d3.calnet.berkeley.edu:8181/cxf/bsp/translationservice/translations/2011-05-27T07:29:40.062-07:00
  </self>
  <description>A test</description>
  <translator>Google Language API</translator>
  <translatedDate>2011-05-27T07:29:40.062-07:00</translatedDate>
  <sourceDocument>
    <title>Foxtrot</title>
    <language>fr</language>
    <line>
      <lineNumber>1</lineNumber>
      <lineContent>Longtemps, je me suis couché de bonne heure.</lineContent>
    </line>
      <line><lineNumber>2</lineNumber>
      <lineContent>Parfois, à peine ma bougie éteinte, mes yeux se fermaient si vite que je n'avais pas le temps de me dire: «Je m'endors.»</lineContent>
    </line>
  </sourceDocument>
  <targetDocument>
    <title>Foxtrot</title>
    <language>en</language>
    <line>
      <lineNumber>1</lineNumber>
      <lineContent>Long, I went to bed early.</lineContent>
    </line>
    <line>
      <lineNumber>2</lineNumber>
      <lineContent>Sometimes, just my candle, my eyes would close so quickly that I had no time to say: "I fall asleep."</lineContent>
    </line>
  </targetDocument>
</Translation>

Feel free to try different languages and to substitute your own input lines to be translated. Naturally, Project Bamboo can't take responsibility for the accuracy of translations, let alone their poetic resonance. What Google Translate provides is what you get... Apologies to Marcel Proust.