def _partial_search_validator(self, sub, sup, anagram=False,
                                  subsequence=False, supersequence=False):
        """
        It's responsible for validating the partial results of `search` method.
        If it returns True, the search would return its result. Else, search
        method would discard what it found and look for others.

        First, checks to see if all elements of `sub` is in `sup` with at least
        the same frequency and then checks to see if every element `sub`
        appears in `sup` with the same order (index-wise).
        If advanced control sturctures are specified, the containment condition
        won't be checked.
        The code for index checking is from [1]_.

        Parameters
        ----------
        sub : list
        sup : list
        anagram : bool, optional
            Default is `False`
        subsequence : bool, optional
            Default is `False`
        supersequence : bool, optional
            Default is `False`

        Returns
        -------
        bool

        References
        ----------
        .. [1] : `
   https://stackoverflow.com/questions/35964155/checking-if-list-is-a-sublist`
        """
        def get_all_in(one, another):
            for element in one:
                if element in another:
                    yield element

        def containment_check(sub, sup):
            return (set(Counter(sub).keys()).issubset(
                set(Counter(sup).keys())))

        def containment_freq_check(sub, sup):
            return (all([Counter(sub)[element] <= Counter(sup)[element]
                         for element in Counter(sub)]))

        def extra_freq_check(sub, sup, list_of_tups):
            # Would be used for matching anagrams, subsequences etc.
            return (len(list_of_tups) > 0 and
                    all([Counter(sub)[tup[0]] <= Counter(sup)[tup[1]]
                         for tup in list_of_tups]))

        # Regarding containment checking while having extra conditions,
        # there's no good way to map each anagram or subseuqnece etc. that was
        # found to the query word, without making it more complicated than
        # it already is, because a query word can be anagram/subsequence etc.
        # to multiple words of the timestamps yet finding the one with the
        # right index would be the problem.
        # Therefore we just approximate the solution by just counting
        # the elements.
        if len(sub) > len(sup):
            return False

        for pred, func in set([(anagram, self._is_anagram_of),
                               (subsequence, self._is_subsequence_of),
                               (supersequence, self._is_supersequence_of)]):
            if pred:
                pred_seive = [(sub_key, sup_key)
                              for sub_key in set(Counter(sub).keys())
                              for sup_key in set(Counter(sup).keys())
                              if func(sub_key, sup_key)]
                if not extra_freq_check(sub, sup, pred_seive):
                    return False

        if (
                not any([anagram, subsequence, supersequence]) and
                (not containment_check(sub, sup) or
                 not containment_freq_check(sub, sup))
        ):
                return False

        for x1, x2 in zip(get_all_in(sup, sub), get_all_in(sub, sup)):
            if x1 != x2:
                return False

        return True
def _partial_search_validator ( self , sub , sup , anagram = False , subsequence = False , supersequence = False ) : def get_all_in ( one , another ) : for element in one : if element in another : yield element def containment_check ( sub , sup ) : return ( set ( Counter ( sub ) . keys ( ) ) . issubset ( set ( Counter ( sup ) . keys ( ) ) ) ) def containment_freq_check ( sub , sup ) : return ( all ( [ Counter ( sub ) [ element ] <= Counter ( sup ) [ element ] for element in Counter ( sub ) ] ) ) def extra_freq_check ( sub , sup , list_of_tups ) : return ( len ( list_of_tups ) > 0 and all ( [ Counter ( sub ) [ tup [ 0 ] ] <= Counter ( sup ) [ tup [ 1 ] ] for tup in list_of_tups ] ) ) if len ( sub ) > len ( sup ) : return False for pred , func in set ( [ ( anagram , self . _is_anagram_of ) , ( subsequence , self . _is_subsequence_of ) , ( supersequence , self . _is_supersequence_of ) ] ) : if pred : pred_seive = [ ( sub_key , sup_key ) for sub_key in set ( Counter ( sub ) . keys ( ) ) for sup_key in set ( Counter ( sup ) . keys ( ) ) if func ( sub_key , sup_key ) ] if not extra_freq_check ( sub , sup , pred_seive ) : return False if ( not any ( [ anagram , subsequence , supersequence ] ) and ( not containment_check ( sub , sup ) or not containment_freq_check ( sub , sup ) ) ) : return False for x1 , x2 in zip ( get_all_in ( sup , sub ) , get_all_in ( sub , sup ) ) : if x1 != x2 : return False return True
It's responsible for validating the partial results of `search` method.
        If it returns True, the search would return its result. Else, search
        method would discard what it found and look for others.

        First, checks to see if all elements of `sub` is in `sup` with at least
        the same frequency and then checks to see if every element `sub`
        appears in `sup` with the same order (index-wise).
        If advanced control sturctures are specified, the containment condition
        won't be checked.
        The code for index checking is from [1]_.

        Parameters
        ----------
        sub : list
        sup : list
        anagram : bool, optional
            Default is `False`
        subsequence : bool, optional
            Default is `False`
        supersequence : bool, optional
            Default is `False`

        Returns
        -------
        bool

        References
        ----------
        .. [1] : `
   https://stackoverflow.com/questions/35964155/checking-if-list-is-a-sublist`