Nuget package for DBPedia Spotlight

Hi,

I have developed a small .NET wrapper for DBPedia Spotlight in order to facilitate the consumption of their web service. Once you’ve downloaded the package in your solution, you can easily use it the following way:

  static void Main(string[] args)
        {
            SpotlightRequestConfig cfg = new SpotlightRequestConfig(
                "Somme text", "http://spotlight.sztaki.hu:2222/rest/");
            cfg.AddFilterOnType(DBPediaTypes.Person);
            cfg.AddFilterOnType(DBPediaTypes.Place);
            ShowCandidates(cfg);
            ShowAnnotation(cfg);
        }
        static void ShowCandidates(SpotlightRequestConfig cfg)
        {
            SpotlightCandidateRequest req = new SpotlightCandidateRequest(cfg);
            SpotlightCandidateResponse resp = req.GetResponse();
            foreach (SurfaceForm resource in resp.annotation.surfaceForm)
            {
                if (resource.resource != null)
                {
                    foreach (SurfaceFormResource sr in resource.resource)
                    {
                        Console.WriteLine(sr.ContextualScore);
                    }
                }
            }
        }
        static void ShowAnnotation(SpotlightRequestConfig cfg)
        {
            SpotlightAnnotateRequest req = new SpotlightAnnotateRequest(cfg);
            SpotlightAnnotateResponse resp = req.GetResponse();
            if (resp.Resources != null)
            {
                foreach (SpotlightResource resource in resp.Resources)
                {
                    Console.WriteLine(resource.uri+" "+resource.types);
                }
            }
        }

The wrapper handles the annotate REST operation which performs disambiguation and NER. It also handles the candidates REST operation to get a ranked list of candidates. The wrapper converts the returned JSON into .NET objects that are easily exploitable in a .NET application. You can optionally filter NER on types, supportability and confidence.

I’ve also created a Github repository that is available https://github.com/stephaneey/Eyskens.Spotlight/

Happy Coding

Advertisements

About Stephane Eyskens

Office 365, Azure PaaS and SharePoint platform expert
This entry was posted in Open Source and tagged , , , . Bookmark the permalink.

One Response to Nuget package for DBPedia Spotlight

  1. Pingback: IBM Watson’s Conversation Service vs LUIS+Bot framework to build chatbots | Welcome to my blog! Stéphane Eyskens, Office 365 and Azure PaaS Architect

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s