示例#1
0
文件: manager.py 项目: oboder/pymake
    def load(cls, expe, load=True):
        """ Return the frontend suited for the given expe"""

        corpus_name = expe.get('corpus') or expe.get('random')

        if '.' in corpus_name:
            c_split = corpus_name.split('.')
            c_name, c_ext = '.'.join(c_split[:-1]), c_split[-1]
        else:
            c_name = corpus_name
            c_ext = None

        _corpus = Corpus.get(c_name)
        if c_ext in GramExp._frontend_ext:
            # graph-tool object
            # @Todo: Corpus intragation!
            _corpus.update(data_format=c_ext)
        elif _corpus is False:
            raise ValueError('Unknown Corpus `%s\'!' % corpus)
        elif _corpus is None:
            return None

        if _corpus['data_type'] == 'text':
            frontend = frontendText(expe)
        elif _corpus['data_type'] == 'network':
            if _corpus.get('data_format') == 'gt':
                frontend = frontendNetwork_gt.from_expe(expe, load=load, corpus=_corpus)
            else:
                # Obsolete loading design. @Todo
                frontend = frontendNetwork(expe)
                if load is True:
                    frontend.load_data(randomize=False)
                frontend.sample(expe.get('N'), randomize=False)

        return frontend
示例#2
0
文件: manager.py 项目: cipoll4/pymake
    def load(cls, expe, skip_init=False):
        """ Return the frontend suited for the given expe
            @TODO: skip_init is not implemented

        """
        if skip_init:
            cls.log.warning('skip init is not implemented')

        corpus_name = expe.get('corpus') or expe.get('random') or expe.get(
            'concept')
        if expe.get('driver'):
            corpus_name += '.' + expe.driver.strip('.')

        if '.' in corpus_name:
            c_split = corpus_name.split('.')
            c_name, c_ext = '.'.join(c_split[:-1]), c_split[-1]
        else:
            c_name = corpus_name
            c_ext = None

        _corpus = Corpus.get(c_name)
        if c_ext in cls._frontend_ext:
            # graph-tool object
            # @Todo: Corpus integration!
            if not _corpus:
                dt_lut = {'gt': 'network'}
                _corpus = dict(data_type=dt_lut[c_ext])
            _corpus.update(data_format=c_ext)
        elif _corpus is False:
            raise ValueError('Unknown Corpus `%s\'!' % c_name)
        elif _corpus is None:
            return None

        if _corpus['data_type'] == 'text':
            from .frontendtext import frontendText
            frontend = frontendText(expe)
        elif _corpus['data_type'] == 'network':
            if _corpus.get('data_format') == 'gt':
                from .frontendnetwork import frontendNetwork_gt
                frontend = frontendNetwork_gt.from_expe(expe, corpus=_corpus)
            else:
                from .frontendnetwork import frontendNetwork
                # Obsolete loading design. @Todo
                frontend = frontendNetwork(expe)
                frontend.load_data(randomize=False)

        if hasattr(frontend, 'configure'):
            frontend.configure()

        return frontend
示例#3
0
    def load(cls, expe):
        """ Return the frontend suited for the given expe"""

        corpus_name = expe.get('corpus') or expe.get('random') or expe.get(
            'concept')
        if expe.get('driver'):
            corpus_name += '.' + expe.ext.strip('.')

        if '.' in corpus_name:
            c_split = corpus_name.split('.')
            c_name, c_ext = '.'.join(c_split[:-1]), c_split[-1]
        else:
            c_name = corpus_name
            c_ext = None

        _corpus = Corpus.get(c_name)
        if c_ext in GramExp._frontend_ext:
            # graph-tool object
            # @Todo: Corpus intragation!
            _corpus.update(data_format=c_ext)
        elif _corpus is False:
            raise ValueError('Unknown Corpus `%s\'!' % corpus)
        elif _corpus is None:
            return None

        if _corpus['data_type'] == 'text':
            from .frontendtext import frontendText
            frontend = frontendText(expe)
        elif _corpus['data_type'] == 'network':
            if _corpus.get('data_format') == 'gt':
                from .frontendnetwork import frontendNetwork_gt
                frontend = frontendNetwork_gt.from_expe(expe, corpus=_corpus)
            else:
                from .frontendnetwork import frontendNetwork
                # Obsolete loading design. @Todo
                frontend = frontendNetwork(expe)
                frontend.load_data(randomize=False)

        frontend.configure()
        return frontend