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:

$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('', FALSE, stream_context_create($context));
$xml = simplexml_load_string($response);
$xml->registerXPathNamespace('y', '');
$places = array_map('parse_item', $xml->xpath("y:document/y:placeDetails/y:place")); 
function parse_item($item){
  return array(
    'name' => (string) $item->name,
    'lat' => (float) $item->centroid->latitude,
    'lng' => (float) $item->centroid->longitude,