I'm working on an nlp project in which I need to parse tags. I have multiple tags in the following form: a string that is a set of tuples. Example:
'{(Entertainment (Adult), S), (Performing Arts, S), (Comedy Club, S), ($, S), (Comedy, P), (18+, S), (Plays & Shows, P)}'
But I want it to look like this:
{('Entertainment (Adult)', 'S'), ('Performing Arts', 'S'), ('Comedy Club', 'S'), ('$', 'S'), ('Comedy', 'P'), ('18+', 'S'), ('Plays & Shows', 'P')}
I tried using literal_eval per this question, but I get an invalid syntax error. I think this is because the tag is a set, which contains tuples, which contain strings that are not cast as strings, so the literal_eval gets confused (just guessing here).
I tried doing some bandaid-y string strips and splits, but I can't get a solution that will work dynamically for different tags.