Esempio n. 1
0
    def get_corpus_info(self, user_lang, corp_name):
        """
        Obtain full corpus info
        """
        if corp_name:
            try:
                # get rid of path-like corpus ID prefix
                corp_name = corp_name.lower()
                corp_info = self._fetch_corpus_info(corp_name, user_lang)
                if corp_info is not None:
                    if user_lang is not None:
                        ans = self._localize_corpus_info(corp_info, lang_code=user_lang)
                    else:
                        ans = corp_info
                    ans.manatee = self._mc.get_info(corp_name)
                    ans.token_connect, ans.kwic_connect, ans.query_suggest = self._get_tckcqs_providers(corp_name)
                    ans.metadata.interval_attrs = self._backend.load_interval_attrs(corp_name)

                    return ans
                return BrokenCorpusInfo(name=corp_name)
            except TypeError as ex:
                logging.getLogger(__name__).warning(
                    'Failed to fetch corpus info for {0}: {1}'.format(corp_name, ex))
                return BrokenCorpusInfo(name=corp_name)
        else:
            return BrokenCorpusInfo()
Esempio n. 2
0
 def get_corpus_info(self, language, corp_id):
     if corp_id:
         # get rid of path-like corpus ID prefix
         corp_id = corp_id.split('/')[-1].lower()
         if corp_id in self._metadata:
             ans = self._localize_corpus_info(self._metadata[corp_id], language)
             ans.manatee = self._manatee_corpora.get_info(corp_id)
             return ans
         else:
             return BrokenCorpusInfo(name=corp_id)
     else:
         return BrokenCorpusInfo()
Esempio n. 3
0
 def get_corpus_info(self, user_lang, corp_name):
     if corp_name:
         # get rid of path-like corpus ID prefix
         corp_name = corp_name.split('/')[-1].lower()
         if corp_name in self._raw_list(user_lang):
             if user_lang is not None:
                 return self._localize_corpus_info(
                     self._raw_list(user_lang)[corp_name],
                     lang_code=user_lang)
             else:
                 return self._raw_list(user_lang)[corp_name]
         return BrokenCorpusInfo(name=corp_name)
     else:
         return BrokenCorpusInfo()
Esempio n. 4
0
 def get_corpus_info(self, user_lang, corp_name):
     if corp_name:
         # get rid of path-like corpus ID prefix
         corp_name = corp_name.split('/')[-1]
         if self._auth.ignores_corpora_names_case():
             corp_name = corp_name.lower()
         if corp_name in self._raw_list(user_lang):
             if user_lang is not None:
                 ans = self._localize_corpus_info(
                     self._raw_list(user_lang)[corp_name],
                     lang_code=user_lang)
             else:
                 ans = self._raw_list(user_lang)[corp_name]
             ans.manatee = self.manatee_corpora.get_info(corp_name)
             return ans
         return BrokenCorpusInfo(name=corp_name)
     else:
         return BrokenCorpusInfo()
Esempio n. 5
0
 def get_corpus_info(self, user_lang, corp_id):
     info = self._srch_item(self._data, corp_id)
     if info:
         ans = CorpusInfo()
         ans.id = info.get('id')
         ans.name = info.get('name')
         return self._localize_corpus_info(ans, user_lang)
     else:
         return self._localize_corpus_info(BrokenCorpusInfo(), user_lang)
Esempio n. 6
0
    def get_corpus_info(self, user_lang, corp_name):
        """
        Obtain full corpus info
        """
        if corp_name:
            # get rid of path-like corpus ID prefix
            corp_name = corp_name.split('/')[-1].lower()
            corp_info = self._fetch_corpus_info(corp_name)
            if corp_info is not None:
                if user_lang is not None:
                    ans = self._localize_corpus_info(corp_info,
                                                     lang_code=user_lang)
                else:
                    ans = corp_info
                ans.manatee = self._mc.get_info(corp_name)
                ans.token_connect, ans.kwic_connect = self._get_tckc_providers(
                    corp_name)

                return ans
            return BrokenCorpusInfo(name=corp_name)
        else:
            return BrokenCorpusInfo()