@classmethod
    def cache_to_tempfile(cls, sequence, delete_on_gc=True):
        """
        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.
        """
        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)



######################################################################
#{ Block Readers
######################################################################
dataset/ETHPy150Open nltk/nltk/nltk/corpus/reader/util.py/PickleCorpusView.cache_to_tempfile/original