<commit_before>"""
Parser for DBF fields.
"""
import datetime
import struct

from .common import to_string, parse_string


class FieldParser:
    def __init__(self, encoding):
        """Create a new field parser

        encoding is the character encoding to use when parsing
        strings."""
        self.encoding = encoding
        self._lookup = self._create_lookup_table()

    def _create_lookup_table(self):
        """Create a lookup table for field types."""
        lookup = {}

        for name in dir(self):
            if name.startswith('parse'):
                field_type = name.lstrip('parse')
                if field_type:
                    lookup[field_type] = getattr(self, name)

        return lookup

    def str(self, data):
        """Convert binary data to string and strip padding."""
        return parse_string(data, self.encoding)
    
    def field_type_supported(self, field_type):<commit_msg>Fixed slightly broken string stripping in field parser init.<commit_after>"""
Parser for DBF fields.
"""
import datetime
import struct

from .common import to_string, parse_string


class FieldParser:
    def __init__(self, encoding):
        """Create a new field parser

        encoding is the character encoding to use when parsing
        strings."""
        self.encoding = encoding
        self._lookup = self._create_lookup_table()

    def _create_lookup_table(self):
        """Create a lookup table for field types."""
        lookup = {}

        for name in dir(self):
            if name.startswith('parse'):
                field_type = name[5:]
                if field_type:
                    lookup[field_type] = getattr(self, name)

        return lookup

    def str(self, data):
        """Convert binary data to string and strip padding."""
        return parse_string(data, self.encoding)
    
    def field_type_supported(self, field_type):
{'fraction_non_alphanumeric': 0.08908803373748023, 'fraction_numerical': 0.0005271481286241434, 'mean_word_length': 2.35929203539823, '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': '4084586', 'n_tokens_mistral': 500, 'n_tokens_neox': 477, 'n_words': 167}