Exemple #1
0
function wikipedia_streetnames_info($info_ret, $object) {
  global $data_lang;
  $text="";

  if(!$object->tags->get("highway"))
    return;

  $res=sql_query("select * from osm_polygon where osm_way && geomfromtext('{$object->data['way']}', 900913) and CollectionIntersects(osm_way, geomfromtext('{$object->data['way']}', 900913)) and osm_tags @> 'boundary=>administrative' order by parse_number(osm_tags->'admin_level') desc");
  while($elem=pg_fetch_assoc($res)) {
    $boundary=load_object($elem['osm_id']);

    $data=cache_search($boundary->id, "wikipedia:street_names:$data_lang");
    if($data) {
      $data=unserialize($data);
    }
    else {
      $data=wikipedia_get_lang_page($boundary, "wikipedia:street_names");
      $article=wikipedia_get_article($boundary, $data['page'], $data['lang']);
      $data['article']=$article;

      cache_insert($boundary->id, "wikipedia:street_names:$data_lang", 
        serialize($data), "1 hour");
    }

    if($data['article']) {
      $text.=wikipedia_streetnames_parse($data['article'], $object);
      if($text) {
	$text.="<br>".lang("source").": <a class='external' href='".wikipedia_url($boundary, $data['page'], $data['lang'])."'>Wikipedia</a>\n";
	$info_ret[]=array("head"=>"wikipedia_streetnames", "content"=>$text, "doc"=>"plugin:wikipedia_streetnames/feature");
	return;
      }
    }
  }
}
Exemple #2
0
function wikipedia_search($procd_descr)
{
    profiling_start('wikipedia_search');
    $TERMS = wikipedia_process_term($procd_descr);
    $url = wikipedia_url($TERMS);
    $data = cached_file_get_contents($url);
    Error::setPrepend($data);
    Error::generate('debug', 'WIKIPEDIA');
    eval('$arr = ' . $data . ';');
    foreach ($arr['query']['pages'] as $k => $v) {
        $title = urlencode($v['title']);
        $url = urlencode($v['fullurl']);
        // https://dgl.cx/2008/10/wikipedia-summary-dns
        if ($k == -1) {
            // not found
            return array();
        }
        break;
    }
    // this is probably a topic from a random unintended field like "frequency analysis (cryptoanalysis)"
    if (strlen($title) < strlen($TERMS) - 5 || strlen($title) > strlen($TERMS) + 5 || strrchr($title, '%28')) {
        return array();
    }
    $store = array('title' => urldecode(str_replace('+', ' ', $title)), 'link' => urldecode($url), 'source' => 'wikipedia');
    profiling_end('wikipedia_search');
    return array($store);
}
Exemple #3
0
function wikipedia_analysis($text)
{
    $content = file_get_contents(wikipedia_url($text));
    $doc = phpQuery::newDocumentHTML($content);
    phpQuery::selectDocument($doc);
    $ansList = pq(".NetDicBody");
    $ans = 0;
    return $doc;
}
Exemple #4
0
echo '
    <form action="' . $self . '" method="GET">
        <label>Search: <input type="text" name="search" /><label>
        <input type="submit" value="Go!">
    </form>
    ';
echo $ret;
if ($search === '') {
} else {
    echo $ret;
    echo "中文词语中文结果:" . $ret;
    echo '<a href="' . moegirl_url($search) . '">萌娘百科:' . $search . '</a>' . $ret;
    echo '<a href="' . baidubaike_url($search) . '">百度百科:' . $search . '</a>' . $ret;
    echo "--------------------------------------------------------------" . $ret;
    echo "日文词语日文结果:" . $ret;
    echo '<a href="' . weblio_url($search) . '">Weblio辞書:' . $search . '</a>' . $ret;
    echo '<a href="' . weblio_thesaurus_url($search) . '">Weblio類語・対義語辞典:' . $search . '</a>' . $ret;
    echo '<a href="' . weblio_ejje_url($search) . '">Weblio英和和英辞典:' . $search . '</a>' . $ret;
    echo '<a href="' . goo_url($search) . '">Goo辞書:' . $search . '</a>' . $ret;
    echo '<a href="' . wikipedia_url($search) . '">日文维基百科:' . $search . '</a>' . $ret;
    echo '<a href="' . pixivdict_url($search) . '">Pixiv百科事典:' . $search . '</a>' . $ret;
    echo '<a href="' . niconicodict_url($search) . '">niconico大百科:' . $search . '</a>' . $ret;
    echo "--------------------------------------------------------------" . $ret;
    echo "日文词语中文结果:" . $ret;
    echo '<a href="' . weblio_cjjc_url($search) . '">Weblio日中中日辞典:' . $search . '</a>' . $ret;
    echo '<a href="' . hj_url($search) . '">沪江词典:' . $search . '</a>' . $ret;
}
//    echo '<a href="'. hj_url($search). '">HJDict:'.$search.'</a>'." -> ". hj_analysis($search).$ret;
//    echo '<a href="'. weblio_url($search). '">Weblio:'.$search.'</a>'." -> ". weblio_analysis($search).$ret;
//    echo '<a href="'. goo_url($search). '">Goo:'.$search.'</a>'." -> ". goo_analysis($search).$ret;
//    echo '<a href="'. wikipedia_url($search). '">Wikipedia:'.$search.'</a>'." -> ". wikipedia_analysis($search).$ret;
Exemple #5
0
function wikipedia_info($info_ret, $object) {
  $ret="";
  global $data_lang;

  if($data=cache_search($object->id, "wikipedia_info:$data_lang")) {
    $data=unserialize($data);
    $ret.="{$data['text']}<a class='external' href='{$data['url']}' target='_blank'>".lang("wikipedia:read_more")."</a>";

    $info_ret[]=array("head"=>"wikipedia", "content"=>$ret, "doc"=>"plugin:wikipedia/feature");
    return;
  }

  if(!($res=wikipedia_get_lang_page($object)))
    return;

  $lang=$res['lang'];
  $page=$res['page'];

  if(!($url=wikipedia_url($object, $page, $lang)))
    return;

  $text=wikipedia_get_abstract($object, $page, $lang);

  cache_insert($object->id, "wikipedia_info:$data_lang", serialize(array("text"=>$text, "url"=>$url)), "1 hour");

  if($text) {
    $ret.="$text<a class='external' style='line-height:2em;' href='$url' target='_blank'>".lang("wikipedia:read_more")."</a>";
  }

  $info_ret[]=array("head"=>"wikipedia", "content"=>$ret, "doc"=>"plugin:wikipedia/feature");
}