-
Notifications
You must be signed in to change notification settings - Fork 7
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,13 +135,10 @@ def MapPool(processes=None, initializer=None, initargs=None, maxtasksperchild=No | |
|
||
if processes > 1: | ||
with closing( mp.Pool(processes, initializer, initargs, maxtasksperchild)) as pool: | ||
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 | ||
Comment on lines
-138
to
+142
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
if processes > 1: | ||
pool.join() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,8 +98,7 @@ def __init__(self, root, min_domain=MIN_DOMAIN, proportion=TRAIN_PROP, langs=Non | |
# root supplied was the root of a directory structure | ||
candidates = [] | ||
for dirpath, dirnames, filenames in os.walk(root, followlinks=True): | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
else: | ||
# root supplied was a file, interpet as list of paths | ||
candidates = map(str.strip, open(root)) | ||
|
@@ -180,13 +179,9 @@ def prune_min_domain(self, min_domain): | |
for langs in self.coverage_index.values(): | ||
for lang in langs: | ||
lang_domain_count[lang] += 1 | ||
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 | ||
}: | ||
Comment on lines
-183
to
+184
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
This removes the following comments ( why? ):
|
||
#print "reject (<{0} domains): {1}".format(min_domain, sorted(reject_langs)) | ||
reject_ids = {self.lang_index[l] for l in reject_langs} | ||
|
||
|
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-fstring-for-concatenation
)This removes the following comments ( why? ):