Open Calais Tags

Open Calais Tags is a PHP class for extracting entities and tags from text using Open Calais. Calais performs semantic analysis of the text, using natural language processing to identify concepts like people, companies and technologies discussed in the text. These are especially useful for suggesting tags for your content such as website articles or blog posts. You could even automatically tag archived content that would take days to go through manually.

You can download the class and example usage here:
PHP-OpenCalais.zip (updated 6/10/2015)

Calais is free for both personal and commercial use, and usage of this class requires a Calais API key. Getting an API key is an easy, automated process. Just click the “Access API” link at the site.

The Open Calais Tags class takes a document (text or HTML string) as input, and returns an array as output. The array’s keys are the entity types detected in the text, and the values are the entities found.

Example input:

April 7 (Bloomberg) — Yahoo! Inc., the Internet company that snubbed a $44.6 billion takeover bid from Microsoft Corp., may drop in Nasdaq trading after the software maker threatened to cut its bid if directors fail to give in soon.

If Yahoo’s directors refuse to negotiate a deal within three weeks, Microsoft plans to nominate a board slate and take its case to investors, Chief Executive Officer Steve Ballmer said April 5 in a statement. He suggested the deal’s value might decline if Microsoft has to take those steps.

The ultimatum may send Yahoo Chief Executive Officer Jerry Yang scrambling to find an appealing alternative for investors to avoid succumbing to Microsoft, whose bid was a 62 percent premium to Yahoo’s stock price at the time. The deadline shows Microsoft is in a hurry to take on Google Inc., which dominates in Internet search, said analysts including Canaccord Adams’s Colin Gillis.

Example output:

Array
(
    [Industry Term] => Array
        (
            [0] => Internet
            [1] => software maker
            [2] => Internet search
        )
    [Person] => Array
        (
            [0] => Steve Ballmer
            [1] => Jerry Yang
            [2] => Colin Gillis
        )
    [Company] => Array
        (
            [0] => Google Inc.
            [1] => Canaccord Adams
            [2] => Yahoo!
            [3] => Microsoft Corp.
        )
    [Currency] => Array
        (
            [0] => USD
        )
    [SocialTag] => Array
        (
            [0] => New encyclopedism
            [1] => Microsoft
            [2] => Jerry Yang
            [3] => Steve Ballmer
            [4] => Bing
            [5] => Yahoo!
            [6] => Internet search engines
            [7] => Hypertext
        )
)

Basic usage is simple. Create an instance of the class with your API key, and call the getEntities method using your content string.

require('opencalais.php');
$oc = new OpenCalais('your-api-token');
$entities = $oc->getEntities($content);

This class is distributed under an open source BSD license. The license terms can be found in license.txt of the code archive.

  • http://grayvjpict.8k.com/frypy/grand-casino-in-gulfport-ms.htm freepri

    slot machines in the houston texas area

  • http://foodqqymin.8k.com/gecsv/poker-blackjack-table-top-2-in-1-2005-no-chips.htm pokerch

    orleans casino and resort las vegas

  • http://lockqirftguest.8m.com/firtf-ip/my-way-games-casino.htm pokerru

    casino magic bay st louis

  • http://grayhfmqnnight.8k.com/myifg/pioneer-slots-users-manual-okinawa-island.htm wwwbatt

    poker rooms in tampast pete

  • http://lightuawover.s5.com/pknua/desert-burn-hoodia-gordonii.htm ambient

    countries with socialism

  • http://bodykkprcbycic.s5.com/tyxqa/mexico-pharmacy-hydrocodone.htm charlie

    laser weight loss programs in arlington tx

  • http://www.alchemyapi.com/api/entity/ Elliot

    Great PHP library! Have you considered abstracting the code to support other semantic tagging services?

    We’d love to see AlchemyAPI support in your library. Similar to the service you’re supporting now, but supports more languages (8), disambiguates more entity types (24+), etc.

  • Pingback: Plugins para tornar seu blog Wordpress “semantic ready” « Alexandre Colucci: Web Design, Desenvolvimento Web, Usabilidade & Arquitetura de Informação()

  • Pingback: Made of String » Automatically tagging news stories using OpenCalais()

  • Pingback: OpenCalais – Analys av text | Entreprenör Jonas Lejon()

  • http://aurorawdc.com geme4472

    This is really, really nice. This is a very concise, lightweight way to communicate with Open Calais. Well done!

  • Melati

    I’m new here. I’m trying to use opencalais to generate database for my name entity. My question: is it possible to use MySQL or Ms Access as database and python ( i’ll do some programming to accept input) as interface

  • C5495355

    Function split() is deprecated : opencalais.php on line 61

  • http://www.dangrossman.info Dan Grossman

    Yes, that’s a notice, when you run this code under certain newer versions of PHP. You can either hide the notice by changing your error reporting level or change split to explode. Why did you leave it as a comment here?

  • Pingback: Black WordPress: Auto Add Tags – Part 3 - Open Calais API()

  • http://michael-lipson.com Michael Lipson

    Came across this when I was playing with Calais Tags, made what I was doing a lot less headache. Thanks for posting this great PHP class. 

  • Pingback: Leonardo Alves Cotta » Blog Archive » Plugins para tornar seu blog WordPress “semantic ready” - Analise, Desenvolvimento e Curiosidades()

  • Pingback: Auto Add Tags – Part 3 – Open Calais API | Alexandru-Dan Fratean()

  • Pingback: Plugins para tornar seu blog WordPress “semantic ready” | Alexandre Colucci - Alexandre Colucci()

  • Omar Sito

    Hello, The code works perfectly, but I have a doubt, you say that the result is:

    Array
    (
    [Industry Term] => Array
    (
    [0] => Internet
    [1] => software maker
    [2] => Internet search
    )
    [Person] => Array
    (
    [0] => Steve Ballmer
    [1] => Jerry Yang
    [2] => Colin Gillis
    )
    …..
    …..
    ….
    etc
    )

    But when I run the code I get this output:

    Array
    (
    [Topics] => Array
    (
    [0] => Business_Finance
    [1] => Technology_Internet
    )

    [SocialTag] => Array
    (
    [0] => World Wide Web
    [1] => Alibaba Group
    [2] => Yahoo!
    [3] => Steve Ballmer
    [4] => Microsoft
    [5] => Ballmer
    [6] => Jerry Yang
    [7] => Canaccord Genuity
    [8] => Google
    )

    [Entities] => Array
    (
    [0] => software maker
    [1] => Canaccord Adams
    [2] => Colin Gillis
    [3] => Steve Ballmer
    [4] => Yahoo
    [5] => Internet search
    [6] => Chief Executive Officer
    [7] => Internet
    [8] => Google Inc.
    [9] => Jerry Yang
    [10] => Yahoo! Inc.
    [11] => Microsoft Corp.
    )

    )

    I need to get just the name of the people and this output does not help me much. Could someone explain what happened and how I can fix it ???