Esempio n. 1
0
def ddmin(s,i):
    assert test(i, ''.join(s)) == "FAIL"
    
    n = 2     # Initial granularity
    while len(s) >= 2:    
        start = 0
        subset_length = len(s) / n
        some_complement_is_failing = False

        while start < len(s):
            complement = s[:start] + s[start + subset_length:]

            # MYSTERY test TAKES 2 ARGUMENTS
            # FIRST IS TEST CASE INDEX
            # SECOND IS THE STRING TO TEST

            global TEST_COUNT
            TEST_COUNT += 1
            
            if test(i, ''.join(complement)) == "FAIL":
                s = complement
                n = max(n - 1, 2)
                some_complement_is_failing = True
                break
                
            start += subset_length

        if not some_complement_is_failing:
            if n == len(s): break
            n = min(n * 2, len(s))
            
    return s
Esempio n. 2
0
def ddmin(case_num, s):
    counter = 0
    n = 2     # Initial granularity
    while len(s) >= 2:
        start = 0
        subset_length = len(s) / n
        some_complement_is_failing = False

        while start < len(s):
            counter += 1
            complement = s[:start] + s[start + subset_length:]

            if type(complement) == list:
                if test(case_num, " ".join(complement)) == "FAIL":
                    s = complement
                    n = max(n - 1, 2)
                    some_complement_is_failing = True
                    break
            else:
                if test(case_num, complement) == "FAIL":
                    s = complement
                    n = max(n - 1, 2)
                    some_complement_is_failing = True
                    break

            start += subset_length

        if not some_complement_is_failing:
            if n == len(s):
                break
            n = min(n * 2, len(s))
    return s, counter
Esempio n. 3
0
def ddmin(i, s):
    counter = 0
    n = 2  # Initial granularity
    while len(s) >= 2:
        start = 0
        subset_length = len(s) / n
        some_complement_is_failing = False

        while start < len(s):
            counter += 1
            complement = s[:start] + s[start + subset_length:]

            if test(i, complement) == "FAIL":
                s = complement
                n = max(n - 1, 2)
                some_complement_is_failing = True
                break

            start += subset_length

        if not some_complement_is_failing:
            if n == len(s):
                break
            n = min(n * 2, len(s))
    return s, counter
Esempio n. 4
0
def ddmin(untokenized):
    s = word_tokenize(untokenized)
    counter = 0
    n = 2     # Initial granularity
    while len(s) >= 2:
        start = 0
        subset_length = len(s) / n
        some_complement_is_failing = False

        while start < len(s):
            counter += 1
            complement = s[:start] + s[start + subset_length:]

            if test(i, "".join(complement)) == "FAIL":
                s = complement
                n = max(n - 1, 2)
                some_complement_is_failing = True
                break
                
            start += subset_length

        if not some_complement_is_failing:
            if n == len(s):
                break
            n = min(n * 2, len(s))
    return "".join(s), counter
Esempio n. 5
0
def ddmin(s, i):
    n = 2  # Initial granularity
    while len(s) >= 2:
        start = 0
        subset_length = len(s) / n
        some_complement_is_failing = False

        while start < len(s):
            complement = s[:start] + s[start + subset_length:]

            # MYSTERY test TAKES 2 ARGUMENTS
            # FIRST IS TEST CASE INDEX
            # SECOND IS THE STRING TO TEST
            if test(i, complement) == "FAIL":
                s = complement
                n = max(n - 1, 2)
                some_complement_is_failing = True
                break

            start += subset_length

        if not some_complement_is_failing:
            if n == len(s):
                break
            n = min(n * 2, len(s))
    return s
def ddmin(t, s):

    s_ = []
    for line in s.splitlines():
        s_.extend(line.split('>'))
    s = s_

    counter = 0
    n = 2  # Initial granularity
    while len(s) >= 2:
        start = 0
        subset_length = len(s) / n
        some_complement_is_failing = False

        while start < len(s):
            counter += 1
            complement = s[:start] + s[start + subset_length:]

            check_complement = complement if isinstance(
                complement, basestring) else '>'.join(complement)
            if test(t, check_complement) == "FAIL":
                s = complement
                n = max(n - 1, 2)
                some_complement_is_failing = True
                break

            start += subset_length

        if not some_complement_is_failing:
            if n == len(s):
                break
            n = min(n * 2, len(s))

        if len(s) < 2 and isinstance(s, list):
            s = ''.join(s)
            n = 2

    return s, counter
def ddmin(t, s):

    s_ = []
    for line in s.splitlines():
        s_.extend(line.split('>'))
    s = s_

    counter = 0
    n = 2     # Initial granularity
    while len(s) >= 2:
        start = 0
        subset_length = len(s) / n
        some_complement_is_failing = False

        while start < len(s):
            counter += 1
            complement = s[:start] + s[start + subset_length:]

            check_complement = complement if isinstance(complement, basestring) else '>'.join(complement)
            if test(t, check_complement) == "FAIL":
                s = complement
                n = max(n - 1, 2)
                some_complement_is_failing = True
                break

            start += subset_length

        if not some_complement_is_failing:
            if n == len(s):
                break
            n = min(n * 2, len(s))

        if len(s) < 2 and isinstance(s, list):
            s = ''.join(s)
            n = 2

    return s, counter