The link is slightly different this time as shown in the picture below —
The remote_chunk.py module is a little more complex than the remote_tag.py module.
In addition to receiving the pickled tagger, it also expects to receive pickled block that implements the ChunkerIinterface.
Once it has both the tagger and the block, it expects to receive any number of tokenized sentences that it tags and parses in a tree. This tree is then etched and sent back through the channel:
Code: Explaining the above work
if __ name__ = = `__channelexec__` :
tagger = pickle.loads (channel.receive ())
chunker = pickle. loads (channel.receive ())
for sentence in channel:
chunk_tree = chunker.parse (tagger.tag (sent))
channel.send (pickle.dumps (chunk_tree)) code >
The only external dependency of the remote_chunk module is the pickle module which is part of the Python standard library. You do not need to import any NLTK modules in order to use the tagger or block, because all the necessary data is collected and transmitted over the channel.