オークションで一眼レフ落札したら、フィルムカメラだった!

エンジニアたるもの、写真の意識が高くないと駄目だ、とあるカメラやってる方にインスパイアーされ、ヤフオクで一眼レフを落札

ワクワク^^

届きました。

いいね~この重厚感

あれ、ちょっと待て、これフィルム?

普通そこ間違えるかね。。

といいつつ、速攻でフィルムと電池を買ってしまった。

息抜きに写真でも撮りに行きますかね。

決算ir情報をphpで翻訳する

yahoo 譲渡制限付株式報酬としての新株式の発行に関するお知らせ(259文字)
当社は中長期的かつ持続的な企業価値の向上を目指しており、そのためには、将来の成長を見据えた
サービスへの先行投資や設備投資、資本業務提携を積極的に行うことが重要だと認識しています。同時
に、利益還元を通じて株主の皆さまに報いることが上場会社としての責務と捉えています。
上記方針のもと、当期の期末配当金につきましては、1 株当たり8.86 円(配当金総額は504 億円)と
いたしました。
当社はこれからも、将来の成長のための投資を継続しながら、株主の皆さまへの適切な利益還元を行
うことにより、企業価値の向上を目指していきます。

$key = 'hoge';

$host = "https://api.cognitive.microsofttranslator.com";
$path = "/translate?api-version=3.0";
$params = "&to=en";
$text = "当社は中長期的かつ持続的な企業価値の向上を目指しており、そのためには、将来の成長を見据えた
サービスへの先行投資や設備投資、資本業務提携を積極的に行うことが重要だと認識しています。同時
に、利益還元を通じて株主の皆さまに報いることが上場会社としての責務と捉えています。
上記方針のもと、当期の期末配当金につきましては、1 株当たり8.86 円(配当金総額は504 億円)と
いたしました。
当社はこれからも、将来の成長のための投資を継続しながら、株主の皆さまへの適切な利益還元を行
うことにより、企業価値の向上を目指していきます。";

if(!function_exists('com_create_guid')){
	function com_create_guid(){
		return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
		mt_rand(0, 0xffff), mt_rand(0, 0xffff),
		mt_rand(0, 0xffff),
		mt_rand(0, 0x0fff) | 0x4000,
		mt_rand(0, 0x3fff) | 0x8000,
		mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
	}
}

function Translate ($host, $path, $key, $params, $content) {
    $headers = "Content-type: application/json\r\n" .
        "Content-length: " . strlen($content) . "\r\n" .
        "Ocp-Apim-Subscription-Key: $key\r\n" .
        "X-ClientTraceId: " . com_create_guid() . "\r\n";
    $options = array (
        'http' => array (
            'header' => $headers,
            'method' => 'POST',
            'content' => $content
        )
    );
    $context  = stream_context_create($options);
    $result = file_get_contents ($host . $path . $params, false, $context);
    return $result;
}

$requestBody = array (
    array (
        'Text' => $text,
    ),
);
$content = json_encode($requestBody);
$result = Translate($host, $path, $key, $params, $content);

$json = json_decode($result);
echo $json[0]->translations[0]->text;

echoの結果->565文字
—–
We aim to improve our corporate value in the medium to long term and We recognize that it is important to actively engage in upfront investment in services, capital investment, and business alliances. Same , it is our duty as a listed company to repay our shareholders through the return of profits. Under the above policy, the year-end dividend for the current period is 8.86 yen per share (total dividend of 50.4 billion yen) We. We will continue to invest in future growth and to return appropriate profits to our shareholders. We aim to improve corporate value.

悪くない!というか、金融系に強い帰国子女に頼むよりも質が高く、早くて安い(笑)
これは自動化したい。

月200万文字まで無料なので、1000文字の翻訳だとすると、上限2000回か。
全銘柄のEdinet IR自動翻訳だとちょっとキツイな。
うーん、どうする?

Azure Translator Text APIを使ってphpで翻訳する

file_get_contentsしたjsonをdecodeします。

$key = 'hogehoge';

$host = "https://api.cognitive.microsofttranslator.com";
$path = "/translate?api-version=3.0";
$params = "&to=en";
$text = "1文をバラバラにして単語レベルで翻訳をするのではなく、1文をひとまとめにして翻訳";

if(!function_exists('com_create_guid')){
	function com_create_guid(){
		return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
		mt_rand(0, 0xffff), mt_rand(0, 0xffff),
		mt_rand(0, 0xffff),
		mt_rand(0, 0x0fff) | 0x4000,
		mt_rand(0, 0x3fff) | 0x8000,
		mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
	}
}

function Translate ($host, $path, $key, $params, $content) {
    $headers = "Content-type: application/json\r\n" .
        "Content-length: " . strlen($content) . "\r\n" .
        "Ocp-Apim-Subscription-Key: $key\r\n" .
        "X-ClientTraceId: " . com_create_guid() . "\r\n";
    $options = array (
        'http' => array (
            'header' => $headers,
            'method' => 'POST',
            'content' => $content
        )
    );
    $context  = stream_context_create($options);
    $result = file_get_contents ($host . $path . $params, false, $context);
    return $result;
}

$requestBody = array (
    array (
        'Text' => $text,
    ),
);
$content = json_encode($requestBody);
$result = Translate($host, $path, $key, $params, $content);


$json = json_decode($result);
echo $json[0]->translations[0]->text;

これは。。。

eminem lose yourself
——-
Look, if you had one shot, one opportunity
To seize everything you ever wanted
One moment
Would you capture it or just let it slip?
Yo
His palms are sweaty, knees weak, arms are heavy
There’s vomit on his sweater already, mom’s spaghetti
He’s nervous, but on the surface he looks calm and ready
To drop bombs, but he keeps on forgettin’
What he wrote down, the whole crowd goes so loud
He opens his mouth, but the words won’t come out
He’s chokin’, how, everybody’s jokin’ now
The clocks run out, times up, over, blaow!
Snap back to reality, oh there goes gravity
Oh, there goes Rabbit, he choked
He’s so mad, but he won’t give up that easy? No
He won’t have it, he knows his whole back city’s ropes
It don’t matter,
He’s dope,…

ラップの翻訳って難しいと思うが、
結果

ほお

翻訳のアルゴリズムは?

前:ルールベース翻訳や統計翻訳
->文法や単語などのルールを一つ一つ登録して翻訳

後:ニューラルネットワーク
->1文をバラバラにして単語レベルで翻訳をするのではなく、1文をひとまとめにして翻訳

そうなのか、VoiceTraとかも統計翻訳の機械学習かと思ってた。。
NICT(情報通信研究機構)
http://www.nict.go.jp/
ここは興味ある。金融庁以来。

しかし予算500億も使ってんのかよ。。コロプラの売上高と一緒じゃんか。。ちくしょー羨ましすぎる。。
https://www.nict.go.jp/pdf/business-report-2016.pdf

ibm translator

使ってみる。

[vagrant@localhost translator]$ curl -u "username":pass" \
> -H "Accept: application/json" \
> "https://gateway.watsonplatform.net/language-translator/api/v2/translate?model_id=en-ja&text=ibm+translator"
{
  "translations" : [ {
    "translation" : "IBM変換プログラム"
  } ],
  "word_count" : 2,
  "character_count" : 14
}

幾つか試したが、レスポンスがなかったり、tokyo -> “translation” : “統教” と精度がイマイチだったり。。。
やってることは凄いんだろうけど、これ以上深堀りする気ナシ。