コード例 #1
0
ファイル: querying.py プロジェクト: dlukes/kontext
    def _attach_aligned_query_params(self, tpl_out: Dict[str, Any]):
        """
        Adds template data required to generate components for adding/overviewing
        aligned corpora. This is called by individual actions.

        arguments:
        tpl_out -- a dict where exported data is stored
        """
        if self.corp.get_conf('ALIGNED'):
            tpl_out['Aligned'] = []
            if 'input_languages' not in tpl_out:
                tpl_out['input_languages'] = {}
            for al in self.corp.get_conf('ALIGNED').split(','):
                alcorp = corplib.open_corpus(al)
                tpl_out['Aligned'].append(
                    dict(label=alcorp.get_conf('NAME') or al, n=al))
                attrlist = alcorp.get_conf('ATTRLIST').split(',')
                poslist = getattr(self.cm, 'corpconf_pairs')(alcorp,
                                                             'WPOSLIST')
                tpl_out['Wposlist_' + al] = [{
                    'n': x[0],
                    'v': x[1]
                } for x in poslist]
                if 'lempos' in attrlist:
                    poslist = getattr(self.cm, 'corpconf_pairs')(alcorp,
                                                                 'LPOSLIST')
                tpl_out['Lposlist_' + al] = [{
                    'n': x[0],
                    'v': x[1]
                } for x in poslist]
                tpl_out['input_languages'][al] = self.get_corpus_info(
                    al)['collator_locale']
コード例 #2
0
ファイル: querying.py プロジェクト: tomachalek/kontext
    def _attach_aligned_query_params(self, tpl_out):
        """
        Adds template data required to generate components for adding/overviewing
        aligned corpora.

        arguments:
        tpl_out -- a dict where exported data is stored
        """
        if self.corp.get_conf('ALIGNED'):
            tpl_out['Aligned'] = []
            if 'input_languages' not in tpl_out:
                tpl_out['input_languages'] = {}
            for al in self.corp.get_conf('ALIGNED').split(','):
                alcorp = corplib.open_corpus(al)
                tpl_out['Aligned'].append(dict(label=alcorp.get_conf('NAME') or al, n=al))
                attrlist = alcorp.get_conf('ATTRLIST').split(',')
                poslist = self.cm.corpconf_pairs(alcorp, 'WPOSLIST')
                tpl_out['Wposlist_' + al] = [{'n': x[0], 'v': x[1]} for x in poslist]
                if 'lempos' in attrlist:
                    poslist = self.cm.corpconf_pairs(alcorp, 'LPOSLIST')
                tpl_out['Lposlist_' + al] = [{'n': x[0], 'v': x[1]} for x in poslist]
                tpl_out['input_languages'][al] = self.get_corpus_info(al).collator_locale