Skip to content

Commit

Permalink
Fix #9
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlls committed Oct 25, 2023
1 parent 2e14f81 commit 57f47e5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions negate/negate.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ def negate_sentence(
# complicates things.
first_aux_or_verb = self._get_first_aux_or_verb(doc)
while (negation and first_aux_or_verb
and first_aux_or_verb.tag_ != "VBG"
and first_aux_or_verb.tag_ not in("VB", "VBG")
and negation.i < first_aux_or_verb.i):
# Search for another negation, if any.
negation = self._get_negated_child(root, min_index=negation.i+1)
aux_child = self._get_aux_child(root)
if negation:
aux_child = self._get_aux_child(root)
remove, add = self._handle_ca_wo(root, aux_child, negation=negation)
# General verbs -> Remove negation and conjugate verb.
# If there is an AUX child, we need to "unnegate" the AUX instead.
Expand Down Expand Up @@ -188,7 +188,6 @@ def negate_sentence(
or any(self._is_aux(child) for child in root.children)):
# If the AUX has AUX children, negate them instead. E.g.: "I will
# be there." or "They have been moody lately."
aux_child = self._get_aux_child(root)
try:
return self._negate_aux_in_doc(
aux=root if not aux_child else aux_child,
Expand All @@ -203,7 +202,10 @@ def negate_sentence(
pass

# General verb non-negated.
if root.tag_ == "VBG": # E.g.: "A Python module negating sentences."
if (any(child.tag_ == "TO" for child in root.children)
or root.tag_ == "VBG"):
# E.g.: "A Python module negating sentences." or "A Python module
# to negate sentences."
add = f"not {root.text}"
else:
negated_aux = self.negate_aux(self.conjugate_verb('do', root.tag_),
Expand Down

0 comments on commit 57f47e5

Please sign in to comment.