映画、ウィンストン・チャーチル/ヒトラーから世界を救った男 (字幕版)を観ましたよ。

2019.03.09

Logging

ウィンストン・チャーチル/ヒトラーから世界を救った男 (字幕版) – 予告編

映画、ウィンストン・チャーチル/ヒトラーから世界を救った男 (字幕版)を観ましたよ。これは良かった。

成功は決定的ではなく、失敗は致命的ではない。大切なのは続ける勇気だ
Success is not final, failure is not fatal: it is the courage to continue that counts

 

タグ

5, 50, com, continue, counts, courage, failure, fatal, FINAL, is, IT, lSG, MIoE, nbsp, not, success, that, The, To, youtube, ウィンストン, コレ, チャーチル, ヒトラー, 世界, 勇気, 大切, 失敗, 字幕, 成功, 映画, ,

WordPress自動日本語タグを吐き出しプラグインを作りました。

2018.11.17

Logging

WordPress自動日本語タグを吐き出しプラグインを作りました。
あのjapanese autotagというプラグインと考え方は同じですが、
自分が作ったものはその簡略化したものです。
ソースコードは全ったく違う感じですが、動作は似たような感じです。
機能はjapanese autotagよりかは少ないですが、これだけで十分かなと思います。
ダウンロードはこちらから
https://zip358.com/tool/jp-auto-tag.zip [v2に対応済み]
尚、Yahoo デベロッパーのアプリケーションIDが必要となります。
ソースコードは下記になります。※v1のソースコードなので今は動きません!!最新の記事を参照ください。

<?php
/*
Plugin Name: jp-auto-tag
Version: 0.1.11
Description: auto jp tag
Author: taoka toshiaki
Author URI: https://zip358.com/
Plugin URI: https://wordpress.org/extend/plugins/jp-auto-tag/
*/
class jp_auto_tag{
    public $db_option = "jp_auto_tag";
    //api
    public $results = "ma";
    public $filter = array("1","2","3","4","5","6","7","8","9","10","11","12","13");
    function frm_page(){
        add_menu_page('jp-auto-tag','jp-auto-tag',  'manage_options', __FILE__, array($this,'show_text_option_page'), '',8);
    }
    function show_text_option_page(){
        wp_enqueue_style( 'bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css', array(), '3.3.6' );
        wp_enqueue_script( 'bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js', array(), '3.3.6');
        $options = get_option($this->db_option);
        if(!empty($options)){
            $appid = $options["appid"];
            foreach ($this->filter as $key => $value) {
               if($options["filter".$value] == $value){
                    $f[] = "checked";
               }else{
                   $f[] = "";
               }
            }
        }
        include_once dirname( __FILE__ ).'/jp-auto-tag-tmp.php';
    }
    function ajax_event(){
        $appid = $_POST["appid"];
        $filter =$_POST["filter"];
        $options["appid"] = $appid;
        foreach ($this->filter as $key => $value) {
            if(in_array($value,$filter,true)){
                $options["filter".$value] = $value;
            }else{
                $options["filter".$value] = "";
            }
        }
        update_option($this->db_option, $options);
        $obj["appid"] = $appid;
        $obj["filter"] = $filter;
        print json_encode($obj);
        die(0);
    }
    function api_tag($post_id){
ini_set("display_errors",1);
        $post = get_post($post_id);
        $title = $post->post_title;
        $content = strip_tags($post->post_content);
        $sentence = $title.$content;
        if(strlen($sentence)>102400){
            $sentence = substr($sentence,0,102400);
        }
        $options = get_option($this->db_option);
        if(!empty($options)){
            $appid = $options["appid"];
            foreach ($this->filter as $key => $value) {
               if($options["filter".$value] == $value){
                    $f[] = $value;
               }
            }
        }
        if($appid){
            $filter = implode("|",$f);
            if(!$filter){
                $url = "https://jlp.yahooapis.jp/MAService/V1/parse?appid=$appid&results=$this->results&sentence=".urlencode($sentence);
            }else{
                $url = "https://jlp.yahooapis.jp/MAService/V1/parse?appid=$appid&results=$this->results&ma_filter=$filter&sentence=".urlencode($sentence);
            }
            $xml = @file_get_contents($url);
            $xml_obj = simplexml_load_string($xml);
            if($xml_obj->ma_result->word_list){
                foreach($xml_obj->ma_result->word_list->word as $word) {
                    if($word->surface){
                        $tags[] = $word->surface;
                    }
                    if(is_array($tags)){
                        wp_set_post_tags($post_id, implode(",",array_unique($tags)), false);
                    }
                }
            }
        }
    }
}
$jp_auto_tag = new jp_auto_tag();
add_action('save_post',array($jp_auto_tag,'api_tag'));
add_action('publish_post',array($jp_auto_tag,'api_tag'));
add_action('admin_menu', array($jp_auto_tag, 'frm_page'));
add_action('wp_ajax_ajax_event',array($jp_auto_tag,'ajax_event'));
<form id="ajax-frm">
<table class="table">
    <tr>
        <td>
            アプリケーションID
        </td>
        <td>
            <input type="text" name="appid" value="<?=$appid?>" class="form-control">
        </td>
    </tr>
    <tr>
        <td>
            解析結果として出力する品詞
        </td>
        <td>
            <input type="checkbox" name="filter[]" value="1" <?=$f[0]?>  class="form-control">1 : 形容詞
            <input type="checkbox" name="filter[]" value="2" <?=$f[1]?> class="form-control">2 : 形容動詞
            <input type="checkbox" name="filter[]" value="3" <?=$f[2]?> class="form-control">3 : 感動詞
            <input type="checkbox" name="filter[]" value="4" <?=$f[3]?> class="form-control">4 : 副詞
            <input type="checkbox" name="filter[]" value="5" <?=$f[4]?> class="form-control">5 : 連体詞
            <input type="checkbox" name="filter[]" value="6" <?=$f[5]?> class="form-control">6 : 接続詞
            <input type="checkbox" name="filter[]" value="7" <?=$f[6]?> class="form-control">7 : 接頭辞
            <input type="checkbox" name="filter[]" value="8" <?=$f[7]?> class="form-control">8 : 接尾辞
            <input type="checkbox" name="filter[]" value="9" <?=$f[8]?> class="form-control">9 : 名詞
            <input type="checkbox" name="filter[]" value="10"<?=$f[9]?>  class="form-control">10 : 動詞
            <input type="checkbox" name="filter[]" value="11"<?=$f[10]?>  class="form-control">11 : 助詞
            <input type="checkbox" name="filter[]" value="12"<?=$f[11]?>  class="form-control">12 : 助動詞
            <input type="checkbox" name="filter[]" value="13"<?=$f[12]?>  class="form-control">13 : 特殊(句読点、カッコ、記号など)
        </td>
    </tr>
    <tr>
        <td colspan="2"><input type="button" id="frmsubmit" value="登録する" class="form-control"></td>
    </tr>
</table>
</form>
<script>
    jQuery(function($){
        $("#frmsubmit").on("click",function(){
            var ajaxurl = '<?=admin_url( 'admin-ajax.php');?>';
            var data = $("#ajax-frm").serializeArray();
            data.push({name:"action",value:"ajax_event"});
            $.ajax({
               type:'POST',
               url:ajaxurl,
               data:data,
               success:function(obj){
                   console.log(obj);
                   if(obj.appid!==""){
                       alert("更新しました");
                   }
               }
            });
        });
    })
</script>

タグ

API, appid, array, Bootstrap, dirname, extend, foreach, implode, MAService, obj, parse, plugins, strlen, success, 助動詞, 品詞, 形容動詞, 接尾辞, 接頭辞, 連体詞,