Skip to content

Commit dd31d9b

Browse files
committed
correct() - in code comments added to help understasnd the logic
1 parent 908a11c commit dd31d9b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

language_tool_python/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def correct(text: str, matches: List[Match]) -> str:
112112
:rtype: str
113113
"""
114114
ltext = list(text)
115-
if len(matches):
115+
if len(matches): # some suggestions available, we'll use first/best
116116
matches = [match for match in matches if match.replacements]
117117
if matches:
118118
errors = [ltext[match.offset:match.offset + match.errorLength]
@@ -127,9 +127,9 @@ def correct(text: str, matches: List[Match]) -> str:
127127
ltext[frompos:topos] = list(repl)
128128
correct_offset += len(repl) - len(errors[n])
129129
return ''.join(ltext)
130-
else:
130+
else: # no suggestions for given language, i.e. gibberish submit
131131
return str()
132-
else:
132+
else: # Correct string submit
133133
return None
134134

135135

0 commit comments

Comments
 (0)