Comparing NLP APIs for Entity Extraction

Update: a number have people have pointed out some small errors and some additional APIs that I should look at; until I get this post updated, please check out some of the great user comments at the bottom

As part of a project I’m working on (more on that later), I wanted to be able to take some text (probably in the form of a web page) and get a list of the important entities/keywords/phrases.

It turns out that there are actually quite a few companies that offer a service like this available freely (at least somewhat) through an API, so I set out to try them all out and assess their quality and suitability for my project. Most of these APIs are provided by companies that do various things in the NLP (natural language processing) realm and/or work with large semantic datasets. Many of the APIs provide a variety of information, only some of which is the set of entities that I’m looking for, so they may have good features that are excluded from my narrow comparison.

Using the APIs

To evaluate the APIs I wrote a script to make use of each one (scroll to the bottom to see it in action). They were fairly similar but the code to handle each one is slightly different. In many cases they offered multiple response formats but I opted for XML for each of them which made things simple enough, and I got used to using SimpleXML in PHP. The main difference between them all is simply the XPath expression needed to pick out the entities. For each API I grab the entity, any available synonyms (minus some de-duplication), and the self-reported relevance score for that entity, if available. If not already sorted by that relevance, I sort them.

An additional issue was that although most of the APIs accepted a URL as input, some required the actual content, in either HTML or plain text. When accepting content from a web page, the service needs to be smart about ignoring web navigation, ads, etc. when determining what is important, and they vary in ability to do that. Alchemy (one of the APIs tested here) also has a web page cleaning API which can be accessed on its own. Results from the Yahoo API were of such low quality that I actually ran the input web page through the web page cleaning API before sending it to Yahoo, and it is those results which are evaluated here.

Most of the analysis here is based off a sample of eight web pages including Wikipedia articles, news articles, and other pages with a lot of text content from a variety of subjects. I have not yet done any analysis of how the quality of the response for each API is affected by the length of the input document.

The APIs

The APIs I tested were, roughly in order of increasing quality,

Comment on this post to let me know if I’m missing any.

API terms

Most APIs today have limits on both how much they can be called, and what you can use them for. Here they are ranked roughly by “most usable terms and limits” to least:

Evri
Currently no API limit; essentially no requirements
AlchemyAPI
30,000 calls per day (although more may be available); commercial use is definitely okay
OpenCalais
50,000 calls per day, 4 calls per second; one must display their logo as-is; if you are syndicating the data it needs to preserve their GUIDs; see details
BeliefNetworks
2,000 calls per day, 1 call per second; essentially no requirements
Yahoo
5,000 calls per IP per day; non-commercial use only
OpenAmplify
1,000 “transactions” per day; note that one call is 1-4 transactions depending on the input type and whether you want all or a subset of the output; commercial use is definitely okay

Please note the standard I-am-not-a-lawyer and that this is just a summary. Please read the terms of service yourself.

Languages

Although my project is English-only for now, ideally there would be support for other languages. All the samples I used were in English so that is what is being used to evaluate the quality, but here is the full list of what languages each API claims to handle:

Yahoo
English
OpenCalais
English, French, Spanish
BeliefNetworks
A white paper on their website claims that their technology can support multiple languages, but most likely only English is currently supported
OpenAmplify
English
AlchemyAPI
English, French, German, Italian, Portuguese, Russian, Spanish, Swedish, however some important features are only available for English
Evri
English

I have not done any research into similar APIs which are not available for English at all, but if you find one, please let me know and I’ll make a note of it here.

The response from OpenAmplify and AlchemyAPI will also include the language of the input document. For AlchemyAPI this includes 97 languages, not just the ones that the API can handle. If you’re just looking for good language identification, there are other resources for that, some open source. My ancient Language Identification page still has some useful links there.

Number of Entities and Relevance Scores

For the purposes of my project, I see the APIs which return more entities from the document to be more useful, all else being equal. BeliefNetworks allows you to specify the number of entities returned (supposedly up to 75 but it actually returns 76), and as such always returns that number, which is almost always more than any other API. Yahoo returns up to 20 entities (which isn’t documented), which is often the least of any API. Here I list the APIs sorted by number of entities returned from most to least:

  1. BeliefNetworks
  2. AlchemyAPI
  3. OpenAmplify
  4. OpenCalais
  5. Yahoo
  6. Evri

There are a couple of important caveats here, however. This is based off of a very small sample, so other than BeliefNetworks returning the most, the list could be off. Beyond that, OpenCalais has a fairly small limit on text length (100,000 characters, presumably including the HTML tags) and if the input is too long, it returns no entities at all, just an error message. The ranking above excludes those examples. OpenAmplify has a limit of 2.5K, however they just truncate the document instead of failing (although this counts as an additional “transaction”). Oddly, Evri returned an error of “rejected by content filter” for this news article and returned no entities. Evri’s ranking in the list above is unchanged with or without the inclusion of that example.

Relevance Scores

All of the APIs, with the exception of Yahoo’s, include some metric with each entity rating its relevance to the input document. This is important as every user of any of these APIs would most likely want to establish a minimum relevance threshold for actually making use of the entities. The number of entities comparison above is based on no threshold at all; obviously changing the threshold would affect the comparison. AlchemyAPI and OpenCalais use scores from zero-to-one, however Evri, OpenAmplify, and BeliefNetworks have their own scale. I haven’t yet done any work to normalize all these scores and I think that most likely the best practice would be to independently determine your own threshold on a per-api basis depending on your own needs.

Semantic Links

By semantic links I simply mean that the entities returned have some sort of links or references to additional information about those entities. Although not necessarily required for my project, this may be very useful. Two of the APIs, Evri and AlchemyAPI include this information when they successfully map a found entity to an entity in their own database. Evri provides a reference to the entity in Evri’s own system, whereas AlchemyAPI links to a variety of other sources: the website for the entity, Freebase, MusicBrainz, and others.

In addition to or instead of these semantic links, Evri, AlchemyAPI, and OpenCalais have their own systems of classification and label entities with things like “Person” and “Religion”. See Evri’s most popular ‘facets’, AlchemyAPI Entity Types, and OpenCalais: Metadata Element Simple Output Value for specifics of each. OpenAmplify is even more basic but provides broad categories such as “Locations” and “Proper Nouns”, and entities may be listed in more than one of these broad categories. Yahoo and BeliefNetworks provide no additional context.

Additional Information

Some of these APIs provide a wealth of information that I disregard entirely but could be useful to others. For example Amplify returns a lot of information about the sentiment being expressed about each entity, information about the person who authored the document (e.g. gender, education), the style of the document (e.g. slang usage), and actions expressed within the document. OpenCalais also extracts events and facts from a document, as well as other details per entity such as the ticker symbol for entities which are public companies. AlchemyAPI can extract quotations from the document. Note that this is a summary and not a complete list of all the data that these APIs return.

Synonyms vs. Duplicates

The better APIs here, at least as far as I’ll be using them, succeed at recognizing that “Smith” referred to throughout an article is the same as “John Smith” mentioned in the first sentence. I want duplicates minimized, and for each entity to have as many valid names/synonyms as possible. The APIs differ here significantly.

Evri is definitely the best, followed by AlchemyAPI. Unfortunately AlchemyAPI sometimes misdisambiguates (ooh, no results on Google or Bing for that word yet) which results in incorrect synonyms, however that isn’t a huge problem for me. An example is the article I referred to earlier where AlchemyAPI confuses a Canadian military unit for the British monarch it was named after. Yahoo and OpenCalais fall into the middle. OpenAmplify and BeliefNetworks have a fair number of unmerged duplicate entities. For my purposes, I don’t care if the synonyms come from the input document or an external database, which is what Evri and AlchemyAPI probably use.

Taking a look at each API

Yahoo

This was the only API that I was aware of until recently, and I’ve blogged about it before. The input format is plain text, so since I’m using URLs as input, I have to first extract the text, strip the HTML, and send that. As I mentioned above, the quality was so poor when using web pages as input that the text must first be scrubbed of web page navigation, etc., and I used AlchemyAPI to do that. Even then, the quality was still poor and the API returned things that I would describe more as long phrases than as entities. Given that, not to mention the maximum of 20 entities, and the non-commercial restriction, I don’t see myself making use of this API.

OpenCalais

This API also accepted content rather than a URL. The content format must be specified in the API call. I simply retrieved the URL, and passed all of its content (with HTML) on to OpenCalais. They suggest making sure to remove web page navigation, but without me doing this, that didn’t present a problem. What was a problem was the short maximum document length. To actually use OpenCalais you should make sure to truncate documents before making the request, which is work that I haven’t yet implemented myself. Even when results were returned, the overall quality was mediocre.

The default output format is RDF, which is very verbose and includes a lot more information than I needed. I opted for the Text/Simple format which is actually XML.

For free API users sometimes the response comes back as “server busy” and I experienced this myself sometimes while trying it out.

BeliefNetworks

This API has a simple output, and is somewhat unusual in its functionality. Unlike all the other APIs, where the entities are extracted from the input document, with BeliefNetworks it seems they find entities which are related to the document but not necessarily actually in it. This produces some interesting results that are sometimes good but overall less related than I’d expect, and in one of my examples, completely unrelated and bizarre. Given that, and the frequency of duplicate entities, as mentioned, I would describe the overall quality as mediocre, although usually better than OpenCalais.

OpenAmplify

The most notable feature of OpenAmplify is all the additional information they provide, as described above.

They take input either as a URL or the content itself, and “charge” an additional transaction if you call them using a URL. I used URL input but also tried submitting the HTML, submitting the text (HTML stripped), and submitting the text after putting through the AlchemyAPI web page cleaning, and in all cases the results were about the same or worse.

OpenAmplify notes that they may not be able to follow all URL redirects (although I didn’t test this with any of the APIs), but this issue can be avoided by following the redirects yourself before making the request. As mentioned earlier, they only look at the first 2.5K of input. They also accept RSS/Atom as input, which is a nice feature.

Although I’ve set up my script to remove duplicates it currently misses removing some duplicate entities from OpenAmplify as the entity may be listed several times in the response but with different relevance scores.

One problem I found was that the entities returned usually consisted of a single token (one word) which just made them less useful. Overall, the quality was okay, generally better than BeliefNetworks.

AlchemyAPI

Other than the occasional misdisambiguation, AlchemyAPI is quite good.

Evri

Evri’s API is also quite good, with the biggest flaw being that it doesn’t return very many entities.

Overall Quality Summary

Overall, Evri and AlchemyAPI were definitely the best and most suited for my purposes. The quality of Evri’s was the best across the small sample, although not in all instances, and it didn’t return as many entities as AlchemyAPI. Interestingly these two APIs are also the two which include semantic links and have the least restrictions and high API limits.

OpenAmplify and BeliefNetworks are the runners up. OpenCalais fared poorly in my evaluation, but I suspect it would do better when looking at all the rest that their API. Yahoo’s API unfortunately just wasn’t good enough to use when any of the other APIs are available.

I’m convinced that trying to build a similar service myself is not worth it at all. One thing that I haven’t tried yet is combining these APIs together in some way, although that could potentially improve the results quite a bit.

You can see the script in action (until I take it down) at http://faganm.com/test/get_entities.php?u=[any URL].

Term Extraction Documentation for Yahoo! Search Web Services - YDN

Yahoo!’s Term Extraction Web Search is about to be discontinued. very sad

wait, nevermind

contact management

so the problem of contact management is the opposite of new, and a lot has improved in recent years, but things still aren’t working for me

my contacts are split like so

primary list of contacts: Gmail. Auto-adding of addresses to the the list is usually good, but I wish it was easier to purge people with who I exchanged one email a long time ago (subject to manual confirmation).

secondary list of contacts: Pidgin. the great instant messaging software includes all my contacts on MSN/WL messenger (including my old account), Gtalk, Yahoo, AIM, ICQ (admittedly virtually unused now). while most of these protocols store the contacts server-side, I have manually combined multiple accounts of the same people, and this is stored in a local XML file. I wrote an XSLT a year or two ago which converts the XML to CSV which can be imported into Gmail. Of course, it is imported manually, doesn’t really deal with Gmail-Pidgin duplicates, and of course lacks the avatars which aren’t stored in the Pidgin local file to begin with.

secondary list of contacts #2: Facebook. Facebook makes for pretty nice contact management, but it is largely a walled garden. For one thing, email is preferable for non-trivial conversation (email works well, isn’t closed, can be better archived and searched, etc.). Facebook makes the process for emailing someone as (1) find their profile (2) find their email in an image and retype (not copy-paste) it into my email application. Ugh. Facebook does have excellent metadata, and importantly, everyone manages and keeps up-to-date their own data. Today I tried FriendsCSV, a Facebook application that converts your friends list to a CSV file which is nice, although they don’t violate Facebook’s terms, meaning of course that email address aren’t included. And thus importing into Gmail creates a million duplicates. The metadata can include the URL to their Facebook profile, but Gmail contacts don’t even support URLs, so the URL is plain text.

tertiary list of contacts: Skype. As I have never yet had a cell phone, I use SkypeOut as my “phone” and so it contains actual phone numbers (in addition to some Skype contacts), a piece of metadata which is largely absent from my other contact lists, but also quite important. Apparently Skype’s own export function doesn’t include SkypeOut contacts, which makes things fairly useless.

There are also various contacts spread out in LinkedIn and many other websites, but few that aren’t also in the previously mentioned lists.

Of course, now that I have a mobile device (currently an iPod Touch, although I will probably be switching this for a cell phone by August), I want to get the data on there, especially phone numbers, since that is the data I will need when I don’t have Internet access. So my current workflow looks like this

  1. periodically prune Gmail contacts
  2. periodicially import (and then prune) contacts from Pidgin->XSLT->CSV and Facebook->FriendsCSV->CSV
  3. periodically delete Windows contacts, and then readd them all by importing the contacts exported from Gmail
  4. synch my iPod, fortunately done automatically when charging

Of course, the iPod Touch has a great visual interface, rendered useless by the fact that contacts imported from Gmail through CSV won’t include Gmail’s avatars (and certainly not ones that failed to get imported from Pidgin and Facebook).

One big problem with this is all the manual pruning that is necessary, and largely incomplete, thanks to all the duplicates created. And let’s not even get into the problem that I have many contacts that I don’t know about because they are people who I exchanged email with before Gmail, and will be useless until I import the old emails into Gmail that were on Outlook Express and are now in that format on an external hard drive…

Google now has a Contacts API and Microsoft has their Windows Live Contacts API, although the latter is decreasingly useful as people migrate off Hotmail/MSN to Gmail/Google. And I don’t want to write the apps using the APIs, I’m lazy and want other people to do it.

Plaxo is supposed to be my saviour, synching things across everywhere, keeping data up to date, deleting duplicates, etc. If I pay of course (what?? pay for software?). I wonder if it is worth it…

I want the future now, dammit.

Why Facebook Shouldn’t Fear OpenSocial

Why Facebook Shouldn’t Fear OpenSocial - I’m supposed to be studying, so of course it’s a good time to do some blogging.

Anyhow, I agree with Josh that the idea that the competition now being Facebook vs OpenSocial is silly. Facebook is doing an absolutely amazingly fantastic job pleasing users, developers, being innovative, and soon, generating profit. Their upcoming “Beacon” plans seem as brilliant as their previous ones. The only bad thing I have to say about them (from a business perspective), is that they have been way to slow getting their advertising products out. In the long run, that may not make much difference.

OpenSocial is not competition in any sense of the word. It’s just a little specification to standardize some web services, which is a good thing. And assuming it gains the traction it is expected (the supporters actually follow through), then Facebook will just join it too, and they haven’t lost anything, really. In fact they’ll have gained additional developers and applications.

Facebook would have to be really stupid to act any other way, and from what I’ve seen, they are anything but. Except their HR, I’m not so in love with that.

Is it just me, or is MySpace sitting on their laurels? Just copying Facebook isn’t going to do it, and besides, they don’t seem to be copying them very well or quickly. I thought being the major player was supposed to count for something, like having resources.

One last comment on OpenSocial… while it is certainly good for developers that there will be a common API, let’s not forget that this simply means it will be easy to have an application run on multiple websites… separately. Having an application that seamlessly uses more than one social website simultaneously will still be an enormous headache. So there’s plenty more to be done there.

Update Nov 5. After reading a few things elsewhere, maybe myspace isn’t doing nothing, they just decided to let Google deal with all their advertising, and hope to make enough from that. But since that will likely be almost all of their revenue, might that not be a bad idea?

Popfly

Popfly - I heard about this first though email, but it’s all over the web as well. Microsoft has done an amazing job of making it really easy to combine web services, and I only hope that the output itself (something in an iframe?) is just as web malleable as the services it uses.

SmugBlog: Lifetime free Pro accounts to developers

SmugBlog: Lifetime free Pro accounts to developers - now that is a smart idea

Google Code - Updates: New GData API: Google Base

Google Code - Updates: New GData API: Google Base - two of my biggest hopes - Google opening up Google Base, and more wide adoption of APIs based around OpenSearch - all at once. This could be big.

Google Data APIs Protocol

Google Data APIs Protocol - interesting move from Google. I (and others) have thought for a while that combining OpenSearch’s read capabilities with the Atom Publishing Protocol’s write capabilities would create a very powerful API, and that’s roughly what Google is doing here.

It’s great to see the OpenSearch support (a bit - they’re using startIndex, totalResults and itemsPerPage), but I’d like to see them using it more. Some of what they’re doing is contrary to how OpenSearch works (that’s not a problem per-say), as they’re using predefined query names such as q and max-results (and a folder for categories) rather that allowing people to use whichever they want and then specify them in an OpenSearch Description file.

In that same vein, it would be nice to see them make use of autodiscovery, as Atom, RSS, OpenSearch, and others do. Upon first inspection I would say these autodiscovered documents could be OpenSearch Descriptions, but I may be wrong about that.

One interesting thing to note is that they mention how startIndex is 1-based (which is true), and then display an example with a value of “0″. Sounds like DeWitt is right, it does need to handle 0-based numbers too; even Google is making that mistake.

DeWitt brings up some other good points as well.

Via Niall.

Update: Joe Gregorio weighs in

Update 2: Marc Canter (one of my favourite bloggers) finds this linkworthy ;-) although I’m always amazed at the spellings my name gets.

Google Toolbar API - Guide to Making Custom Button

Google Toolbar API - Guide to Making Custom Button - aaaargh. I see Google’s recreated the OpenSearch Description format. Nice job guys. Oh yeah, and it also functions as an RSS feed information thingy…. which as far as I can tell, only provides refresh rate…. if they need that so badly they could make that element an extension to RSS/Atom.

It seems like Google’s attitude nowadays is “developers like APIs, and they like XML, so lets create lots and lots of little tiny APIs and new XML formats.” How about a new search API, like for images. The web search API was last updated years ago… . Oh, in case we’re counting, Google now has created XML formats for sitemaps (but they accept RSS and Atom, so what was the point?), homepage modules (why not use HTML, as I’ve written before?), “buttons” (Google Toolbar), 50 (exaggeration) kinds of microcontent (Google Base), etc.

More later when I get back from school and have time to look into this more fully.

Why is the Google Homepage API not HTML?

Someone please explain to me why the Google Homepage API is a small XML format that includes an HTML bit, instead of just HTML itself?

Okay, so they introduce a few bits of meta data. The links, such as screenshot can be handled by <link /> with rel=”screenshot” and such. The other bits of data can be handled by <meta />, except for the title… there’s already one of those in HTML ;-)

Note that I haven’t taken a good look at any of the Microsoft Live Gadgets, Google Sidebar API, Yahoo! Widgets (Konfabulator), or Dashboard.

From metasearch to distributed information environments

From metasearch to distributed information environments (Lorcan Dempsy) is a good overview on metasearch in the academic enviroment, and search/metadata APIs.

I looked at a number of the documents, including the first two PowerPoint files and the information on MXG. All worth looking at.

In terms of meta/federated search, those schools (first two PowerPoints) are definitely making leaps forward. The commercial and academic worlds are beginning to learn from each other. The improvements are great, but need to be much greater.

The MXG (.doc file) proposal looks to me like an attempt to make a simpler but not as great version of SRU, which tried to do the same for Z39.50. Which is good news, the authors seem to have the right attitude. I also like how they’ve made levels of the specification, each of which is more complicated, and thus closer to SRU (that last is SRU).

If I were them I’d think hard about OpenSearch. It is a much simpler specification (clearly not originating from the academic world) which accomplishes less than even MXG Level 1. But not that much less, considering how much easier it is to use.

One specific thing that OpenSearch does that the other specifications don’t, is allow search engines to use their own URL variables instead of predefined ones. It looks fairly trivial to me for this concept to be integrated into the SRU/MXG specifications.

Back to academic ‘multi’ search tools, there is UWhub, my personal project. Right now it does web search and image search (just added that this week), but I would definitely like to expand this to include searching within the school’s library, among other things.

Google Maps API

Google Maps API - finally, and thank goodness. I haven’t looked at the API yet, hopefully it still leaves a place for Mikel’s fantastic worldKit. Via Google Blog.

Update later June 29: also today, the Yahoo! Maps Web Service. All because it’s the beginning of the Where 2.0 conference. I’m still not sure how I feel about the industry practice of launching things to coincide with conferences…