Commit
·
dd03977
1
Parent(s):
f7813f0
Upload 3 files
Browse files- convert.py +6 -6
- train.csv +0 -0
convert.py
CHANGED
@@ -10,14 +10,14 @@ output_file = 'train.csv'
|
|
10 |
with open(input_file, 'r', encoding='utf-8') as file:
|
11 |
paragraphs = file.read().split('\n\n') # Adjust the split pattern based on your paragraph format
|
12 |
|
13 |
-
# Create a CSV writer and write the paragraphs into the CSV file
|
14 |
with open(output_file, 'w', newline='', encoding='utf-8') as csvfile:
|
15 |
csv_writer = csv.writer(csvfile)
|
16 |
|
17 |
-
# Use a loop to
|
18 |
for i in range(len(paragraphs)):
|
19 |
-
prompt = ' '.join(paragraphs[i:i + 2]) # Combine two paragraphs for the prompt
|
20 |
-
continuation = ' '.join(paragraphs[i + 2:i + 7]) # Combine five paragraphs for the continuation
|
21 |
|
22 |
-
#
|
23 |
-
csv_writer.writerow([prompt.strip()
|
|
|
10 |
with open(input_file, 'r', encoding='utf-8') as file:
|
11 |
paragraphs = file.read().split('\n\n') # Adjust the split pattern based on your paragraph format
|
12 |
|
13 |
+
# Create a CSV writer and write the combined paragraphs into the CSV file
|
14 |
with open(output_file, 'w', newline='', encoding='utf-8') as csvfile:
|
15 |
csv_writer = csv.writer(csvfile)
|
16 |
|
17 |
+
# Use a loop to combine prompt and continuation in the same column with appropriate tags
|
18 |
for i in range(len(paragraphs)):
|
19 |
+
prompt = '###Human ' + ' '.join(paragraphs[i:i + 2]) # Combine two paragraphs for the prompt
|
20 |
+
continuation = '###Assistant ' + ' '.join(paragraphs[i + 2:i + 7]) # Combine five paragraphs for the continuation
|
21 |
|
22 |
+
# Combine the prompt and continuation in the same column and write to the CSV
|
23 |
+
csv_writer.writerow([prompt.strip() + ' ' + continuation.strip()])
|
train.csv
CHANGED
The diff for this file is too large to render.
See raw diff
|
|