In the last video you saw how to carry out text classification. That is, to look at a piece of text and classify it as a relevant or not relevant to food. In this video, you see how the process takes in an even deeper way in which we have a large language model look at the document and extract particular bits of information like restaurants and food dish names that you can then use elsewhere. You see how you can highlight this extracted information and save it to a new file for easy reading. Let's take a look at how to do that. As you've seen before, the journal entries we have for different destinations may contain restaurants as well as interesting dishes to try at said restaurants. And after extracting this information, you might want to save it in a little table that looks like this. That'll make it easy when you are in that city to figure out where to go eat. So let's run this code to load Rio de Janeiro dot text. Read journal is a function that opens the text file reads the text, and in this case saves it into the variable journal Rio de Janeiro. Later in this course, you see for yourself how to build a function like read journal. Now given this variable, here is a prompt. Given the following journal entry for food critic. Identify restaurants and best dishes, highlight and point each restaurant Identify restaurants and best dishes, highlight and point each restaurant and best dish within the original text. And we want a large language model to provide the output as HTML suitable for display that Jupyter notebook. So, web pages are formatted using HTML. So this lets us use a lot of rich formatting like write text in orange or in blue. So there's the prompt with the journal entry down here below. Now let's call the large language model and get the response for that prompt. And we are going to get the response in HTML. And let's print this out. And you see that the large language model has output to HTML. P tells it to start the paragraph. These are called HTML tags to specify the formatting. If you want to display the actual HTML, you can use this command. We're going to display HTML, and then the response I had above. And now this prints out this nicely formatted HTML with the orange coding of the restaurants. And then blue coding of the dish names. Now let's do the same for the Tokyo journal entry. journal entry. Here's a code. Let's read Tokyo. Same prompt as before. Get the HTML response and then display that. So let's run that here. And look's like it has done a pretty good job naming the restaurants in orange and dishes in blue. Even though this piece of text was formatted very differently than the Rio de Janeiro journal entry, the large language model was able to process that. I then encourage you to experiment with the prompt, and maybe here's one challenge for you. Can you change this prompt to highlight any desserts in green? Or maybe try changing the code to add an emoji next to every ingredient? Let's see if instead of just highlighting certain pieces of information in different colors, we can modify the prompts to extract information from the text. So here's a prompt I'm going to use. Please extract comprehensive list of a restaurants and their respective dishes mentioned in the following journal entry. Ensure that each restaurant name is accurately identified and listed. And here we are saying provide your answer in CSV format, ready to save. CSV stands for comma separated values. CSV is a very common format for a computer to store information that looks like tables. So I think a good way to understand this is just run it and look at an example. So the first row of the CSV file tells you what is the data that will appear in each row. And each row will have a restaurant name comma and the a dish name. And the first restaurant is this, followed by this dish name. Next row is this restaurant followed by this dish name. And so on. You can think of this as how the computer is representing a table with two columns, where the first column is of restaurants and the second column which is up the dishes. Now, with a prompt like this, you can also iterate through all the journal entries you have. So let's walk through this code step by step. I have here list of files Cape Town, Istanbul, New York, and so on. And we're going to use a for loop so that for each file in "this files", read the journal entry from that file name and it will ask it extract the comprehensive list of the restaurants and the dishes. And then I'll put it in CSV. And then for every one of these files will print out the name of the file and then print out the large language model response. And this command just prints an empty line. So let's run it. Cape Town, here are the dishes. Istanbul. Went to Istanbul as a teenager and loved it. What a great city. New York. Fantastic restaurants in New York. Paris, Rio de Janeiro, Sydney, Tokyo. And so you saw the code call through all of this data in just a few seconds. Imagine how long it would have taken you to open up these files, one at a time, and read through it and extract the dishes. So I hope you can maybe imagine how large language models can become more and more useful as the volume of files you have to analyze increases. I think with all the time you save, you can maybe now have more time to spend in some of these delicious restaurants. I encourage you to try out different versions of this prompt. So, for example, maybe you can try modify the prompt to extract the restaurant and its neighborhood if known, or extract the dish name, add the main ingredient to that dish. So we're almost to the end of this lesson. Before we wrap up, I just want to demonstrate how to open files to save data to files. So recall that previously we had generated this HTML response. And so to save the content of this variable HTML response into a file, here's a code you can use to do so. I'm going to say f equals open highlighted text HTML. So that's my file name. And now instead of "R" I'm going to write "W" because I want to write "W" for write. Rather than "R" for read. And F dot write the content of HTML response. And lastly, when we're done, let's close the file. The main difference between this and opening files to read them is "W" instead of "R" to write instead of read, and then you use F dot write as the F dot read. If you want to better understand what this code is doing, ask the AI chatbot. So this explains what open does, what write does and what closed does. If you want you can also run down the file and type highlighted text dot HTML to download this file onto your local desktop, click on this link. If you open that file, open your web browser, you should see something like this, the HTML file that you generated. So we've gone through a lot in this video to recognize certain terms and then to highlight them or to extract them and save them to a CSV file. And then also how to write data out to a file that you can then download. In the next lesson, you see how to load data that is formatted in CSV format, kind of like the data you created in this lesson with restaurants and their dishes, and use that to help plan out your own vacation. So please try out the exercises at the end of this Jupyter notebook. And after that, I look forward to seeing you in the next video!