Hi,
I need to know what is wrong with this code and why I am getting errors and how can solve it......
I need to know what is wrong with this code and why I am getting errors and how can solve it......
def leaves(tag_words): from nltk.tree import Tree import re pattern = r'\w+:?(?=\/)' # for removing NNS AND NN npb= [] for i in tag_words[0:]: tr= [(" " .join((re.findall(pattern, str(word.leaves())))) ) for word in Tree.fromstring(str(i)).subtrees(filter = lambda t: t.label()=='NP')] npb.extend(tr) nor = [stem(normalizatio((i.lower()))) for i in npb]# lemmatization candi=[t for t in nor if acceptable_word(t)] # stopword remove return candiplease help me........
Output: File "C:\ProgramData\Anaconda2\lib\site-packages\nltk\tree.py", line 636, in fromstring
cls._parse_error(s, 'end-of-string', close_b)
File "C:\ProgramData\Anaconda2\lib\site-packages\nltk\tree.py", line 675, in _parse_error
raise ValueError(msg)
ValueError: Tree.read(): expected u')' but got u'end-of-string'
at index 159.
"...,/, ./.)"
^
thanks you