Getting ID (first element of response) into a map while manipulating second element

Hi @Justinbenfit23!

Check if something like this helps you get an idea on how you can tackle this:

reviews = [
  {"July 03, 2021",
   "We had been looking for a 2021 Suburban for about 6 months and no one could find exactly what we wanted! We contacted Adrian at McKaig and he told us he could order one for us! Our Suburban was delivered in 4 weeks and had everything on it that we wanted! Adrian, Brandon, Dennis and Freddie all worked with us to get exactly what we wanted! They made phone calls and deals for us right on the spot and we drove out with a beautiful black Suburban! We will definitely use Adrian and McKaig Chevrolet again! Thank you for a fun car buying experience!"},
  {"July 03, 2021",
   "Adrian first educated me on trade ins. And Joe helped me have a car with a better fit and one I can feel good about! "},
  {"July 03, 2021",
   "Adrian was able to finally help my fiance get the truck he needed for quite some time now! We left Mckaig extremely happy and grateful! As always customer service was amazing especially Adrian’s and Joe’s!"}
]

special_words = ["extremely", "definitely","amazing","very","best","great","excellent","awesome","incredibly","beyond","loved","really","highly"]

reviews
|> Stream.map(fn {k, v} -> {k, String.split(v)} end)
|> Stream.map(fn {k, v} -> {k, Enum.filter(v, &(&1 in special_words))} end)
|> Stream.map(fn {k, v} -> {k, Enum.frequencies(v)} end)
|> Stream.map(fn {k, v} -> Map.put(v, "id", k) end)
|> Enum.to_list()

This will yield something like this:

[
  %{"definitely" => 1, "id" => "July 03, 2021"},
  %{"id" => "July 03, 2021"},
  %{"amazing" => 1, "extremely" => 1, "id" => "July 03, 2021"}
]

The structure is a bit different from what you asked but you can get a rough idea on how you are able to transform your data into the desired result with Elixir.

Cheers!