Skip to content

Commit a7788e9

Browse files
committed
run black 23.12.0 on the codebase
1 parent d815d8e commit a7788e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+151
-227
lines changed

nltk/app/chunkparser_app.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ def _eval_demon(self):
713713
if self.normalized_grammar != self._eval_normalized_grammar:
714714
# Check if we've seen this grammar already. If so, then
715715
# just use the old evaluation values.
716-
for (g, p, r, f) in self._history:
716+
for g, p, r, f in self._history:
717717
if self.normalized_grammar == self.normalize_grammar(g):
718718
self._history.append((g, p, r, f))
719719
self._history_index = len(self._history) - 1
@@ -850,7 +850,7 @@ def _init_widgets(self, top):
850850
).grid(column=i * 2 + 1, row=0)
851851
self.helptabs[self.HELP[0][0]].configure(font=self._font)
852852
self.helpbox.tag_config("elide", elide=True)
853-
for (tag, params) in self.HELP_AUTOTAG:
853+
for tag, params in self.HELP_AUTOTAG:
854854
self.helpbox.tag_config("tag-%s" % tag, **params)
855855
self.show_help(self.HELP[0][0])
856856

@@ -1047,7 +1047,7 @@ def show_trace(self, *e):
10471047
def show_help(self, tab):
10481048
self.helpbox["state"] = "normal"
10491049
self.helpbox.delete("1.0", "end")
1050-
for (name, tabstops, text) in self.HELP:
1050+
for name, tabstops, text in self.HELP:
10511051
if name == tab:
10521052
text = text.replace(
10531053
"<<TAGSET>>",
@@ -1066,7 +1066,7 @@ def show_help(self, tab):
10661066
self.helpbox.config(tabs=tabstops)
10671067
self.helpbox.insert("1.0", text + "\n" * 20)
10681068
C = "1.0 + %d chars"
1069-
for (tag, params) in self.HELP_AUTOTAG:
1069+
for tag, params in self.HELP_AUTOTAG:
10701070
pattern = f"(?s)(<{tag}>)(.*?)(</{tag}>)"
10711071
for m in re.finditer(pattern, text):
10721072
self.helpbox.tag_add("elide", C % m.start(1), C % m.end(1))

nltk/app/wordnet_app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ def run():
281281
# Main logic for wordnet browser.
282282
#
283283

284+
284285
# This is wrapped inside a function since wn is only available if the
285286
# WordNet corpus is installed.
286287
def _pos_tuples():
@@ -983,7 +984,7 @@ def app():
983984
server_mode = False
984985
help_mode = False
985986
logfilename = None
986-
for (opt, value) in opts:
987+
for opt, value in opts:
987988
if (opt == "-l") or (opt == "--logfile"):
988989
logfilename = str(value)
989990
elif (opt == "-p") or (opt == "--port"):

nltk/ccg/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def substitute(self, substitutions):
125125
"""If there is a substitution corresponding to this variable,
126126
return the substituted category.
127127
"""
128-
for (var, cat) in substitutions:
128+
for var, cat in substitutions:
129129
if var == self:
130130
return cat
131131
return self
@@ -197,7 +197,7 @@ def substitute(self, subs):
197197
if not self.is_variable():
198198
return self
199199

200-
for (var, restrs) in subs:
200+
for var, restrs in subs:
201201
if var == "_":
202202
return Direction(self._dir, restrs)
203203
return self

nltk/ccg/chart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def printCCGDerivation(tree):
380380

381381
# Construct a string with both the leaf word and corresponding
382382
# category aligned.
383-
for (leaf, cat) in leafcats:
383+
for leaf, cat in leafcats:
384384
str_cat = "%s" % cat
385385
nextlen = 2 + max(len(leaf), len(str_cat))
386386
lcatlen = (nextlen - len(str_cat)) // 2

nltk/ccg/combinator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def __str__(self):
128128

129129
# Predicates for function application.
130130

131+
131132
# Ensures the left functor takes an argument on the right
132133
def forwardOnly(left, right):
133134
return left.dir().is_forward()

nltk/chat/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def respond(self, str):
9494
"""
9595

9696
# check each pattern
97-
for (pattern, response) in self._pairs:
97+
for pattern, response in self._pairs:
9898
match = pattern.match(str)
9999

100100
# did the pattern match?

nltk/chunk/named_entity.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def _tagged_to_parse(self, tagged_tokens):
140140
"""
141141
sent = Tree("S", [])
142142

143-
for (tok, tag) in tagged_tokens:
143+
for tok, tag in tagged_tokens:
144144
if tag == "O":
145145
sent.append(tok)
146146
elif tag.startswith("B-"):
@@ -260,7 +260,7 @@ def subfunc(m):
260260
if fmt == "binary":
261261
i = 0
262262
toks = Tree("S", [])
263-
for (s, e, typ) in sorted(entities):
263+
for s, e, typ in sorted(entities):
264264
if s < i:
265265
s = i # Overlapping! Deal with this better?
266266
if e <= s:
@@ -275,7 +275,7 @@ def subfunc(m):
275275
elif fmt == "multiclass":
276276
i = 0
277277
toks = Tree("S", [])
278-
for (s, e, typ) in sorted(entities):
278+
for s, e, typ in sorted(entities):
279279
if s < i:
280280
s = i # Overlapping! Deal with this better?
281281
if e <= s:

nltk/chunk/regexp.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ def to_chunkstruct(self, chunk_label="CHUNK"):
165165
index = 0
166166
piece_in_chunk = 0
167167
for piece in re.split("[{}]", self._str):
168-
169168
# Find the list of tokens contained in this piece.
170169
length = piece.count("<")
171170
subsequence = self._pieces[index : index + length]

nltk/chunk/util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def conlltags2tree(
457457
Convert the CoNLL IOB format to a tree.
458458
"""
459459
tree = Tree(root_label, [])
460-
for (word, postag, chunktag) in sentence:
460+
for word, postag, chunktag in sentence:
461461
if chunktag is None:
462462
if strict:
463463
raise ValueError("Bad conll tag sequence")
@@ -592,7 +592,6 @@ def ieerstr2tree(
592592

593593

594594
def demo():
595-
596595
s = "[ Pierre/NNP Vinken/NNP ] ,/, [ 61/CD years/NNS ] old/JJ ,/, will/MD join/VB [ the/DT board/NN ] ./."
597596
import nltk
598597

nltk/classify/decisiontree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def pseudocode(self, prefix="", depth=4):
108108
if self._fname is None:
109109
return f"{prefix}return {self._label!r}\n"
110110
s = ""
111-
for (fval, result) in sorted(
111+
for fval, result in sorted(
112112
self._decisions.items(),
113113
key=lambda item: (item[0] in [None, False, True], str(item[0]).lower()),
114114
):

0 commit comments

Comments
 (0)