Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
centroid = centroids[k]
plot_series(centroid, centroid_plot_foldpath, 'centroid', True)
members = X[y == k]
n_samples = members.shape[0]
sample_rows = np.arange(n_samples)
np.random.shuffle(sample_rows)
members_to_plot = members[sample_rows[:10]]
for i in xrange(members_to_plot.shape[0]):
print(k, i)
plot_series(members_to_plot[i], centroid_plot_foldpath, 'ex-%d' % i)
if __name__ == '__main__':
sys.exit(plac.call(main))
nr_row, nr_dim = header.split()
nlp.vocab.reset_vectors(width=int(nr_dim))
for line in file_:
line = line.rstrip().decode("utf8")
pieces = line.rsplit(" ", int(nr_dim))
word = pieces[0]
vector = numpy.asarray([float(v) for v in pieces[1:]], dtype="f")
nlp.vocab.set_vector(word, vector) # add the vectors to the vocab
# test the vectors and similarity
text = "class colspan"
doc = nlp(text)
print(text, doc[0].similarity(doc[1]))
if __name__ == "__main__":
plac.call(main)
i.interact(verbose=verbose)
elif multiline:
i.multiline(verbose=verbose)
elif serve:
i.start_server(serve)
elif batch:
run((fname,) + extra, 'execute', verbose)
elif test:
run((fname,) + extra, 'doctest', verbose)
print('run %s plac test(s)' % (len(extra) + 1))
else:
baseparser.print_usage()
main.add_help = False
if __name__ == '__main__':
plac.call(main)
def main():
plac.call(__main_delegate__)
thread = threading.Thread(target=open_browser, args=[browser, url])
thread.start()
else:
print('open following url by web browser', file=sys.stderr)
print(url, file=sys.stderr)
displacy.serve(docs, style, options={'compact': True, 'collapse_punct': False})
def open_browser(browser, url, wait=0.5):
if wait:
time.sleep(wait)
browser.open(url)
if __name__ == '__main__':
plac.call(main)
logger.info(output)
process = subprocess.Popen(submit_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output, error = process.communicate()
if error:
logger.error(error)
logger.info(output)
res = os.chdir(f'{cwd}')
try_log_error(res,f"Changed to directory: {cwd}")
print(res)
except Exception as f:
logger.error(f)
if __name__ == '__main__':
import plac; plac.call(main)
trainer.record_train_loss(loss)
with model.use_params(optimizer.averages):
dev_acc_avg = model.evaluate(dev_X, dev_Y)
print('Avg dev.: %.3f' % dev_acc_avg)
trainer.record_dev_acc(dev_acc_avg)
with model.use_params(optimizer.averages):
print('Avg dev.: %.3f' % score_model(model, dev_X, dev_Y))
print('Avg test.: %.3f' % score_model(model, test_X, test_Y))
with open('out.pickle', 'wb') as file_:
pickle.dump(model, file_, -1)
if __name__ == '__main__':
plac.call(main)
# # Split on double line breaks
# [{"IS_SPACE": True, "TEXT": { "REGEX" : "([\r\t ]?[\n]){2,}" }}, {}],
# # Split on hard punctuation
# [{"IS_PUNCT": True, "TEXT" : { "IN" : ["!", "?"]}}, {}],
# # Split on full stop if not followed by lower case letter or digit
# [{"IS_PUNCT": True, "TEXT": "."}, {"SHAPE": { "REGEX" : "^[^xd]" }}]
# ]
nlp = spacy.load("fr", disable=['ner', 'parser'])
custom = RuleSentencizer(nlp, **sent_config)
nlp.add_pipe(custom)
doc = nlp(text)
for sent in doc.sents:
print("<%s>"%sent.text)
if __name__ == "__main__":
plac.call(main)
@plac.annotations(
input_path=(video_splitter.__plac_input_path_doc__),
output_dir_path=(video_splitter.__plac_output_dir_path_doc__),
melt=(video_splitter.__plac_melt_doc__),
melt_command_tail=(video_splitter.__plac_melt_command_tail_doc__),
recursive=(video_splitter.__plac_recursive_doc__, "flag"),
version=(video_splitter.__plac_version_doc__, "flag"),
debug=(video_splitter.__plac_debug_doc__, "flag"),
)
def remove_trailing_frame(input_path, output_dir_path, melt=video_splitter.melt_default, melt_command_tail=video_splitter.melt_command_tail_default, recursive=video_splitter.recursive_default, version=False, debug=False):
"""Removes the trailing frame which has been added by accident in versions of video-splitter below 1.2."""
videoSplitterRemoveTrailingFrame = VideoSplitterRemoveTrailingFrame(input_path, output_dir_path, melt, melt_command_tail, recursive, version, debug)
videoSplitterRemoveTrailingFrame.removeTrailingFrame()
if __name__ == "__main__":
plac.call(remove_trailing_frame)
# example7.py
from datetime import datetime
def main(dsn, *scripts):
"Run the given scripts on the database"
for script in scripts:
print('executing %s' % script)
# ...
if __name__ == '__main__':
import plac; plac.call(main)