Splitting Tree

subhabangalore at gmail.com subhabangalore at gmail.com
Sun Dec 2 16:02:25 CET 2012


On Sunday, December 2, 2012 5:39:32 PM UTC+5:30, subhaba... at gmail.com wrote:
> Dear Group,
> 
> 
> 
> I am using NLTK and I used the following command,
> 
> 
> 
> chunk=nltk.ne_chunk(tag)
> 
> print "The Chunk of the Line Is:",chunk
> 
> 
> 
> 
> 
> The Chunk of the Line Is: (S
> 
>   ''/''
> 
>   It/PRP
> 
>   is/VBZ
> 
>   virtually/RB
> 
>   a/DT
> 
>   homecoming/NN
> 
>   ,/,
> 
>   ''/''
> 
>   said/VBD
> 
>   (PERSON Gen/NNP Singh/NNP)
> 
>   on/IN
> 
>   arrival/NN)
> 
> 
> 
> Now I am trying to split the output preferably by ",/,".
> 
> 
> 
> But how would I split a Tree object in python.
> 
> 
> 
> If I use command like,
> 
> chunk_word=chunk.split()
> 
> 
> 
> It is giving me the error as,
> 
> 
> 
> File "C:/Python27/docstructure1.py", line 38, in document_structure1
> 
>     chunk1=chunk.split()
> 
> AttributeError: 'Tree' object has no attribute 'split'
> 
> 
> 
> If anyone of the learned members of the room can kindly help.
> 
> 
> 
> Regards,
> 
> Subhabrata.

Sorry to ask this. I converted in string and then splitted it.



More information about the Python-list mailing list