llm_translator 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 +4 -4
- data/lib/llm_translator.rb +11 -3
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2eaa70543efe06ebcff7a1eca548dc36e8ab0983a7d3b180b5953fec12c2c71f
|
4
|
+
data.tar.gz: 249fc33eb499585ac53bb95bbd1c4156c6c562d411752befd34c3946df0fd5f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 390b2f53bb562d431eb203aa007a1a46dbb9ad2a079abaa116de33007769eac1dadc30576650e411057ff0699d6dd19dff5aee27ab97647c225ce9b83e66b7a8
|
7
|
+
data.tar.gz: 423480766fcc286f93840540fc75bead95bcbb6a7a2cf7ded757faeb0c55393bbdc8c0e777abd33ade79457e9c1ab5ea6cfa1cea107c44c537df39f2039589a3
|
data/lib/llm_translator.rb
CHANGED
@@ -121,14 +121,20 @@ LANG_CODE = %|
|
|
121
121
|
|
122
122
|
class LlmTranslator
|
123
123
|
|
124
|
-
|
124
|
+
CONFIG_PATH = File.expand_path('~/.llm_translator')
|
125
|
+
attr_accessor :text,
|
126
|
+
:history,
|
125
127
|
:auto, # 自动中英互译
|
126
128
|
:detail, # 详细翻译
|
127
129
|
:from, # 源语言
|
128
130
|
:to # 目标语言
|
129
131
|
|
130
132
|
def initialize(text)
|
133
|
+
if !Dir.exists?(CONFIG_PATH)
|
134
|
+
Dir.mkdir(CONFIG_PATH)
|
135
|
+
end
|
131
136
|
@text = text
|
137
|
+
@history= File.open("#{CONFIG_PATH}/history.csv", 'a+')
|
132
138
|
@url = 'https://openapi.youdao.com/api'
|
133
139
|
@appkey = '0b53e81a10846a3a'
|
134
140
|
@appscr = 'JLKxQO22jBft6w3PgLBh5as5iNJ1w5wS'
|
@@ -156,9 +162,11 @@ class LlmTranslator
|
|
156
162
|
end
|
157
163
|
|
158
164
|
def run
|
159
|
-
|
165
|
+
result = to_result()
|
166
|
+
history.write("#{text} #{result['translation'][0]} #{Time.now}\n") if @history
|
167
|
+
return result if @detail
|
160
168
|
|
161
|
-
|
169
|
+
result['translation'][0]
|
162
170
|
end
|
163
171
|
|
164
172
|
def command(args)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: llm_translator
|
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
|
- Liuliming
|
@@ -39,8 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
requirements: []
|
42
|
-
|
43
|
-
rubygems_version: 2.7.6.2
|
42
|
+
rubygems_version: 3.2.3
|
44
43
|
signing_key:
|
45
44
|
specification_version: 4
|
46
45
|
summary: a simple translator!
|