<commit_before># Licensed under a 3-clause BSD style license, see LICENSE.
"""
***********************
Module for Selection
***********************
"""

# -----------------------------------------------------------------------------
# Import statements
# -----------------------------------------------------------------------------
from ..utils.py23 import *
from ..utils.dependencies import softimport

numpy = softimport("numpy")
pyparsing = softimport("pyparsing")

# -----------------------------------------------------------------------------
# Selection class
# -----------------------------------------------------------------------------


class ParseResultsWrapper(object):

    def __init__(self, result):
        if not isinstance(result, pyparsing.ParseResults):
            raise TypeError("pyparsing.ParseResults expected!")
        attrs_list = ["lhs", "rhs", "operator", "__getitem__", "asList"]
        if not all(hasattr(result, attr) for attr in attrs_list):
            msg = "pyparsing.ParseResults expected with the following"
            msg += " attributes {0} expected!".format(attrs_list)
            raise TypeError(msg)
        self._result = result

    @property
    def lhs(self):
        ret = self._result.lhs
        if len(ret) == 1:
            return ret[0]
        return ret

    @property
    def rhs(self):
        ret = self._result.rhs
        if len(ret) == 1:
            return ret[0]
        return ret

    @property
    def operator(self):
        ret = self._result.operator
        if len(ret) == 1:
            return ret[0]
        return ret

    def __getitem__(self, i):<commit_msg>add type check in lhs, rhs, operator method of ParseResultWrapper<commit_after># Licensed under a 3-clause BSD style license, see LICENSE.
"""
***********************
Module for Selection
***********************
"""

# -----------------------------------------------------------------------------
# Import statements
# -----------------------------------------------------------------------------
from ..utils.py23 import *
from ..utils.dependencies import softimport

numpy = softimport("numpy")
pyparsing = softimport("pyparsing")

# -----------------------------------------------------------------------------
# Selection class
# -----------------------------------------------------------------------------


class ParseResultsWrapper(object):

    def __init__(self, result):
        if not isinstance(result, pyparsing.ParseResults):
            raise TypeError("pyparsing.ParseResults expected!")
        attrs_list = ["lhs", "rhs", "operator", "__getitem__", "asList"]
        if not all(hasattr(result, attr) for attr in attrs_list):
            msg = "pyparsing.ParseResults expected with the following"
            msg += " attributes {0} expected!".format(attrs_list)
            raise TypeError(msg)
        self._result = result

    @property
    def lhs(self):
        ret = self._result.lhs
        if isinstance(ret, pyparsing.ParseResults) and len(ret) == 1:
            return ret[0]
        return ret

    @property
    def rhs(self):
        ret = self._result.rhs
        if isinstance(ret, pyparsing.ParseResults) and len(ret) == 1:
            return ret[0]
        return ret

    @property
    def operator(self):
        ret = self._result.operator
        if isinstance(ret, pyparsing.ParseResults) and len(ret) == 1:
            return ret[0]
        return ret

    def __getitem__(self, i):
{'fraction_non_alphanumeric': 0.28983833718244806, 'fraction_numerical': 0.005773672055427252, 'mean_word_length': 1.4679487179487178, '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': '1974543', 'n_tokens_mistral': 850, 'n_tokens_neox': 833, 'n_words': 231}