NAME

translate.pl - Translate a CSV file from German to English

SYNOPSIS

None.

DESCRIPTION

Note: You should read this code because without the sample CSV file, it won't work.

This is real code I wrote to solve a problem for a client. They provided access to their data to a graduate student who as working with a vector database to analyze a bunch of the company data for his thesis. There was no guarantee that the database would be useful for the client, but they asked me if it would make a good replacement for their search system.

I received a CSV file with about 14,000 sample rows and put them into the ChromaDB vector database and wrote some python code, using the student's code, to issue queries. However, the results were in German and I couldn't understand them. I wrote this code to translate the results from German to English so I could understand them.

The code uses the OpenAI API to translate the text. For the volume of data I was translating, it would have taken a professional translator weeks to do the work at a cost of tens of thousands of dollars. The OpenAI API did the work in five hours at a cost of $3.89. I spot-checked the results and they were pretty good. I didn't need perfect translations, just enough to understand the data.

Note that my solution is not perfect. It was a quick hack to get the job done. If you want to use this code, you'll need to adjust it for your needs.