Combine items from two different arrays

I have a transcript represented as a complex array with more data than I need. The end result I’m trying to get to is something like:

Speaker A: utterance1
Speaker B: utterance2
Speaker A: utterance3

Using the Set Variable module and the map() function I was able to get:

Speaker A
Speaker A

and a second variable:

utterance1
utterance2

How do I combine these two arrays to get my desired result?

Full Transcript Output that I’m trying to simplify:

Outputs of Set Variable so far. I need to combine these.


Put the Speaker array in an Iterator module.

Immediately use a Text Aggregator to put the current Value (Speaker), and : , and array value of Utterance (use Bundle Order Position of Iterator).

Alternatively, you can Iterate DATA, and directly map into a Text Aggregator:

Output:

I highly recommend you complete the Make Academy. This is arrays 101.

Module Export - quick import into your scenario

You can copy and paste this module export into your scenario. This will import the modules (with fields/settings/filters) shown in my screenshots above.

  1. Move your mouse over the line of code below. Copy the JSON by clicking the copy button on the right of the code, which looks like this:

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the editor.

  3. Click on each imported module and re-save it for validation. There may be some errors prompting you to remap some variables and connections.

JSON module export — paste this directly in your scenario

{"subflows":[{"flow":[{"id":257,"module":"json:ParseJSON","version":1,"parameters":{"type":""},"mapper":{"json":"{\"data\":[{\"words\":[{\"text\":\"I was giving a path to, what would you call that?\",\"start_timestamp\":0,\"end_timestamp\":5.820362091064453,\"language\":null,\"confidence\":null}],\"speaker\":\"Dylan Peterson\",\"speaker_id\":100,\"language\":\"en-us\"},{\"words\":[{\"text\":\"Like a key value pair.\",\"start_timestamp\":7.8770976066589355,\"end_timestamp\":9.958776473999023,\"language\":null,\"confidence\":null}],\"speaker\":\"Dylan Peterson\",\"speaker_id\":100,\"language\":\"en-us\"},{\"words\":[{\"text\":\"And now I'm giving a path to an array.\",\"start_timestamp\":10.787675857543945,\"end_timestamp\":13.251642227172852,\"language\":null,\"confidence\":null}],\"speaker\":\"Dylan Peterson\",\"speaker_id\":100,\"language\":\"en-us\"},{\"words\":[{\"text\":\"so,\",\"start_timestamp\":15.605591773986816,\"end_timestamp\":17.14249610900879,\"language\":null,\"confidence\":null}],\"speaker\":\"Dylan Peterson\",\"speaker_id\":100,\"language\":\"en-us\"},{\"words\":[{\"text\":\"That's kind of interesting.\",\"start_timestamp\":17.95963478088379,\"end_timestamp\":19.607587814331055,\"language\":null,\"confidence\":null}],\"speaker\":\"Dylan Peterson\",\"speaker_id\":100,\"language\":\"en-us\"}]}"},"metadata":{"designer":{"x":1461,"y":-1,"name":"Mock HTTP module"},"parameters":[{"name":"type","type":"udt","label":"Data structure"}]}},{"id":258,"module":"builtin:BasicFeeder","version":1,"parameters":{},"mapper":{"array":"{{257.data}}"},"metadata":{"designer":{"x":1819,"y":0}}},{"id":259,"module":"util:TextAggregator","version":1,"parameters":{"rowSeparator":"\n","feeder":258},"mapper":{"value":"{{258.speaker}}: {{258.words[].text}}"},"metadata":{"designer":{"x":2061,"y":-1,"messages":[{"category":"last","severity":"warning","message":"A transformer should not be the last module in the route."}]},"parameters":[{"name":"rowSeparator","type":"select","label":"Row separator","validate":{"enum":["\n","\t","other"]}}],"advanced":true}}]}],"metadata":{"version":1}}

Note: Did you know you can reduce the size of blueprints and module export code like the above, using the Make Blueprint Scrubber?

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

1 Like

Thank you! I actually did complete Make academy. It’s just taking awhile for the concepts to sink in. I guess I got intimidated by the complex array with nested collections and arrays. The Make academy uses very straight-forward examples. I’m getting now that the same concepts apply. Learning! :slight_smile: