How to get started
How to get started
Posted on: Sat, 10/11/2008 - 05:31
Hello. I'm a senior Computer Science major and I'd like to use Calais in my senior project. However, I've never worked with an API like this before and I'm finding it difficult to find examples for basic programs. How do I call the Calais service in my code? Where can I store the tagged data? It doesn't seem well-organized for the novice programmer, and I could really use some help.

Comments
Thank you. This code has been useful for helping me get started. I now understand how to get the Calais data out of a String I pass in. But it's difficult to read, and I don't understand how the Json class works (for example, what are all the other constructors besides the API key?). Plus, I'd ideally like to get it into the HTML form demonstrated by the SemanticProxy demo (http://semanticproxy.opencalais.com/demo.html), but as I'm unclear as to exactly what the Json class is doing, I don't know how to abstract that to HTML.
Hi,
As for HTML view - please look at this post: http://www.opencalais.com/node/5898. You can also try to use the Document Viewer HTML and JavaScript + CSS - http://sws.clearforest.com/calaisViewer/.
As for JSON. We have a new direct JSON interface. Please see: http://www.opencalais.com/json.
Hope this helps.
Ofer
The Geotagging application is good, and thanks for it, but I'm looking to develop a desktop application. As a result, I'd like to see code examples of how Java can parse a text using OpenCalais.
Hi,
Here are few code examples you can use:
http://opencalais.com/REST
http://opencalais.com/node/5033
http://opencalais.com/node/1578
And other here: http://opencalais.com/OfficialGallery
Please make sure you read the documentation in http://opencalais.com/calaisAPI.
Can you share with us what are you trying to do? We may be able to help.
Tx,
Ofer
I've found the API difficult to understand - it doesn't seem to show basic examples, like exactly how to put Calais functionality into your program. The examples you linked me to looked useful, but I don't know what language they're in. In terms of Calais functionality, I have some questions: Do you link to a website in order to use it in your program? Or is there a class? What format does the text being read in have to be in? What format is the output? Can you manipulate the different categories that things are tagged as, or add your own? In fact, it would be nice to have some idea of exactly how Calais is doing what it's doing: is it more algorithmic based (trying to figure out words in context) or more database-based (it compares what it reads to entries in a database)? That will affect my project. My project, by the way, is to create an application that will link with the Freebase (http://www.freebase.com/) site: to run Calais on a document and then automatically upload it to the corresponding entry in Freebase, or else create a new one if none exists.
Open Calais does not link to web sites. It receives all the document through the API and processes it.
Please see the http://www.opencalais.com/ResponseFormats for output formats and for input formats - look in http://www.opencalais.com/APIcalls under FORMATS.
Hope this helps.
Thanks,
Ofer
Jeremy,
You might also want to look at the Calais thread on the Drupal website (www.drupal.org), where a number of Calais developers and users have posted their insights.
Regards,
Jeremy -
Take a look at this Gallery entry, posted only recently: http://www.opencalais.com/node/8314. Guilhem's website offers a very clear explanation of how he incorporated Calais in a geotagging application. A number of other applications in the Gallery may also provide insight.
Regards,
Can I see some Java code laid out like that for a desktop application?
You can take a look at http://www.opencalais.com/node/1229. Download the attachment and look inside calaisjson_java_dist.zip under src.
One class that might help you is CalaisJavaIf (com.clearforest.calais.common.CalaisJavaIf). You create an instance of this class by providing the API key, which you obtained in registration:
CalaisJavaIf calaisIf = new CalaisJavaIf("123456");
Then you can call the method callEnlighten() passing the text you'd like to have analyzed:
calaisIf.callEnlighten(some text...);
This method calls the Calais Web service and returns the results from the Web service.
Another useful class is CalaisJSONIf (com.clearforest.calais.full.CalaisJSONIf). You probably don't need its functionality (it converts the output from RDF format to JSON). But you can take a look at this class for an example of how to parse the response returned by the Web service and extract the information from it. In particular the inner class ContentHandler, which does the actual parsing.
This is not a desktop application, but it's just Java code and you should have no problems using it within a desktop application.
Regards,
Shai Dagan
Thank you. This code has been useful for helping me get started. I now understand how to get the Calais data out of a String I pass in. But it's difficult to read, and I don't understand how the Json class works (for example, what are all the other constructors besides the API key?). Plus, I'd ideally like to get it into the HTML form demonstrated by the SemanticProxy demo (http://semanticproxy.opencalais.com/demo.html), but as I'm unclear as to exactly what the Json class is doing, I don't know how to abstract that to HTML.