Update few-shot-pe-llm-0.py
Browse files- few-shot-pe-llm-0.py +15 -6
few-shot-pe-llm-0.py
CHANGED
@@ -1,12 +1,21 @@
|
|
1 |
def few_shot_pe_llm_0():
|
2 |
pipe = pipeline("text-classification", model="kolkata97/autotrain-pe-llm-0")
|
|
|
|
|
3 |
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
|
12 |
-
print(
|
|
|
1 |
def few_shot_pe_llm_0():
|
2 |
pipe = pipeline("text-classification", model="kolkata97/autotrain-pe-llm-0")
|
3 |
+
|
4 |
+
predicted_categories = []
|
5 |
|
6 |
+
for sentence in sentences_list:
|
7 |
+
results = pipe(sentence)
|
8 |
+
predicted_categories.append(results[0]['label'])
|
9 |
|
10 |
+
with open(output_csv_file, 'r', newline='', encoding='utf-8') as file:
|
11 |
+
csv_reader = csv.reader(file)
|
12 |
+
rows = list(csv_reader)
|
13 |
+
|
14 |
+
for i, row in enumerate(rows[1:], start=0):
|
15 |
+
row.append(predicted_categories[i])
|
16 |
|
17 |
+
with open(output_csv_file, 'w', newline='', encoding='utf-8') as file:
|
18 |
+
writer = csv.writer(file)
|
19 |
+
writer.writerows(rows)
|
20 |
|
21 |
+
print("Predicted categories appended to the CSV file.")
|