To start with I turned the tree into a list: You insert an already tokenized sentence and it returns a tree.
def LanguageCreateTree(tokenizedSentence):
cp = nltk.RegexpParser(GRAMMAR)
result = cp.parse(tokenizedSentence)
result = str(result)
print(result)
>>> A red cat with a hat
(S A/DT (VP red/VBN (NP cat/NN)) with/IN a/DT hat/JJ)
How would I go about to make a list with lists in it based on this string? I need it to be able to make a list like this:
[['A','DT'], ['VP', ['red','VBN'], ['NP', ['cat','NN']]], ['with','IN'], ['a','DT'], ['hat','JJ']]]