I want to convert a text file into a json lines format using Python. I need this to be applicable to a text file of any length (in characters or words).
As an example, I want to convert the following text;
A lot of effort in classification tasks is placed on feature engineering and parameter optimization, and rightfully so.
These steps are essential for building models with robust performance. However, all these efforts can be wasted if you choose to assess these models with the wrong evaluation metrics.
To this:
{"text": "A lot of effort in classification tasks is placed on feature engineering and parameter optimization, and rightfully so."}
{"text": "These steps are essential for building models with robust performance. However, all these efforts can be wasted if you choose to assess these models with the wrong evaluation metrics."}
I tried this:
text = ""
with open(text.txt", encoding="utf8") as f:
for line in f:
text = {"text": line}
But not luck.