immosquare-yaml 0.1.21 → 0.1.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/immosquare-yaml/translate.rb +14 -6
- data/lib/immosquare-yaml/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ffd34ab4fce7d19ca43f4116c404ec6b419d72613752deae7400988cf26b2cb
|
4
|
+
data.tar.gz: 781daefa41c64ddbb5498bbcd0819980f1326378947a886e5a2a3d8a0aa775a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '080b28c941dca4ff82714c01ad5b3301ab7ae0d6867e10c8d2a4021f1d954a3db9ca40d519a8a241cb19c1fe02183c7bdf98a3f0fb45ee80ed5e897d315fde13'
|
7
|
+
data.tar.gz: 88177866769f1672b7a040cccea44139978b00b5dee6b0b3d07af65103a0ac9aa9a8eea04ba9b068ae6b9b8fdacaf5112ad2b101f7858184a124f1a73398691c
|
@@ -92,8 +92,12 @@ module ImmosquareYaml
|
|
92
92
|
##============================================================##
|
93
93
|
## Then we have to reformat the output yml file
|
94
94
|
##============================================================##
|
95
|
-
final_array = translated_array.map
|
96
|
-
|
95
|
+
final_array = translated_array.map do |k, _from, to|
|
96
|
+
parsed_to = to.start_with?("[") && to.end_with?("]") ? JSON.parse(to) : to
|
97
|
+
[k, parsed_to]
|
98
|
+
end
|
99
|
+
final_hash = translatable_hash(final_array)
|
100
|
+
|
97
101
|
|
98
102
|
##============================================================##
|
99
103
|
## We write the output file and clean it
|
@@ -136,7 +140,7 @@ module ImmosquareYaml
|
|
136
140
|
end
|
137
141
|
else
|
138
142
|
r2 = options[:format] == "string" ? key.split(":").join(".") : key.split(":")
|
139
|
-
result << (options[:keys_only] ? r2 : [r2, hash])
|
143
|
+
result << (options[:keys_only] ? r2 : [r2, hash.is_a?(Array) ? hash.to_json : hash])
|
140
144
|
end
|
141
145
|
result
|
142
146
|
end
|
@@ -181,7 +185,7 @@ module ImmosquareYaml
|
|
181
185
|
{:name => "gpt-4-1106-preview", :tokens => 128_000, :input => 0.0100, :output => 0.030, :group_size => 2400}
|
182
186
|
]
|
183
187
|
model = models.find {|m| m[:name] == model_name }
|
184
|
-
model = models.find {|m| m[:name] == "gpt-
|
188
|
+
model = models.find {|m| m[:name] == "gpt-4-1106-preview" } if model.nil?
|
185
189
|
|
186
190
|
##============================================================##
|
187
191
|
## Manage blank values
|
@@ -229,12 +233,16 @@ module ImmosquareYaml
|
|
229
233
|
prompt_system = "You are a translation tool from #{from_iso} to #{to_iso}\n" \
|
230
234
|
"The input is an array of pairs, where each pair contains an index and a string to translate, formatted as [index, string_to_translate]\n" \
|
231
235
|
"Your task is to create an output ARRAY where each element is a pair consisting of the index and the translated string, formatted as [index, 'string_translated']\n" \
|
232
|
-
"
|
236
|
+
"If a string_to_translate starts with [ and ends with ], it is considered a special string that should be treated as a JSON object. Otherwise, it's a normal string.\n" \
|
237
|
+
"\nRules to respect for JSON objects:\n" \
|
238
|
+
"- You need to translate ONLY the values of the JSON object, not the keys. Do not change anything in the format, just translate the values.\n" \
|
239
|
+
"- Respect all following rules for normal strings to translate the values\n" \
|
240
|
+
"\nRules to respect for normal strings:\n" \
|
233
241
|
"- Do not escape apostrophes in translated strings; leave them as they are.\n" \
|
234
242
|
"- Special characters, except apostrophes, that need to be escaped in translated strings should be escaped using a single backslash (\\), not double (\\\\).\n" \
|
235
243
|
"- If a string cannot be translated use the string '#{cant_be_translated}' translated as the translation value witouth quote (simple or double) quote, just the string\n" \
|
236
244
|
"- If you dont know the correct translatation use the #{cant_be_translated} strategy of the preceding point\n" \
|
237
|
-
"- Use only
|
245
|
+
"- Use only double quotes (\") to enclose translated strings and avoid using single quotes (').\n" \
|
238
246
|
"- Your output must ONLY be an array with the same number of pairs as the input, without any additional text or explanation. DO NOT COMMENT!\n" \
|
239
247
|
"- You need to check that the globle array is correctly closed at the end of the response. (the response must therefore end with ]] to to be consistent)"
|
240
248
|
prompt_init = "Please proceed with translating the following array:"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: immosquare-yaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IMMO SQUARE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|