GH-560: Add encoding='utf-8' to fix "UnicodeDecodeError" (Sourcery refactored)#3
GH-560: Add encoding='utf-8' to fix "UnicodeDecodeError" (Sourcery refactored)#3sourcery-ai[bot] wants to merge 1 commit into
Conversation
| if label not in self.label2index: | ||
| index = self.vocab_size | ||
| self.label2index[label] = index | ||
| self.index2label[index] = label | ||
| self.vocab_size += 1 | ||
| return index | ||
| else: | ||
| if label in self.label2index: | ||
| return self.label2index[label] | ||
| index = self.vocab_size | ||
| self.label2index[label] = index | ||
| self.index2label[index] = label | ||
| self.vocab_size += 1 | ||
| return index |
There was a problem hiding this comment.
Function LabelEncoder.encode refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches) - Remove unnecessary else after guard condition (
remove-unnecessary-else)
| print("Currently training: %s (aspect or polarity)" % training) | ||
| print(f"Currently training: {training} (aspect or polarity)") |
There was a problem hiding this comment.
Function UITABSAHotel.__init__ refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| if label not in self.label2index: | ||
| index = self.vocab_size | ||
| self.label2index[label] = index | ||
| self.index2label[index] = label | ||
| self.vocab_size += 1 | ||
| return index | ||
| else: | ||
| if label in self.label2index: | ||
| return self.label2index[label] | ||
| index = self.vocab_size | ||
| self.label2index[label] = index | ||
| self.index2label[index] = label | ||
| self.vocab_size += 1 | ||
| return index |
There was a problem hiding this comment.
Function LabelEncoder.encode refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches) - Remove unnecessary else after guard condition (
remove-unnecessary-else)
| print("Currently training: %s (aspect or polarity)" % training) | ||
| print(f"Currently training: {training} (aspect or polarity)") |
There was a problem hiding this comment.
Function UITABSARestaurant.__init__ refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
Sourcery Code Quality ReportMerging this PR leaves code quality unchanged.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
Pull Request #2 refactored by Sourcery.
Since the original Pull Request was opened as a fork in a contributor's
repository, we are unable to create a Pull Request branching from it.
To incorporate these changes, you can either:
Merge this Pull Request instead of the original, or
Ask your contributor to locally incorporate these commits and push them to
the original Pull Request
Incorporate changes via command line
NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Help us improve this pull request!