File size: 994 Bytes
53bbcda
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4d17e32
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from datasets import Dataset

# Prepare your data
data = [
    {"source_text": "Hello, how are you?", "target_text": "مرحبا كيف حالك؟"},
    {"source_text": "I am fine, thank you.", "target_text": "أنا بخHere's the complete code to prepare and upload a translation dataset to Hugging Face using the `datasets` library:

```python
from datasets import Dataset

# Prepare your data
data = [
    {"source_text": "Hello, how are you?", "target_text": "مرحبا كيف حالك؟"},
    {"source_text": "I am fine, thank you.", "target_text": "أنا بخير، شكراً لك."},
    {"source_text": "What is your name?", "target_text": "ما هو اسمك؟"},
    ...
]

# Convert your data into a format compatible with Hugging Face
dataset = Dataset.from_dict(data)
dataset = dataset.rename_column("source_text", "input_text")
dataset = dataset.rename_column("target_text", "target_text")

# Upload your data to Hugging Face
dataset.save_to_disk("translation_dataset")

---