In a previous post, I described how you could use the document viewer form of OpenCalais) at http://viewer.opencalais.com/) to enter text and use OpenCalais to generate semantic metadata from it. Of course, to create a tool in, say, PHP, it is in order to find some way to do the same thing from a script. From an example on the OpenCalais website, I found the proper syntax to call one of the OpenCalais functions to do so as follows:
http://api.opencalais.com/enlighten/rest?licenseID=YOUR_OPEN_CALAIS_ID&content="Princess Kate is married to Prince William of England."
The two URL arguments are licenseID (I used mine obtained for free from OpenCalais) and the content to be analyzed (my example shows just a small amount of text). What is returned is a daunting amount of RDF data. and below is just a snippet of semantic data that illustrates what OpenCalais generated (including William's nationality):
<rdf:Description rdf:about="http://d.opencalais.com/pershash-1/b4a543bb-34d6-355f-81e5-1f0fb83e1111">
http://api.opencalais.com/enlighten/rest?licenseID=YOUR_OPEN_CALAIS_ID&content="Princess Kate is married to Prince William of England."
The two URL arguments are licenseID (I used mine obtained for free from OpenCalais) and the content to be analyzed (my example shows just a small amount of text). What is returned is a daunting amount of RDF data. and below is just a snippet of semantic data that illustrates what OpenCalais generated (including William's nationality):
<rdf:Description rdf:about="http://d.opencalais.com/pershash-1/b4a543bb-34d6-355f-81e5-1f0fb83e1111">
<rdf:type rdf:resource="http://s.opencalais.com/1/type/em/e/Person"/>
<c:name>William</c:name>
<c:persontype>political</c:persontype>
<c:nationality>British</c:nationality>
<c:commonname>William</c:commonname></rdf:Description>
Also, an online form can be implemented to use this OpenCalais API call, using the following HTML:
Again, for the licenseID, use one obtained for free from OpenCalais. For content, provide the data that you want to derive semantic metadata for. For paramsXML, it can be left empty, or filled in with something as described at http://www.opencalais.com/documentation/calais-web-service-api/forming-api-calls/input-parameters).
This RDF translates into the following graphical metadata shown below when you enter "Princess Kate is married to Prince William of England." in the text field of the OpenCalais document viewer form:
Also, an online form can be implemented to use this OpenCalais API call, using the following HTML:
<html>
<head>
<title>Calais test page</title>
</head>
<body>
<form action="http://api.opencalais.com/enlighten/rest/" method="post"
accept-charset="utf-8">
licenseID: <input type="text" name="licenseID" />
<input type="submit" /><br />
content: <br />
<textarea rows="15" cols="80" name="content" ></textarea><br />
paramsXML: <br />
<textarea rows="15" cols="80" name="paramsXML" /></textarea><br />
</form>
</body>
</html>
The form looks like this:
No comments:
Post a Comment