@plac.annotations(<EOL>origin=("<STR_LIT>", "<STR_LIT>", None, str),<EOL>link_name=("<STR_LIT>", "<STR_LIT>", None, str),<EOL>force=("<STR_LIT>", "<STR_LIT>", "<STR_LIT:f>", bool),<EOL>)<EOL>def link(origin, link_name, force=False, model_path=None):
msg = Printer()<EOL>if util.is_package(origin):<EOL><INDENT>model_path = util.get_package_path(origin)<EOL><DEDENT>else:<EOL><INDENT>model_path = Path(origin) if model_path is None else Path(model_path)<EOL><DEDENT>if not model_path.exists():<EOL><INDENT>msg.fail(<EOL>"<STR_LIT>",<EOL>"<STR_LIT>".format(path2str(model_path)),<EOL>exits=<NUM_LIT:1>,<EOL>)<EOL><DEDENT>data_path = util.get_data_path()<EOL>if not data_path or not data_path.exists():<EOL><INDENT>spacy_loc = Path(__file__).parent.parent<EOL>msg.fail(<EOL>"<STR_LIT>",<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(path=spacy_loc),<EOL>exits=<NUM_LIT:1>,<EOL>)<EOL><DEDENT>link_path = util.get_data_path() / link_name<EOL>if link_path.is_symlink() and not force:<EOL><INDENT>msg.fail(<EOL>"<STR_LIT>".format(link_name),<EOL>"<STR_LIT>",<EOL>exits=<NUM_LIT:1>,<EOL>)<EOL><DEDENT>elif link_path.is_symlink():  <EOL><INDENT>link_path.unlink()<EOL><DEDENT>elif link_path.exists():  <EOL><INDENT>msg.fail(<EOL>"<STR_LIT>".format(link_name),<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>exits=<NUM_LIT:1>,<EOL>)<EOL><DEDENT>details = "<STR_LIT>" % (path2str(model_path), path2str(link_path))<EOL>try:<EOL><INDENT>symlink_to(link_path, model_path)<EOL><DEDENT>except:  <EOL><INDENT>msg.fail(<EOL>"<STR_LIT>".format(link_name),<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>)<EOL>msg.text(details)<EOL>raise<EOL><DEDENT>msg.good("<STR_LIT>", details)<EOL>msg.text("<STR_LIT>".format(link_name))<EOL>
Create a symlink for models within the spacy/data directory. Accepts
either the name of a pip package, or the local path to the model data
directory. Linking models allows loading them via spacy.load(link_name).