COTOHA APIを使って究極の感謝を送りたい

# 興り
我々エンジニアは（程度の差はあれど、）臆病な生き物なので、人と話すのが苦手です。

人と話すのが嫌だからエンジニアになった、まであります。
なので専らチャットやらメールやらでやりとりするわけですが、これがまた伝わりづらい。
絵文字やスタンプなどで感情の機微を伝える方法も、、、まああるんですが、どうせなら言葉で伝えたいですよね。
感謝、ありがとうの気持ちなどは特に。

## エンジニアでも感謝したい！

感謝を伝えたい、でも伝わるかわからない・・・
すごい感謝しているけどそれが伝わらなかったら・・・
どうすれば感謝が伝わるのか・・・

その悩み、技術の力で解決しましょう。

## COTOHA

>COTOHA® APIは、NTTグループの40年以上にわたる研究成果である日本語辞書・自然言語機能、およびCOTOHAの提供を通じて独自開発した機能をベースとした「テキスト解析」「対話」「音声認識サポート」に活用できるAPIサービスです。
> Communication Engine "COTOHA® API"



公式は[こちら](https://api.ce-cotoha.com/contents/index.html)
NTTCom社が提供している自然言語処理サービスです。


## どうやって調べるか 

「感情分析API」を使用します。
分析する言葉
よく言う・見る感謝のワードに副詞や助動詞、記号などをつけたり外したりして生成しました。
使用したパーツはこんな感じ

``` javascript
{
 prefix: ['', '超', 'マジ', '本当に', '誠に'],
 text: ['ありがとう', '感謝', '恩に着る', 'かたじけない', 'ども', 'あざす', 'ありがと', 'さんきゅ', 'サンクス', 'thx', '多謝'],
 suffix: ['', 'ね', 'です', 'ございます', 'ございました'],
 extension: ['', '。', '・・・', 'ー', '！', '〜', 'ー！', '〜！', '・・・！', '！！'],
}
```

リスト化すると、大体3000弱の言葉が生まれました。
これを一つ一つ感情分析します。

## 判断基準

使用するパラメータは**"sentiment"（感情）**と**"score"（センチメントスコア）**です。

「感謝」は感情的には喜んでいるはずなので、"sentiment"が"Positive"なものは感謝していると言えると思います。
また、"score"はmaxを1として、高ければ高いほど、その"sentiment"が強い、という意味です。
よって、感謝度合いとして、
「"sentiment"が"Positive"」かつ、「"score"が高い」ものがより感謝しているとします。

## 判定例

「ありがとう」、「ありがとう。」、「ありがとう！」を分析してみます。
それぞれこんな結果が返ってきました。

### ありがとう

``` json
{
   "result": {
       "sentiment": "Neutral",
       "score": 0.3140117003315527,
       "emotional_phrase": []
   },
   "status": 0,
   "message": "OK"
}
```

### ありがとう。

``` json
{
   "result": {
       "sentiment": "Positive",
       "score": 0.18406198502930196,
       "emotional_phrase": [
           {
               "form": "ありがとう",
               "emotion": "喜ぶ"
           }
       ]
   },
   "status": 0,
   "message": "OK"
}
```

### ありがとう！
``` json
{
   "result": {
       "sentiment": "Positive",
       "score": 0.1823655212516051,
       "emotional_phrase": [
           {
               "form": "ありがとう",
               "emotion": "喜ぶ"
           }
       ]
   },
   "status": 0,
   "message": "OK"
}
```

この中だと、僅差ですが、**「ありがとう。」**が一番感謝している、と判定します。

## 結果

長いのでTOP20だけ

### 感謝しているリスト（下に行くほど感謝している）
``` json
{"text":"超感謝です〜","result":{"sentiment":"Positive","score":0.6205492790659887,"emotional_phrase":[{"form":"超感謝です〜","emotion":"P"}]}}
{"text":"本当に感謝です〜","result":{"sentiment":"Positive","score":0.6205492790659887,"emotional_phrase":[{"form":"本当に感謝です〜","emotion":"P"}]}}
{"text":"誠に感謝です〜","result":{"sentiment":"Positive","score":0.6205492790659887,"emotional_phrase":[{"form":"誠に感謝です〜","emotion":"P"}]}}
{"text":"マジ感謝ね〜","result":{"sentiment":"Positive","score":0.6206531866974735,"emotional_phrase":[{"form":"マジ感謝ね〜","emotion":"P"}]}}
{"text":"マジ感謝です〜","result":{"sentiment":"Positive","score":0.6219847012855368,"emotional_phrase":[{"form":"マジ感謝です〜","emotion":"P"}]}}
{"text":"感謝です","result":{"sentiment":"Positive","score":0.6396017754735464,"emotional_phrase":[{"form":"感謝です","emotion":"P"}]}}
{"text":"超感謝です","result":{"sentiment":"Positive","score":0.6396017754735464,"emotional_phrase":[{"form":"超感謝です","emotion":"P"}]}}
{"text":"本当に感謝です","result":{"sentiment":"Positive","score":0.6396017754735464,"emotional_phrase":[{"form":"本当に感謝です","emotion":"P"}]}}
{"text":"誠に感謝です","result":{"sentiment":"Positive","score":0.6396017754735464,"emotional_phrase":[{"form":"誠に感謝です","emotion":"P"}]}}
{"text":"マジ感謝です","result":{"sentiment":"Positive","score":0.6410488358205073,"emotional_phrase":[{"form":"マジ感謝です","emotion":"P"}]}}
{"text":"感謝ね","result":{"sentiment":"Positive","score":0.6511186220600979,"emotional_phrase":[{"form":"感謝ね","emotion":"P"}]}}
{"text":"超感謝ね","result":{"sentiment":"Positive","score":0.6511186220600979,"emotional_phrase":[{"form":"超感謝ね","emotion":"P"}]}}
{"text":"超感謝ねー","result":{"sentiment":"Positive","score":0.6511186220600979,"emotional_phrase":[{"form":"超感謝ねー","emotion":"P"}]}}
{"text":"本当に感謝ね","result":{"sentiment":"Positive","score":0.6511186220600979,"emotional_phrase":[{"form":"本当に感謝ね","emotion":"P"}]}}
{"text":"本当に感謝ねー","result":{"sentiment":"Positive","score":0.6511186220600979,"emotional_phrase":[{"form":"本当に感謝ねー","emotion":"P"}]}}
{"text":"誠に感謝ね","result":{"sentiment":"Positive","score":0.6511186220600979,"emotional_phrase":[{"form":"誠に感謝ね","emotion":"P"}]}}
{"text":"誠に感謝ねー","result":{"sentiment":"Positive","score":0.6511186220600979,"emotional_phrase":[{"form":"誠に感謝ねー","emotion":"P"}]}}
{"text":"感謝ねー","result":{"sentiment":"Positive","score":0.6511186220600979,"emotional_phrase":[{"form":"感謝ねー","emotion":"P"}]}}
{"text":"マジ感謝ね","result":{"sentiment":"Positive","score":0.6524217224387305,"emotional_phrase":[{"form":"マジ感謝ね","emotion":"P"}]}}
{"text":"マジ感謝ねー","result":{"sentiment":"Positive","score":0.6524217224387305,"emotional_phrase":[{"form":"マジ感謝ねー","emotion":"P"}]}}
```

**＿人人人人人人人人＿**
**＞　マジ感謝ねー　＜**
**￣Y^Y^Y^Y^Y^Y^Y￣**

もしくは

**＿人人人人人人人＿**
**＞　マジ感謝ね　＜**
**￣Y^Y^Y^Y^Y^Y￣**

日本語として何となく違和感を覚えますが、スコアはなんと**0.65**です。
**「ありがとう。」が約0.2**だったので、**およそ3倍**感謝してます。赤くなってます。というか「感謝」が総ナメです。

というわけで、エンジニアの皆さん、究極の感謝を伝えたい時は**「マジ感謝ね」**でお願いします。




## おまけ

### 感謝の気持ちはあるけどそこまででもないリスト
（下に行くほどそこまででもない）

``` json
{"text":"マジありがとうです。","result":{"sentiment":"Positive","score":0.1055310255410064,"emotional_phrase":[{"form":"ありがとう","emotion":"喜ぶ"}]}}
{"text":"ありがとうです。","result":{"sentiment":"Positive","score":0.1055310255410064,"emotional_phrase":[{"form":"ありがとう","emotion":"喜ぶ"}]}}
{"text":"誠に多謝ございます！！","result":{"sentiment":"Positive","score":0.09655046754174663,"emotional_phrase":[{"form":"多謝","emotion":"喜ぶ"}]}}
{"text":"本当に多謝ございます！！","result":{"sentiment":"Positive","score":0.09655046754174663,"emotional_phrase":[{"form":"多謝","emotion":"喜ぶ"}]}}
{"text":"マジ多謝ございます！！","result":{"sentiment":"Positive","score":0.09655046754174663,"emotional_phrase":[{"form":"多謝","emotion":"喜ぶ"}]}}
{"text":"超多謝ございます！！","result":{"sentiment":"Positive","score":0.09655046754174663,"emotional_phrase":[{"form":"多謝","emotion":"喜ぶ"}]}}
{"text":"多謝ございます！！","result":{"sentiment":"Positive","score":0.09655046754174663,"emotional_phrase":[{"form":"多謝","emotion":"喜ぶ"}]}}
{"text":"誠にありがとございます！！","result":{"sentiment":"Positive","score":0.09636882341386281,"emotional_phrase":[{"form":"ありがと","emotion":"喜ぶ"}]}}
{"text":"本当にありがとございます！！","result":{"sentiment":"Positive","score":0.09636882341386281,"emotional_phrase":[{"form":"ありがと","emotion":"喜ぶ"}]}}
{"text":"マジありがとございます！！","result":{"sentiment":"Positive","score":0.09636882341386281,"emotional_phrase":[{"form":"ありがと","emotion":"喜ぶ"}]}}
{"text":"ありがとございます！！","result":{"sentiment":"Positive","score":0.09636882341386281,"emotional_phrase":[{"form":"ありがと","emotion":"喜ぶ"}]}}
{"text":"誠に多謝ございました！！","result":{"sentiment":"Positive","score":0.0924688184169565,"emotional_phrase":[{"form":"多謝","emotion":"喜ぶ"}]}}
{"text":"本当に多謝ございました！！","result":{"sentiment":"Positive","score":0.0924688184169565,"emotional_phrase":[{"form":"多謝","emotion":"喜ぶ"}]}}
{"text":"マジ多謝ございました！！","result":{"sentiment":"Positive","score":0.0924688184169565,"emotional_phrase":[{"form":"多謝","emotion":"喜ぶ"}]}}
{"text":"超多謝ございました！！","result":{"sentiment":"Positive","score":0.0924688184169565,"emotional_phrase":[{"form":"多謝","emotion":"喜ぶ"}]}}
{"text":"多謝ございました！！","result":{"sentiment":"Positive","score":0.0924688184169565,"emotional_phrase":[{"form":"多謝","emotion":"喜ぶ"}]}}
{"text":"誠にありがとございました！！","result":{"sentiment":"Positive","score":0.09229406873002474,"emotional_phrase":[{"form":"ありがと","emotion":"喜ぶ"}]}}
{"text":"本当にありがとございました！！","result":{"sentiment":"Positive","score":0.09229406873002474,"emotional_phrase":[{"form":"ありがと","emotion":"喜ぶ"}]}}
{"text":"マジありがとございました！！","result":{"sentiment":"Positive","score":0.09229406873002474,"emotional_phrase":[{"form":"ありがと","emotion":"喜ぶ"}]}}
{"text":"ありがとございました！！","result":{"sentiment":"Positive","score":0.09229406873002474,"emotional_phrase":[{"form":"ありがと","emotion":"喜ぶ"}]}}
```

### 特に何も思ってないリスト
（下に行くほど特に何も思っていない）

``` json
{"text":"マジさんきゅね！！","result":{"sentiment":"Neutral","score":0.43897945937300376,"emotional_phrase":[]}}
{"text":"本当にさんきゅね！！","result":{"sentiment":"Neutral","score":0.43897945937300376,"emotional_phrase":[]}}
{"text":"誠にさんきゅね！！","result":{"sentiment":"Neutral","score":0.43897945937300376,"emotional_phrase":[]}}
{"text":"サンクスね！！","result":{"sentiment":"Neutral","score":0.43897945937300376,"emotional_phrase":[]}}
{"text":"超サンクスね！！","result":{"sentiment":"Neutral","score":0.43897945937300376,"emotional_phrase":[]}}
{"text":"マジサンクスね！！","result":{"sentiment":"Neutral","score":0.43897945937300376,"emotional_phrase":[]}}
{"text":"本当にサンクスね！！","result":{"sentiment":"Neutral","score":0.43897945937300376,"emotional_phrase":[]}}
{"text":"誠にサンクスね！！","result":{"sentiment":"Neutral","score":0.43897945937300376,"emotional_phrase":[]}}
{"text":"thxね！！","result":{"sentiment":"Neutral","score":0.43897945937300376,"emotional_phrase":[]}}
{"text":"超thxね！！","result":{"sentiment":"Neutral","score":0.43897945937300376,"emotional_phrase":[]}}
{"text":"マジthxね！！","result":{"sentiment":"Neutral","score":0.43897945937300376,"emotional_phrase":[]}}
{"text":"本当にthxね！！","result":{"sentiment":"Neutral","score":0.43897945937300376,"emotional_phrase":[]}}
{"text":"誠にthxね！！","result":{"sentiment":"Neutral","score":0.43897945937300376,"emotional_phrase":[]}}
{"text":"マジどもね！！","result":{"sentiment":"Neutral","score":0.43897945937300376,"emotional_phrase":[]}}
{"text":"恩に着るね！！","result":{"sentiment":"Neutral","score":0.44024907942407704,"emotional_phrase":[]}}
{"text":"超恩に着るね！！","result":{"sentiment":"Neutral","score":0.44024907942407704,"emotional_phrase":[]}}
{"text":"マジ恩に着るね！！","result":{"sentiment":"Neutral","score":0.44024907942407704,"emotional_phrase":[]}}
{"text":"本当に恩に着るね！！","result":{"sentiment":"Neutral","score":0.44024907942407704,"emotional_phrase":[]}}
{"text":"誠に恩に着るね！！","result":{"sentiment":"Neutral","score":0.44024907942407704,"emotional_phrase":[]}}
{"text":"超さんきゅね！！","result":{"sentiment":"Neutral","score":0.4403449043366995,"emotional_phrase":[]}}
```

### もはや感情がないリスト
（下に行くほど感情がない）

``` json
{"text":"誠にサンクスございましたー","result":{"sentiment":"Neutral","score":0.2769223054262791,"emotional_phrase":[]}}
{"text":"本当にサンクスございましたー","result":{"sentiment":"Neutral","score":0.2769223054262791,"emotional_phrase":[]}}
{"text":"マジサンクスございましたー","result":{"sentiment":"Neutral","score":0.2769223054262791,"emotional_phrase":[]}}
{"text":"超サンクスございましたー","result":{"sentiment":"Neutral","score":0.2769223054262791,"emotional_phrase":[]}}
{"text":"サンクスございましたー","result":{"sentiment":"Neutral","score":0.2769223054262791,"emotional_phrase":[]}}
{"text":"誠にどもございましたー","result":{"sentiment":"Neutral","score":0.2769223054262791,"emotional_phrase":[]}}
{"text":"本当にどもございましたー","result":{"sentiment":"Neutral","score":0.2769223054262791,"emotional_phrase":[]}}
{"text":"マジどもございましたー","result":{"sentiment":"Neutral","score":0.2769223054262791,"emotional_phrase":[]}}
{"text":"どもございましたー","result":{"sentiment":"Neutral","score":0.2769223054262791,"emotional_phrase":[]}}
{"text":"誠に恩に着るございましたー","result":{"sentiment":"Neutral","score":0.2769223054262791,"emotional_phrase":[]}}
{"text":"本当に恩に着るございましたー","result":{"sentiment":"Neutral","score":0.2769223054262791,"emotional_phrase":[]}}
{"text":"マジ恩に着るございましたー","result":{"sentiment":"Neutral","score":0.2769223054262791,"emotional_phrase":[]}}
{"text":"超恩に着るございましたー","result":{"sentiment":"Neutral","score":0.2769223054262791,"emotional_phrase":[]}}
{"text":"恩に着るございましたー","result":{"sentiment":"Neutral","score":0.2769223054262791,"emotional_phrase":[]}}
{"text":"超ありがとうございましたー","result":{"sentiment":"Neutral","score":0.2769223054262791,"emotional_phrase":[]}}
{"text":"誠にかたじけないございましたー","result":{"sentiment":"Neutral","score":0.27355211994418566,"emotional_phrase":[{"form":"誠にかたじけないございましたー","emotion":"PN"}]}}
{"text":"本当にかたじけないございましたー","result":{"sentiment":"Neutral","score":0.27355211994418566,"emotional_phrase":[{"form":"本当にかたじけないございましたー","emotion":"PN"}]}}
{"text":"マジかたじけないございましたー","result":{"sentiment":"Neutral","score":0.27355211994418566,"emotional_phrase":[{"form":"マジかたじけないございましたー","emotion":"PN"}]}}
{"text":"超かたじけないございましたー","result":{"sentiment":"Neutral","score":0.27355211994418566,"emotional_phrase":[{"form":"超かたじけないございましたー","emotion":"PN"}]}}
{"text":"かたじけないございましたー","result":{"sentiment":"Neutral","score":0.27355211994418566,"emotional_phrase":[{"form":"かたじけないございましたー","emotion":"PN"}]}}
```

### 基本ワード

``` json
{"text":"多謝","result":{"sentiment":"Positive","score":0.18320426951423588,"emotional_phrase":[{"form":"多謝","emotion":"喜ぶ"}]}}
{"text":"ありがとう","result":{"sentiment":"Positive","score":0.18417957185162692,"emotional_phrase":[{"form":"ありがとう","emotion":"喜ぶ"}]}}
{"text":"ありがと","result":{"sentiment":"Positive","score":0.18417957185162692,"emotional_phrase":[{"form":"ありがと","emotion":"喜ぶ"}]}}
{"text":"かたじけない","result":{"sentiment":"Neutral","score":0.3032396750204326,"emotional_phrase":[{"form":"かたじけない","emotion":"PN"}]}}
{"text":"恩に着る","result":{"sentiment":"Neutral","score":0.30588907405608484,"emotional_phrase":[]}}
{"text":"ども","result":{"sentiment":"Neutral","score":0.3140117003315527,"emotional_phrase":[]}}
{"text":"あざす","result":{"sentiment":"Neutral","score":0.3140117003315527,"emotional_phrase":[]}}
{"text":"さんきゅ","result":{"sentiment":"Neutral","score":0.3140117003315527,"emotional_phrase":[]}}
{"text":"サンクス","result":{"sentiment":"Neutral","score":0.3140117003315527,"emotional_phrase":[]}}
{"text":"thx","result":{"sentiment":"Neutral","score":0.3140117003315527,"emotional_phrase":[]}}
{"text":"感謝","result":{"sentiment":"Positive","score":0.5975354606357581,"emotional_phrase":[{"form":"感謝","emotion":"P"}]}}
```

最後のやつだけ見ても「感謝」がダントツですね、**「ども」とか全然感謝してなくてやばい**です。

以上です。

なんか、一年分くらい感謝した気がします。

ここまで読んでくれてマジ感謝ね