'Compiles this vocabulary. If the force argument is True, compilation
will be forced regardless of necessity (which means that the
preliminary check if the current revision already equals the
revision after compilation will be skipped).
This method is not meant to be overridden by subclasses - use the
_compile_vocabulary()-method instead.
Arguments:
phrases -- a list of phrases that this vocabulary will contain
force -- (optional) forces compilation (Default: False)
Returns:
The revision of the compiled vocabulary'

def compile(self, phrases, force=False):

    revision = self.phrases_to_revision(phrases)
    if ((not force) and (self.compiled_revision == revision)):
        self._logger.debug(('Compilation    not    neccessary,    compiled    ' + 'version    matches    phrases.'))
        return revision
    if (not os.path.exists(self.path)):
        self._logger.debug(("Vocabulary    dir    '%s'    does    not    exist,    " + 'creating...'), self.path)
        try:
            os.makedirs(self.path)
        except OSError:
            self._logger.error("Couldn't    create    vocabulary    dir    '%s'", self.path, exc_info=True)
            raise
    try:
        with open(self.revision_file, 'w') as f:
            f.write(revision)
    except (OSError, IOError):
        self._logger.error("Couldn't    write    revision    file    in    '%s'", self.revision_file, exc_info=True)
        raise
    else:
        self._logger.info('Starting    compilation...')
        try:
            self._compile_vocabulary(phrases)
        except Exception as e:
            self._logger.error(('Fatal    compilation    Error    occured,    ' + 'cleaning    up...'), exc_info=True)
            try:
                os.remove(self.revision_file)
            except OSError:
                pass
            raise e
        else:
            self._logger.info('Compilation    done.')
    return revision
