Yahoo! PlaceMaker

As an entity extraction service - the actual service, ignoring the quality of the results - Yahoo! PlaceMaker is excellent. It takes plain text or XML as input, and returns a list of places identified within the text. For XML input, it even returns an XPath and offsets for each entity so you can easily splice the annotations back into the document.

Here's somewhere you can test the extraction, though it's only marking the centre of extracted locations, not the whole region.

Sample code for extracting from text:

<?php
$params = array(
    'appid' => 'YOUR APP ID',
    'documentType' => 'text/plain',
    'documentContent' => $text,
    );
    
$headers = array('Content-Type: application/x-www-form-urlencoded; charset=UTF-8');
$context = array('http' => array('method'=> 'POST', 'content' => http_build_query($params), 'header' => implode("\n", $headers)));
$response = file_get_contents('http://wherein.yahooapis.com/v1/document', FALSE, stream_context_create($context));

$xml = simplexml_load_string($response);
$xml->registerXPathNamespace('y', 'http://wherein.yahooapis.com/v1/schema');
  
$places = array_map('parse_item', $xml->xpath("y:document/y:placeDetails/y:place")); 
print_r($places);

function parse_item($item){
  return array(
    'name' => (string) $item->name,
    'lat' => (float) $item->centroid->latitude,
    'lng' => (float) $item->centroid->longitude,
    );
}

Comments

Thanks - excellent demo! Please consider posting it to YDN forum of the Placemaker!

Neat!

This would have been tremendously handy when I made the map for my Around the World playlist.

Playlist:
http://earthlingsoft.net/ssp/playlists/AroundTheWorld.html

Map:
http://maps.google.de/maps/ms?ie=UTF8&msa=0&msid=114894081796458344135.000449e218794223c5b37&ll=41,41&spn=123,280&z=2

Posted by: ssp on May 22, 2009 12:41 AM

All fields are optional, email address will not be shown; no HTML, URLs are automatically hyperlinked.