# Path: nbdiff/diff.py
# def diff(before, after, check_modified=False):
#     """Diff two sequences of comparable objects.
# 
#     The result of this function is a list of dictionaries containing
#     values in ``before`` or ``after`` with a ``state`` of either
#     'unchanged', 'added', 'deleted', or 'modified'.
# 
#     >>> import pprint
#     >>> result = diff(['a', 'b', 'c'], ['b', 'c', 'd'])
#     >>> pprint.pprint(result)
#     [{'state': 'deleted', 'value': 'a'},
#      {'state': 'unchanged', 'value': 'b'},
#      {'state': 'unchanged', 'value': 'c'},
#      {'state': 'added', 'value': 'd'}]
# 
#     Parameters
#     ----------
#     before : iterable
#         An iterable containing values to be used as the baseline version.
#     after : iterable
#         An iterable containing values to be compared against the baseline.
#     check_modified : bool
#         Whether or not to check for modifiedness.
# 
#     Returns
#     -------
#     diff_items : A list of dictionaries containing diff information.
#     """
# 
#     # The grid will be empty if `before` or `after` are
#     # empty; this will violate the assumptions made in the rest
#     # of this function.
#     # If this is the case, we know what the result of the diff is
#     # anyways: the contents of the other, non-empty input.
#     if len(before) == 0:
#         return [
#             {'state': 'added', 'value': v}
#             for v in after
#         ]
#     elif len(after) == 0:
#         return [
#             {'state': 'deleted', 'value': v}
#             for v in before
#         ]
# 
#     grid = create_grid(before, after)
# 
#     nrows = len(grid[0])
#     ncols = len(grid)
#     dps = diff_points(grid)
#     result = []
#     for kind, col, row in dps:
#         if kind == 'unchanged':
#             value = before[col]
#             result.append({
#                 'state': kind,
#                 'value': value,
#             })
#         elif kind == 'deleted':
#             assert col < ncols
#             value = before[col]
#             result.append({
#                 'state': kind,
#                 'value': value,
#             })
#         elif kind == 'added':
#             assert row < nrows
#             value = after[row]
#             result.append({
#                 'state': kind,
#                 'value': value,
#             })
#         elif check_modified and kind == 'modified':
#             result.append({
#                 'state': kind,
#                 'originalvalue': before[col],
#                 'modifiedvalue': after[row],
#             })
#         elif (not check_modified) and kind == 'modified':
#             result.append({
#                 'state': 'deleted',
#                 'value': before[col],
#             })
#             result.append({
#                 'state': 'added',
#                 'value': after[row],
#             })
#         else:
#             raise Exception('We should not be here.')
#     return result
# 
# def create_grid(before, after):
#     ncols = len(before)
#     nrows = len(after)
#     all_comps = [b == a for b, a in it.product(before, after)]
#     return [
#         all_comps[col*(nrows):col*(nrows)+nrows]
#         for col in range(ncols)
#     ]
# 
# def find_matches(col, colNum):
#     result = []
#     for j in range(len(col)):
#         if col[j]:
#             result.append((colNum, j))
#     return result


from .diff import (
    diff,
    create_grid,
    find_matches,
)
import Levenshtein
    def __init__(self, data, check_modified=False):
        self.data = data
        self.check_modified = check_modified

    def __eq__(self, other):
        return self.equal(self.data, other.data)

    def equal(self, line1, line2):
        '''
        return true if exactly equal or if equal but modified,
        otherwise return false
        return type: BooleanPlus
        '''

        eqLine = line1 == line2
        if eqLine:
            return BooleanPlus(True, False)
        else:
            unchanged_count = self.count_similar_words(line1, line2)
            similarity_percent = (
                (2.0 * unchanged_count) /
                (len(line1.split()) + len(line2.split()))
            )
            if similarity_percent >= 0.50:
                return BooleanPlus(True, True)
            return BooleanPlus(False, False)

    def count_similar_words(self, line1, line2):
        words1 = line1.split()
        words2 = line2.split()

# Path: nbdiff/diff.py
# def diff(before, after, check_modified=False):
#     """Diff two sequences of comparable objects.
# 
#     The result of this function is a list of dictionaries containing
#     values in ``before`` or ``after`` with a ``state`` of either
#     'unchanged', 'added', 'deleted', or 'modified'.
# 
#     >>> import pprint
#     >>> result = diff(['a', 'b', 'c'], ['b', 'c', 'd'])
#     >>> pprint.pprint(result)
#     [{'state': 'deleted', 'value': 'a'},
#      {'state': 'unchanged', 'value': 'b'},
#      {'state': 'unchanged', 'value': 'c'},
#      {'state': 'added', 'value': 'd'}]
# 
#     Parameters
#     ----------
#     before : iterable
#         An iterable containing values to be used as the baseline version.
#     after : iterable
#         An iterable containing values to be compared against the baseline.
#     check_modified : bool
#         Whether or not to check for modifiedness.
# 
#     Returns
#     -------
#     diff_items : A list of dictionaries containing diff information.
#     """
# 
#     # The grid will be empty if `before` or `after` are
#     # empty; this will violate the assumptions made in the rest
#     # of this function.
#     # If this is the case, we know what the result of the diff is
#     # anyways: the contents of the other, non-empty input.
#     if len(before) == 0:
#         return [
#             {'state': 'added', 'value': v}
#             for v in after
#         ]
#     elif len(after) == 0:
#         return [
#             {'state': 'deleted', 'value': v}
#             for v in before
#         ]
# 
#     grid = create_grid(before, after)
# 
#     nrows = len(grid[0])
#     ncols = len(grid)
#     dps = diff_points(grid)
#     result = []
#     for kind, col, row in dps:
#         if kind == 'unchanged':
#             value = before[col]
#             result.append({
#                 'state': kind,
#                 'value': value,
#             })
#         elif kind == 'deleted':
#             assert col < ncols
#             value = before[col]
#             result.append({
#                 'state': kind,
#                 'value': value,
#             })
#         elif kind == 'added':
#             assert row < nrows
#             value = after[row]
#             result.append({
#                 'state': kind,
#                 'value': value,
#             })
#         elif check_modified and kind == 'modified':
#             result.append({
#                 'state': kind,
#                 'originalvalue': before[col],
#                 'modifiedvalue': after[row],
#             })
#         elif (not check_modified) and kind == 'modified':
#             result.append({
#                 'state': 'deleted',
#                 'value': before[col],
#             })
#             result.append({
#                 'state': 'added',
#                 'value': after[row],
#             })
#         else:
#             raise Exception('We should not be here.')
#     return result
# 
# def create_grid(before, after):
#     ncols = len(before)
#     nrows = len(after)
#     all_comps = [b == a for b, a in it.product(before, after)]
#     return [
#         all_comps[col*(nrows):col*(nrows)+nrows]
#         for col in range(ncols)
#     ]
# 
# def find_matches(col, colNum):
#     result = []
#     for j in range(len(col)):
#         if col[j]:
#             result.append((colNum, j))
#     return result


# Path: nbdiff/comparable.py
from .diff import (
    diff,
    create_grid,
    find_matches,
)
import Levenshtein

    def __init__(self, data, check_modified=False):
        self.data = data
        self.check_modified = check_modified

    def __eq__(self, other):
        return self.equal(self.data, other.data)

    def equal(self, line1, line2):
        '''
        return true if exactly equal or if equal but modified,
        otherwise return false
        return type: BooleanPlus
        '''

        eqLine = line1 == line2
        if eqLine:
            return BooleanPlus(True, False)
        else:
            unchanged_count = self.count_similar_words(line1, line2)
            similarity_percent = (
                (2.0 * unchanged_count) /
                (len(line1.split()) + len(line2.split()))
            )
            if similarity_percent >= 0.50:
                return BooleanPlus(True, True)
            return BooleanPlus(False, False)

    def count_similar_words(self, line1, line2):
        words1 = line1.split()
        words2 = line2.split()

        grid = create_grid(words1, words2)