Project DescriptionThis .NET 3.5 class library provides a wrapper for the Calais web service.
Calais allows you to automatically annotate your content with rich semantic metadata, including companies, cities, industry terms and people.
This is a work in progress. If you have any problems or ideas for improvements please let us know :D
Calais v4 Support
Please check the 'CalaisDotNet-v4Support' branch for code supporting version 4 of the web service.
It's not all there yet but all the new entities and types have been added but there is no support for French at this time.
Please report any bugs or weirdness. Once all new features are supported we will do a new release.
Project Information
Read more about Calis at
http://opencalais.com/Step 1Get a Calais API key
hereStep 2Add Calais.NET to your project.
Step 3Use the Calais.NET API to extract metadata from your content.
Example// Get some contet to process
string content = (new WebClient()).DownloadString("http://news.bbc.co.uk/");
// Pass in the content as a string and also your calais API key
var calais = new CalaisDotNet(apiKey, content);
// Tell calaisdotnet what output format you want to work with (ie CalaisSimpleDocument / CalaisRdfDocument / CalaisJsonDocument etc)
var document = calais.Call<CalaisSimpleDocument>();
// Output the raw response from the web service
Console.WriteLine(document.RawOutput);
// Organize Entities in various ways (ie Relevance)
var sorted = from item in document.Entities
orderby item.Relevance descending
select item;
foreach (var entity in sorted)
{
Console.WriteLine(entity.Value + " / " + entity.Type + " / " + entity.Frequency + " / " + entity.Relevance);
}
RDF Examplevar calais = new CalaisDotNet(apiKey, content);
// Tell calaisdotnet you want to work with RDF output
var document = calais.Call<CalaisRdfDocument>();
// Output the raw response from the web service
Console.WriteLine(document.RawOutput);
// Filter entities by type (ie Country)
var results = from item in document.Entities
where item.EntityType == CalaisRdfEntityType.Country
select item;
foreach (var result in results)
{
Console.Write(result);
Console.WriteLine(" (Freq: " + result.Instances.Count() +")");
}
// or you can filter based on entity relationship
var moreResults = from item in document.Relationships
where item.RelationshipType == CalaisRdfRelationshipType.PersonPolitical
select item;
foreach (var result in moreResults)
{
Console.Write(result.RelationshipType + ": " + result);
Console.WriteLine(" (Freq: " + result.Instances.Count() + ")");
}