Skip to content

negate_sequence() function buggy. #9

Description

@josmithua

The problems that I see are in:

if any(neg in word for neg in ["not", "n't", "no"]):
    negation = not negation
1st problem: negate_sequence() negates words after word containing substring "no", "not", "n't"

For example,

negate_sequence("I know it's going to be nice today")

returns:

['i', 'know', 'i know', "not_it's", "know not_it's", "i know not_it's", 'not_nice', "not_it's not_nice", "know not_it's not_nice", 'not_today', 'not_nice not_today', "not_it's not_nice not_today"]

due to the fact that "know" contains the substring "no". "n't" is not really a problem because it usually comes at the end of a word, but matching on "not" presents issues as well.

2nd problem: You should be comparing with the .lower() version of the word.

For example,

negate_sequence("I DON'T like this movie")

will not negate anything because it's only checking for "n't", not "N'T" or any other case variation. Same thing for a text like "No one with half a brain would watch this movie more than once", because the "No" doesn't match "no".

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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