Changing NLU data format from rasa 1.7.2 to rasa 1.10.2

Trying to reformat my nlu data for rasa 1.10.2 (to run on rasa x)

running this command from the documentation

sed -i -E 's/\[([^)]+)\]\(([^)]+):([^)]+)\)/[\1]{"entity": "\2", "value": "\3"}/g' nlu.md

gives me this error

sed: 1: "s/\[([^)]+)\]\(([^)]+): ...": \2 not defined in the RE

I found a solution to this. Sharing for the benefit of anybody who is facing the same problem with changing the training data format.

Open any text editor (like Atom) that supports regex. To convert training data in [value](entity) format for e.g. from this format [FIRST](class_type:FIRST) to this [FIRST]{"entity": "class_type", "value": "FIRST"} format do this:

In find paste this:

\[([^)]+)\]\(([^):]+)\)

and in replace paste this:

[$1]{"entity": "$2", "value": "$1"}

To convert training data in [value](entity:synonym) format for e.g. from this format [first class](class_type:FIRST) to this [first class]{"entity": "class_type", "value": "FIRST"} format do this

In find paste this:

\[([^)]+)\]\(([^)]+):([^)]+)\)

and in replace paste this:

[$1]{"entity": "$2", "value": "$3"}

It takes a few minutes for the formatting to complete. Once it’s done check to see if everything is formatted according to the new training data format