Get a tag list from pos tagging

Currently, I am working on an NLP project, and after applying pos tagging, I have received the below output.

[[(ද්විපාර්ශවික, NNP), (එකඟතා, NNP), (ජන, JJ), (ජීවිත, NNJ), (සෞඛ්යය, NNC), (මනාව, RB)]]

for my work, I need to retrieve tags, like this.

> pos_tag_list = [['NNP', 'NNP', 'JJ', 'NNJ', 'NNC', 'RB']]

Answer

I think this could work.

a = [[('ද්විපාර්ශවික', 'NNP'), ('එකඟතා', 'NNP'), ('ජන', 'JJ'), ('ජීවිත', 'NNJ'), ('සෞඛ්යය', 'NNC'), ('මනාව', 'RB')]]

def foo (data):
    result = []
    if type(data) == tuple:
        return data[1]

    if type(data) == list:
        for inner in data:
            result.append(foo(inner))
    
    return result

result = foo (a)