'Write the given sequence to a temporary file as a pickle
corpus; and then return a ``PickleCorpusView`` view for that
temporary corpus file.
:param delete_on_gc: If true, then the temporary file will be
deleted whenever this object gets garbage-collected.'

@classmethod
def cache_to_tempfile(cls, sequence, delete_on_gc=True):

    try:
        (fd, output_file_name) = tempfile.mkstemp('.pcv', 'nltk-')
        output_file = os.fdopen(fd, 'wb')
        cls.write(sequence, output_file)
        output_file.close()
        return PickleCorpusView(output_file_name, delete_on_gc)
    except (OSError, IOError) as e:
        raise ValueError(('Error    while    creating    temp    file:    %s' % e))
