tx_nlp 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -24
- data/lib/tx_nlp.rb +1 -1
- data/lib/tx_nlp/base.rb +0 -8
- data/lib/tx_nlp/cli.rb +5 -0
- data/lib/tx_nlp/helper/config_helper.rb +1 -1
- data/lib/tx_nlp/keyword.rb +28 -0
- data/lib/tx_nlp/text.rb +18 -0
- data/lib/tx_nlp/version.rb +1 -1
- data/tx_nlp.gemspec +0 -1
- metadata +3 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e914bda4a52e36667d6a75f4c37266f09ece8f25d85aeed0410b76b2d6d7ecd1
|
4
|
+
data.tar.gz: 514d34ff0ca8a7ffff41544643ac0d427caa85be45ea660ed6ea2e686e1b46fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
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
@@ -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
|
data/lib/tx_nlp/version.rb
CHANGED
data/tx_nlp.gemspec
CHANGED
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.
|
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:
|
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
|