getGeoInfo

説明

GeoNLP IDから地名語の詳細情報を検索する。

文法

object geonlp.getGeoInfo (string[] geonlp_ids)

リクエストパラメータ

geonlp_ids
  • 情報を取得したい地名語の geonlp_id の配列
  • 要素数の上限なし

リクエストの例

{
  "method": "geonlp.getGeoInfo",
  "params": [["tp1al0","rQ1HpF"]],
  "id": "4"
}

レスポンス

リクエストで渡された geonlp_id をキー、対応する地名語の情報を値とするオブジェクトを返す。

レスポンスの例

{
  "error":null,
  "id":4,
  "result":{
    "rQ1HpF":{
      "body":"神保町",
      "body_kana":"ジンボウチョウ",
      "dictionary_id":31,
      "entry_id":"eb03_6358",
      "geonlp_id":"rQ1HpF",
      "hypernym":[
        "東京都",
        "三田線"
      ],
      "latitude":"35.6948933333333",
      "longitude":"139.758428333333",
      "ne_class":"鉄道施設/地下鉄駅",
      "railway_type":"12",
      "service_provider_type":"3",
      "suffix":[
        "駅",
        ""
      ],
      "suffix_kana":[
        "エキ",
        ""
      ]
    },
    "tp1al0":{
      "body":"神保町",
      "body_kana":"ジンボウチョウ",
      "dictionary_id":31,
      "entry_id":"eb03_6303",
      "geonlp_id":"tp1al0",
      "hypernym":[
        "東京地下鉄",
        "半蔵門線"
      ],
      "latitude":"35.6960166666667",
      "longitude":"139.75742",
      "ne_class":"鉄道施設/地下鉄駅",
      "railway_type":"12",
      "service_provider_type":"4",
      "suffix":[
        "駅",
        ""
      ],
      "suffix_kana":[
        "エキ",
        ""
      ]
    }
  }
}

PHP サンプルコード

jsonrpc_client.php

ダウンロード

<?php

$apikey = ""; // <-- input your API key

function jsonrpc_exec($json_request) {
  global $apikey;
  if ($apikey == '') throw new Exception("Please submit the API key from the GeoNLP site (https://geonlp.ex.nii.ac.jp)");

  $endpoint = "https://dias.ex.nii.ac.jp/geonlp/api/1/geo-tagging";
  $header  = array("Content-Type: application/json",
                   "X-GeoNLP-Authorization: {$apikey}",
                   "Content-Length: ".strlen($json_request));
  $options = array('http' => array('method' => 'POST', 'header' => implode("\r\n", $header), 'content' => $json_request));
  $content = file_get_contents($endpoint, false, stream_context_create($options));
  $result = var_export(json_decode($content, true), true);
  return $result;
}

getGeoInfo.php

ダウンロード

<?php
require_once('jsonrpc_client.php');

$request = array(
  'method'=>'geonlp.getGeoInfo',
  'params'=>array(array('tp1al0', 'rQ1HpF')),
  'id'=>4);

$response = jsonrpc_exec(json_encode($request));
var_export($response);

実行結果

$ php getGeoInfo.php
array (
  'error' => NULL,
  'id' => 4,
  'result' => 
  array (
    'rQ1HpF' => 
    array (
      'body' => '神保町',
      'body_kana' => 'ジンボウチョウ',
      'dictionary_id' => 31,
      'entry_id' => 'eb03_6358',
      'geonlp_id' => 'rQ1HpF',
      'hypernym' => 
      array (
        0 => '東京都',
        1 => '三田線',
      ),
      'latitude' => '35.6948933333333',
      'longitude' => '139.758428333333',
      'ne_class' => '鉄道施設/地下鉄駅',
      'railway_type' => '12',
      'service_provider_type' => '3',
      'suffix' => 
      array (
        0 => '駅',
        1 => '',
      ),
      'suffix_kana' => 
      array (
        0 => 'エキ',
        1 => '',
      ),
    ),
    'tp1al0' => 
    array (
      'body' => '神保町',
      'body_kana' => 'ジンボウチョウ',
      'dictionary_id' => 31,
      'entry_id' => 'eb03_6303',
      'geonlp_id' => 'tp1al0',
      'hypernym' => 
      array (
        0 => '東京地下鉄',
        1 => '半蔵門線',
      ),
      'latitude' => '35.6960166666667',
      'longitude' => '139.75742',
      'ne_class' => '鉄道施設/地下鉄駅',
      'railway_type' => '12',
      'service_provider_type' => '4',
      'suffix' => 
      array (
        0 => '駅',
        1 => '',
      ),
      'suffix_kana' => 
      array (
        0 => 'エキ',
        1 => '',
      ),
    ),
  ),
)