Update README.md
Browse files
README.md
CHANGED
@@ -160,4 +160,41 @@ If you are training a model for 10 different languages, then you will need to tr
|
|
160 |
This is possible, but it is not easy.
|
161 |
You can train a model for a specific language, say English, by training a model for that language. Then, when you train the model for 10 other languages, you will need to train a model for the 10 languages that don't have the same English as the one you trained for.
|
162 |
This is what
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
```
|
|
|
160 |
This is possible, but it is not easy.
|
161 |
You can train a model for a specific language, say English, by training a model for that language. Then, when you train the model for 10 other languages, you will need to train a model for the 10 languages that don't have the same English as the one you trained for.
|
162 |
This is what
|
163 |
+
```
|
164 |
+
|
165 |
+
```
|
166 |
+
user: dog, cat, mouse, {}
|
167 |
+
assistant:
|
168 |
+
Assistant's response:
|
169 |
+
dog, cat, mouse, {}
|
170 |
+
|
171 |
+
I have a function that returns the list of items from the object.
|
172 |
+
def get_items(items):
|
173 |
+
for item in items:
|
174 |
+
return [item]
|
175 |
+
|
176 |
+
I would like to do something like this
|
177 |
+
assistant = get_items(items)
|
178 |
+
|
179 |
+
or
|
180 |
+
cat = get_items(items)
|
181 |
+
|
182 |
+
A:
|
183 |
+
|
184 |
+
You can use itertools.izip_longest() to zip all of the items together and then get the first item.
|
185 |
+
import itertools
|
186 |
+
|
187 |
+
items = [dog, cat, mouse, {}]
|
188 |
+
|
189 |
+
result = list(itertools.izip_longest(items, key=lambda x: x))
|
190 |
+
|
191 |
+
# [dog, cat, mouse, {}]
|
192 |
+
|
193 |
+
If you really want to use a list comprehension, you can do it like this:
|
194 |
+
result = [item for item in items if item]
|
195 |
+
|
196 |
+
If you really want to use a dictionary instead of a list, you can do this:
|
197 |
+
result = {item: item for item in items if item}
|
198 |
+
|
199 |
+
You can use a dictionary in this case because it will allow you to iterate over the keys and values of the dictionary
|
200 |
```
|