<commit_before>from collections import OrderedDict

from django.db.models.fields import related
from django.utils.encoding import force_text
from rest_framework import serializers
from rest_framework.metadata import SimpleMetadata
from rest_framework.utils.field_mapping import ClassLookupDict

from rest_framework_json_api.utils import get_related_resource_type


class JSONAPIMetadata(SimpleMetadata):
    """
    This is the JSON:API metadata implementation.
    It returns an ad-hoc set of information about the view.
    There are not any formalized standards for `OPTIONS` responses
    for us to base this on.
    """
    type_lookup = ClassLookupDict({
        serializers.HyperlinkedIdentityField: 'Relationship',
        serializers.HyperlinkedRelatedField: 'Relationship',
        serializers.BooleanField: 'Boolean',
        serializers.NullBooleanField: 'Boolean',
        serializers.CharField: 'String',
        serializers.URLField: 'URL',
        serializers.EmailField: 'Email',
        serializers.RegexField: 'Regex',
        serializers.SlugField: 'Slug',
        serializers.IntegerField: 'Integer',
        serializers.FloatField: 'Float',
        serializers.DecimalField: 'Decimal',
        serializers.DateField: 'Date',
        serializers.DateTimeField: 'DateTime',
        serializers.TimeField: 'Time',
        serializers.ChoiceField: 'Choice',
        serializers.MultipleChoiceField: 'MultipleChoice',
        serializers.FileField: 'File',
        serializers.ImageField: 'Image',
        serializers.ListField: 'List',
        serializers.DictField: 'Dict',
        serializers.Serializer: 'Serializer',
    })<commit_msg>Added a 'Catch all' field type -> GenericField<commit_after>from collections import OrderedDict

from django.db.models.fields import related
from django.utils.encoding import force_text
from rest_framework import serializers
from rest_framework.metadata import SimpleMetadata
from rest_framework.utils.field_mapping import ClassLookupDict

from rest_framework_json_api.utils import get_related_resource_type


class JSONAPIMetadata(SimpleMetadata):
    """
    This is the JSON:API metadata implementation.
    It returns an ad-hoc set of information about the view.
    There are not any formalized standards for `OPTIONS` responses
    for us to base this on.
    """
    type_lookup = ClassLookupDict({
        serializers.Field: 'GenericField',
        serializers.HyperlinkedIdentityField: 'Relationship',
        serializers.HyperlinkedRelatedField: 'Relationship',
        serializers.BooleanField: 'Boolean',
        serializers.NullBooleanField: 'Boolean',
        serializers.CharField: 'String',
        serializers.URLField: 'URL',
        serializers.EmailField: 'Email',
        serializers.RegexField: 'Regex',
        serializers.SlugField: 'Slug',
        serializers.IntegerField: 'Integer',
        serializers.FloatField: 'Float',
        serializers.DecimalField: 'Decimal',
        serializers.DateField: 'Date',
        serializers.DateTimeField: 'DateTime',
        serializers.TimeField: 'Time',
        serializers.ChoiceField: 'Choice',
        serializers.MultipleChoiceField: 'MultipleChoice',
        serializers.FileField: 'File',
        serializers.ImageField: 'Image',
        serializers.ListField: 'List',
        serializers.DictField: 'Dict',
        serializers.Serializer: 'Serializer',
    })
{'fraction_non_alphanumeric': 0.08702064896755163, 'fraction_numerical': 0.0, 'mean_word_length': 3.619891008174387, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4105611', 'n_tokens_mistral': 879, 'n_tokens_neox': 868, 'n_words': 222}