New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored master branch #3
Conversation
py3langid/examples/_twokenize.py
Outdated
urlExtraCrapBeforeEnd = regex_or(punctChars, entity) + "+?" | ||
urlExtraCrapBeforeEnd = f'{regex_or(punctChars, entity)}+?' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 58-195
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
This removes the following comments ( why? ):
# iOS 'emoji' characters (some smileys, some symbols) [\ue001-\uebbb]
# Standard version :) :( :] :D :P
# myleott: o.O and O.o are two of the biggest sources of differences
# reversed version (: D: use positive lookbehind to remove "(word):"
# TODO should try a big precompiled lexicon from Wikipedia, Dan Ramage told me (BTO) he does this
# between this and the Java version. One little hack won't hurt...
#inspired by http://en.wikipedia.org/wiki/User:Scapler/emoticons#East_Asian_style
# because eyes on the right side is more ambiguous with the standard usage of : ;
f = lambda fn, chunks: pool.imap_unordered(fn, chunks, chunksize=chunksize) | ||
yield f | ||
yield lambda fn, chunks: pool.imap_unordered(fn, chunks, chunksize=chunksize) | ||
else: | ||
if initializer is not None: | ||
initializer(*initargs) | ||
f = imap | ||
yield f | ||
|
||
yield imap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function MapPool
refactored with the following changes:
- Inline variable that is immediately yielded (
inline-immediately-yielded-variable
)
for docname in filenames: | ||
candidates.append(os.path.join(dirpath, docname)) | ||
candidates.extend(os.path.join(dirpath, docname) for docname in filenames) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function CorpusIndexer.__init__
refactored with the following changes:
- Replace a for append loop with list extend (
for-append-to-extend
)
reject_langs = { | ||
l | ||
for l in lang_domain_count if lang_domain_count[l] < min_domain | ||
} | ||
|
||
# Remove the languages from the indexer | ||
if reject_langs: | ||
if reject_langs := { | ||
l for l in lang_domain_count if lang_domain_count[l] < min_domain | ||
}: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function CorpusIndexer.prune_min_domain
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
This removes the following comments ( why? ):
# Remove the languages from the indexer
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 1.14%.
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! |
Branch
master
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run:Help us improve this pull request!