<commit_before>from django import template

from metashare.repository.models import corpusInfoType_model, \
    lexicalConceptualResourceInfoType_model, \
    languageDescriptionInfoType_model
    # toolServiceInfoType_model,

register = template.Library()

class ResourceLanguages(template.Node):
    """
    Template tag that allows to display languages in result page template.    
    """
    
    def __init__(self, context_var):
        """
        Initialises this template tag.
        """
        super(ResourceLanguages, self).__init__()
        self.context_var = template.Variable(context_var)
        
    def render(self, context):
        """
        Renders languages.
        """
        result = []
        corpus_media = self.context_var.resolve(context)
    
        if isinstance(corpus_media, corpusInfoType_model):
            media_type = corpus_media.corpusMediaType
            for corpus_info in media_type.corpustextinfotype_model_set.all():
                result.extend([lang.languageName for lang in
                               corpus_info.languageinfotype_model_set.all()])
            # if media_type.corpusAudioInfo:
            #     result.extend([lang.languageName for lang in
            #                    media_type.corpusAudioInfo.languageinfotype_model_set.all()])
            for corpus_info in media_type.corpusvideoinfotype_model_set.all():
                result.extend([lang.languageName for lang in
                               corpus_info.languageinfotype_model_set.all()])
            # if media_type.corpusTextNgramInfo:
            #     result.extend([lang.languageName for lang in
            #                 media_type.corpusTextNgramInfo.languageinfotype_model_set.all()])
            # if media_type.corpusImageInfo:
            #     result.extend([lang.languageName for lang in
            #                    media_type.corpusImageInfo.languageinfotype_model_set.all()])

        elif isinstance(corpus_media, lexicalConceptualResourceInfoType_model):
            lcr_media_type = corpus_media.lexicalConceptualResourceMediaType
            # if lcr_media_type.lexicalConceptualResourceAudioInfo:
            #     result.extend([lang.languageName for lang in lcr_media_type \
            #             .lexicalConceptualResourceAudioInfo.languageinfotype_model_set.all()])
            if lcr_media_type.lexicalConceptualResourceTextInfo:
                result.extend([lang.languageName for lang in lcr_media_type \
                        .lexicalConceptualResourceTextInfo.languageinfotype_model_set.all()])
            # if lcr_media_type.lexicalConceptualResourceVideoInfo:<commit_msg>remove reference to unused component<commit_after>from django import template

from metashare.repository.models import corpusInfoType_model, \
    lexicalConceptualResourceInfoType_model, \
    languageDescriptionInfoType_model
    # toolServiceInfoType_model,

register = template.Library()

class ResourceLanguages(template.Node):
    """
    Template tag that allows to display languages in result page template.    
    """
    
    def __init__(self, context_var):
        """
        Initialises this template tag.
        """
        super(ResourceLanguages, self).__init__()
        self.context_var = template.Variable(context_var)
        
    def render(self, context):
        """
        Renders languages.
        """
        result = []
        corpus_media = self.context_var.resolve(context)
    
        if isinstance(corpus_media, corpusInfoType_model):
            media_type = corpus_media.corpusMediaType
            for corpus_info in media_type.corpustextinfotype_model_set.all():
                result.extend([lang.languageName for lang in
                               corpus_info.languageinfotype_model_set.all()])
            # if media_type.corpusAudioInfo:
            #     result.extend([lang.languageName for lang in
            #                    media_type.corpusAudioInfo.languageinfotype_model_set.all()])
            # for corpus_info in media_type.corpusvideoinfotype_model_set.all():
            #     result.extend([lang.languageName for lang in
            #                    corpus_info.languageinfotype_model_set.all()])
            # if media_type.corpusTextNgramInfo:
            #     result.extend([lang.languageName for lang in
            #                 media_type.corpusTextNgramInfo.languageinfotype_model_set.all()])
            # if media_type.corpusImageInfo:
            #     result.extend([lang.languageName for lang in
            #                    media_type.corpusImageInfo.languageinfotype_model_set.all()])

        elif isinstance(corpus_media, lexicalConceptualResourceInfoType_model):
            lcr_media_type = corpus_media.lexicalConceptualResourceMediaType
            # if lcr_media_type.lexicalConceptualResourceAudioInfo:
            #     result.extend([lang.languageName for lang in lcr_media_type \
            #             .lexicalConceptualResourceAudioInfo.languageinfotype_model_set.all()])
            if lcr_media_type.lexicalConceptualResourceTextInfo:
                result.extend([lang.languageName for lang in lcr_media_type \
                        .lexicalConceptualResourceTextInfo.languageinfotype_model_set.all()])
            # if lcr_media_type.lexicalConceptualResourceVideoInfo:
{'fraction_non_alphanumeric': 0.0719760702935128, 'fraction_numerical': 0.0, 'mean_word_length': 2.3690176322418135, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4112038', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1388, 'n_words': 227}