tx_nlp 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5800285825c313f62401bd491955f3cf2e0fcf7d6c3da29990bdb4d560b444c6
4
- data.tar.gz: e4105394c93a14aced24daa7a16397f547b92e2846d77c8ce424b3b1a48a7637
3
+ metadata.gz: e914bda4a52e36667d6a75f4c37266f09ece8f25d85aeed0410b76b2d6d7ecd1
4
+ data.tar.gz: 514d34ff0ca8a7ffff41544643ac0d427caa85be45ea660ed6ea2e686e1b46fc
5
5
  SHA512:
6
- metadata.gz: ce6816dc4d2cec92b37dff6da71cddc068ce19ac3a990fd2a1d4681c7e2dfe7327b81b7ed79296282fdc19091101d1c66a72b81cb4591ae0798ae2dff28d95b2
7
- data.tar.gz: a9f8608198ce02359ee728251be5821ac0e6129462f50ffb263e2a97bd50292eb500e7499742ba88a752596ceb8642ce34e1845789c7e832b3921f7a774b3b10
6
+ metadata.gz: ce3748b5606118327d9ae31193d22e31441c8ce6783deb64944561c3793f7834249f89d0f77cc7af214f01e9d2f9b21ea846a35c41522b59499d8867dead5a5d
7
+ data.tar.gz: 32d2d8aa5e2197938fb923e65966fd272eb32b3938446eaec08546db0c1bec8f6a1a8a7391438af09fa3288b0792059c0f54ce62d2fb10aaf7268123fbdfadb0
data/Gemfile.lock CHANGED
@@ -1,11 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tx_nlp (0.0.3)
4
+ tx_nlp (0.0.4)
5
5
  activesupport
6
6
  httparty
7
7
  json
8
- tencent_cos_sdk
9
8
  thor
10
9
 
11
10
  GEM
@@ -17,45 +16,23 @@ GEM
17
16
  minitest (~> 5.1)
18
17
  tzinfo (~> 1.1)
19
18
  zeitwerk (~> 2.2)
20
- colorize (0.8.1)
21
19
  concurrent-ruby (1.1.5)
22
- domain_name (0.5.20190701)
23
- unf (>= 0.0.5, < 1.0.0)
24
- http-accept (1.7.0)
25
- http-cookie (1.0.3)
26
- domain_name (~> 0.5)
27
20
  httparty (0.17.1)
28
21
  mime-types (~> 3.0)
29
22
  multi_xml (>= 0.5.2)
30
23
  i18n (1.7.0)
31
24
  concurrent-ruby (~> 1.0)
32
- ipaddr (1.2.2)
33
25
  json (2.2.0)
34
26
  mime-types (3.3)
35
27
  mime-types-data (~> 3.2015)
36
28
  mime-types-data (3.2019.1009)
37
29
  minitest (5.13.0)
38
30
  multi_xml (0.6.0)
39
- netrc (0.11.0)
40
- openssl (2.1.2)
41
- ipaddr
42
31
  rake (10.5.0)
43
- rest-client (2.1.0)
44
- http-accept (>= 1.7.0, < 2.0)
45
- http-cookie (>= 1.0.2, < 2.0)
46
- mime-types (>= 1.16, < 4.0)
47
- netrc (~> 0.8)
48
- tencent_cos_sdk (0.2.2)
49
- colorize (~> 0.8)
50
- openssl (~> 2.1)
51
- rest-client (~> 2.0)
52
32
  thor (0.20.3)
53
33
  thread_safe (0.3.6)
54
34
  tzinfo (1.2.5)
55
35
  thread_safe (~> 0.1)
56
- unf (0.1.4)
57
- unf_ext
58
- unf_ext (0.0.7.6)
59
36
  zeitwerk (2.2.1)
60
37
 
61
38
  PLATFORMS
data/lib/tx_nlp.rb CHANGED
@@ -3,7 +3,7 @@ require 'tx_nlp/version'
3
3
  require 'tx_nlp/cli'
4
4
  require 'tx_nlp/base'
5
5
  require 'tx_nlp/text'
6
-
6
+ require 'tx_nlp/keyword'
7
7
  module TxNlp
8
8
  # Your code goes here...
9
9
  end
data/lib/tx_nlp/base.rb CHANGED
@@ -3,19 +3,11 @@ require 'httparty'
3
3
  require 'json'
4
4
  require 'cgi'
5
5
  require 'uri'
6
- require 'tencent_cos_sdk'
7
6
 
8
7
  module TxNlp
9
8
  class Base
10
9
  HOST = 'nlp.tencentcloudapi.com'
11
10
 
12
- TencentCosSdk.configure do |conf|
13
- conf.secret_id = TxNlp.config[:secret_id]
14
- conf.secret_key = TxNlp.config[:secret_key]
15
- conf.host = "#{TxNlp.config[:bucket]}.cos.#{TxNlp.config[:region]}.myqcloud.com"
16
- end
17
-
18
-
19
11
  def region
20
12
  TxNlp.config[:region]
21
13
  end
data/lib/tx_nlp/cli.rb CHANGED
@@ -27,6 +27,11 @@ module TxNlp
27
27
  puts TxNlp::Text.new(word).indent_result
28
28
  end
29
29
 
30
+ desc 'tx_nlp 句子 ', '抽取關鍵字'
31
+ def keyword(keyword)
32
+ puts TxNlp::Keyword.new(keyword).indent_result
33
+ end
34
+
30
35
  private
31
36
 
32
37
  def display_name(name)
@@ -37,7 +37,7 @@ module TxNlp
37
37
  if yml_file
38
38
  @config = yml_file
39
39
  else
40
- File.open(yml_path, 'w') { |f| YAML.dump(@config, f) }
40
+ @config = nil
41
41
  end
42
42
  end
43
43
 
@@ -0,0 +1,28 @@
1
+ module TxNlp
2
+ class Keyword < Base
3
+ def initialize(text, action_type = 'KeywordsExtraction')
4
+ @action_type = action_type
5
+ @encode_text = text.tr("\n", ' ')
6
+ @escape_text = CGI.escape(@encode_text)
7
+ end
8
+
9
+ def raw_result
10
+ if json['Response']['Error']
11
+ json
12
+ else
13
+ original_data = json['Response']["Keywords"]
14
+ end
15
+ end
16
+
17
+ def indent_result
18
+ if json['Response']['Error']
19
+ json
20
+ else
21
+ new_content = raw_result.join(',')
22
+
23
+ new_content
24
+ end
25
+ end
26
+ end
27
+
28
+ end
data/lib/tx_nlp/text.rb CHANGED
@@ -8,5 +8,23 @@ module TxNlp
8
8
  @escape_text = CGI.escape(@encode_text)
9
9
  end
10
10
 
11
+ def raw_result
12
+ if json['Response']['Error']
13
+ json
14
+ else
15
+ original_data = json['Response']["SimilarWords"]
16
+ end
17
+ end
18
+
19
+ def indent_result
20
+ if json['Response']['Error']
21
+ json
22
+ else
23
+ new_content = raw_result.join(',')
24
+
25
+ new_content
26
+ end
27
+ end
28
+
11
29
  end
12
30
  end
@@ -1,3 +1,3 @@
1
1
  module TxNlp
2
- VERSION = '0.0.3'.freeze
2
+ VERSION = '0.0.4'.freeze
3
3
  end
data/tx_nlp.gemspec CHANGED
@@ -29,5 +29,4 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency 'httparty'
30
30
  spec.add_dependency 'json'
31
31
  spec.add_dependency 'thor'
32
- spec.add_dependency 'tencent_cos_sdk'
33
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tx_nlp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - xdite
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-13 00:00:00.000000000 Z
11
+ date: 2020-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,20 +94,6 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: tencent_cos_sdk
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
97
  description: Tencent NLP CLI
112
98
  email:
113
99
  - xuite.joke@gmail.com
@@ -128,6 +114,7 @@ files:
128
114
  - lib/tx_nlp/base.rb
129
115
  - lib/tx_nlp/cli.rb
130
116
  - lib/tx_nlp/helper/config_helper.rb
117
+ - lib/tx_nlp/keyword.rb
131
118
  - lib/tx_nlp/text.rb
132
119
  - lib/tx_nlp/version.rb
133
120
  - templates/settings.yml.tt