Skip to content

Comparing a file with itself raises IndexError #15

Description

@nitinsurya

Running command like:

text-matcher tmp.txt tmp.txt

raises IndexError. Sample stack trace:

.../text_matcher/matcher.py in extend_matches(self, cutoff)
    267             # If we've gone through the whole list and there's nothing
    268             # left to extend, then stop. Otherwise do this again.
--> 269             self.extend_matches()
    270
    271         return self.healed_matches

.../text_matcher/matcher.py in extend_matches(self, cutoff)
    267             # If we've gone through the whole list and there's nothing
    268             # left to extend, then stop. Otherwise do this again.
--> 269             self.extend_matches()
    270
    271         return self.healed_matches

.../text_matcher/matcher.py in extend_matches(self, cutoff)
    237         for match in self.healed_matches:
    238             # Look one word before.
--> 239             wordA = self.textAgrams[(match.a - 1)][0]
    240             wordB = self.textBgrams[(match.b - 1)][0]
    241             if self.edit_ratio(wordA, wordB) < cutoff:

IndexError: list index out of range

Error is possibly because of this: https://github.com/JonathanReeve/text-matcher/blob/master/text_matcher/matcher.py#L239 where match.a is 0 and the evaluated command becomes:
wordA = self.textAgrams[-1][0] and thus causing an infinite loop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions