user_local_chat_api 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7981f8052ab34a13e07fc6c147994e87ab324c8
4
- data.tar.gz: c46d1fe9dc2fa4d7ef07ea296f356ce9f842b7e5
3
+ metadata.gz: 8b52094b014039626ed55e8f16e1db93d8eb37e9
4
+ data.tar.gz: 1bbe3a9a3d6f466c42b51c16fed73a0924bdf39f
5
5
  SHA512:
6
- metadata.gz: 63ed113657673a8eda17a2310a4236dc0e7fc9499f3e3481b3a5e199426b5cb037fbba29f7b95667358de491000f01760f6756383162ae70499ad7008ed6eca5
7
- data.tar.gz: 16799eef6ebc7a22d153ad0ef94dec8cd3bf18ce979ee0138402540e7ca8e84b42be6bcf8972452653d33a6ebff16ddc60eb9e2837afb8183fb15fefa82f4954
6
+ metadata.gz: 3e97e7b18d37b2a86ab8571162e100f119302cec4a01da11cf6aac0db3cfebe3c6cf7d43dc85c23192e1deef1c203b31d3b95b2cc680dfdd2eb76531007c21ec
7
+ data.tar.gz: c179df0e29e5d76be5e5c1a5019cff7d794ccb5f8e09843779a6c67f04ef2df33c4658bb45f9228fda92fc38d93db58f6a11cb769871b3da43ace36633ac66e9
data/README.md CHANGED
@@ -23,10 +23,70 @@ gem 'user_local_chat_api'
23
23
 
24
24
  client = UserLocalChatApi::Client.new('{access token}')
25
25
 
26
- p client.chat("こんにちは") # => {"status"=>"success", "result"=>"こんにちは"}
27
- p client.character("ねむいな", "cat") # => {"status"=>"success", "result"=>"ねむいニャ"}
28
- p client.name("田中太郎") # => {"status"=>"success", "result"=>{"last_name"=>"田中", "last_name_yomi"=>"たなか", "first_name"=>"太郎", "first_name_yomi"=>"たろう", "gender"=>1, "gender_accuracy"=>4, "nickname"=>["たろぴー", "たろたん", "たろちゃん", "たろぽん", "たなきち", "たろたろー", "たろすけ", "たろべえ", "たろっち", "たーちゃ", "太太郎"]}}
29
- p client.decompose("公園にキレイな花が咲いていました。") # => {"status"=>"success", "result"=>[{"surface"=>"公園", "pos"=>"名詞", "origin"=>"公園", "yomi"=>"コウエン"}, {"surface"=>"に", "pos"=>"助詞", "origin"=>"に", "yomi"=>"ニ"}, {"surface"=>"キレイ", "pos"=>"名詞", "origin"=>"キレイ", "yomi"=>"キレイ"}, {"surface"=>"な", "pos"=>"助動詞", "origin"=>"だ", "yomi"=>"ナ"}, {"surface"=>"花", "pos"=>"名詞", "origin"=>"花", "yomi"=>"ハナ"}, {"surface"=>"が", "pos"=>"助詞", "origin"=>"が", "yomi"=>"ガ"}, {"surface"=>"咲い", "pos"=>"動詞", "origin"=>"咲く", "yomi"=>"サイ"}, {"surface"=>"て", "pos"=>"助詞", "origin"=>"て", "yomi"=>"テ"}, {"surface"=>"い", "pos"=>"動詞", "origin"=>"いる", "yomi"=>"イ"}, {"surface"=>"まし", "pos"=>"助動詞", "origin"=>"ます", "yomi"=>"マシ"}, {"surface"=>"た", "pos"=>"助動詞", "origin"=>"た", "yomi"=>"タ"}, {"surface"=>"。", "pos"=>"記号", "origin"=>"。", "yomi"=>"。"}]}
26
+ # 自動会話API
27
+ # ユーザー入力メッセージに対し、自然な受け答えを返す
28
+ p client.chat("こんにちは")
29
+ # => {
30
+ # "status" => "success",
31
+ # "result" => "こんにちはっ"
32
+ # }
33
+
34
+ # キャラクター会話変換API
35
+ # ネコやイヌなどの語尾に自動変換する 例)愉快ですね→愉快だニャ
36
+ p client.character("ねむいな", "cat")
37
+ # => {
38
+ # "status" => "success",
39
+ # "result" => "ねむいニャ"
40
+ # }
41
+
42
+ # 氏名自動識別API
43
+ # 会話中の相手の名前をもとに性別判定したり、姓・名を切り分ける
44
+ p client.name("田中太郎")
45
+ # => {
46
+ # "status" => "success",
47
+ # "result" => {
48
+ # "last_name" => "田中",
49
+ # "last_name_yomi" =>"たなか",
50
+ # "first_name" => "太郎",
51
+ # "first_name_yomi" => "たろう",
52
+ # "gender" => 1,
53
+ # "gender_accuracy" => 4,
54
+ # "nickname" => [
55
+ # "たろぴー",
56
+ # "たろたん",
57
+ # "たろちゃん",
58
+ # "たろぽん",
59
+ # "たなきち",
60
+ # "たろたろー",
61
+ # "たろすけ",
62
+ # "たろべえ",
63
+ # "たろっち",
64
+ # "たーちゃ",
65
+ # "太太郎"
66
+ # ]
67
+ # }
68
+ # }
69
+
70
+ # 形態素解析API
71
+ # 文章を単語に分割・活用形抽出するAPI
72
+ p client.decompose("公園にキレイな花が咲いていました。")
73
+ # => {
74
+ # "status" => "success",
75
+ # "result" => [
76
+ # { "surface" => "公園", "pos" => "名詞", "origin" => "公園", "yomi" => "コウエン" },
77
+ # { "surface" => "に", "pos" => "助詞", "origin" => "に", "yomi" => "ニ" },
78
+ # { "surface" => "キレイ", "pos" => "名詞", "origin" => "キレイ", "yomi" => "キレイ" },
79
+ # { "surface" => "な", "pos" => "助動詞", "origin" => "だ", "yomi" => "ナ" },
80
+ # { "surface" => "花", "pos" => "名詞", "origin" => "花", "yomi" => "ハナ" },
81
+ # { "surface" => "が", "pos" => "助詞", "origin" => "が", "yomi" => "ガ" },
82
+ # { "surface" => "咲い", "pos" => "動詞", "origin" => "咲く", "yomi" => "サイ" },
83
+ # { "surface" => "て", "pos" => "助詞", "origin" => "て", "yomi" => "テ" },
84
+ # { "surface" => "い", "pos" => "動詞", "origin" => "いる", "yomi" => "イ" },
85
+ # { "surface" => "まし", "pos" => "助動詞", "origin" => "ます", "yomi" => "マシ" },
86
+ # { "surface" => "た", "pos" => "助動詞", "origin" => "た", "yomi" => "タ" },
87
+ # { "surface" => "。", "pos" => "記号", "origin" => "。", "yomi" => "。" }
88
+ # ]
89
+ # }
30
90
  ```
31
91
 
32
92
  ## Development
@@ -37,7 +97,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
37
97
 
38
98
  ## Contributing
39
99
 
40
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/user_local_chat_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
100
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ytkg/user_local_chat_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
41
101
 
42
102
 
43
103
  ## License
@@ -11,34 +11,44 @@ module UserLocalChatApi
11
11
  @access_token = access_token || ENV['USER_LOCAL_ACCESS_TOKEN']
12
12
  end
13
13
 
14
- def chat(msg)
15
- url = "#{DEFAULT_URL}/chat?key=#{@access_token}&message=#{msg}"
16
- response(url)
14
+ def chat(msg, user_name = nil)
15
+ params = {
16
+ message: msg,
17
+ user_name: user_name,
18
+ }
19
+ response("chat", params)
17
20
  end
18
21
 
19
22
  def character(msg, character_type = nil)
20
- url = "#{DEFAULT_URL}/character?key=#{@access_token}&message=#{msg}&character_type=#{character_type}"
21
- response(url)
23
+ params = {
24
+ message: msg,
25
+ character_type: character_type,
26
+ }
27
+ response("character", params)
22
28
  end
23
29
 
24
30
  def name(name)
25
- url = "#{DEFAULT_URL}/name?key=#{@access_token}&message=#{name}"
26
- response(url)
31
+ params = { message: name }
32
+ response("name", params)
27
33
  end
28
34
 
29
- def decompose(msg)
30
- url = "#{DEFAULT_URL}/decompose?key=#{@access_token}&message=#{msg}"
31
- response(url)
35
+ def decompose(text, detail = false, cut_last_word = false)
36
+ params = {
37
+ message: text,
38
+ detail: detail,
39
+ cut_last_word: cut_last_word,
40
+ }
41
+ response("decompose", params)
32
42
  end
33
43
 
34
44
  private
35
- def response(url)
36
- url_escape = URI.escape(url)
37
- rest = RestClient.get(url_escape)
38
- result = JSON.parse(rest)
39
-
40
- result
41
- end
45
+ def response(type, params)
46
+ params[:key] = @access_token
47
+ params = URI.encode_www_form(params)
48
+ rest = RestClient.get("#{DEFAULT_URL}/#{type}?#{params}")
49
+ result = JSON.parse(rest)
42
50
 
51
+ result
52
+ end
43
53
  end
44
54
  end
@@ -1,3 +1,3 @@
1
1
  module UserLocalChatApi
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -6,8 +6,8 @@ require 'user_local_chat_api/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "user_local_chat_api"
8
8
  spec.version = UserLocalChatApi::VERSION
9
- spec.authors = ["ytkg"]
10
- spec.email = ["ytkg@ytkg.jp"]
9
+ spec.authors = ["Yoshiki Takagi"]
10
+ spec.email = ["yoshiki.tkg@gmail.com"]
11
11
 
12
12
  spec.summary = %q{A Ruby wrapper of User Local API}
13
13
  spec.homepage = "https://github.com/ytkg/user_local_chat_api"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: user_local_chat_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
- - ytkg
7
+ - Yoshiki Takagi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-22 00:00:00.000000000 Z
11
+ date: 2017-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '10.0'
55
55
  description:
56
56
  email:
57
- - ytkg@ytkg.jp
57
+ - yoshiki.tkg@gmail.com
58
58
  executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []