|
import spacy |
|
import jsonlines |
|
|
|
|
|
model_path = "./my_trained_model" |
|
nlp = spacy.load(model_path) |
|
|
|
|
|
unlabeled_data_file = "data/train.jsonl" |
|
|
|
|
|
classified_data = [] |
|
with jsonlines.open(unlabeled_data_file) as reader: |
|
for record in reader: |
|
text = record["text"] |
|
doc = nlp(text) |
|
predicted_labels = doc.cats |
|
classified_data.append({"text": text, "predicted_labels": predicted_labels}) |
|
|
|
|
|
output_file = "data/thirdStep_file.jsonl" |
|
with jsonlines.open(output_file, mode="w") as writer: |
|
writer.write_all(classified_data) |
|
|