mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 09:26:27 +03:00
Add pipeline setting to meta.json generator
This commit is contained in:
parent
086a06e7d7
commit
1203959625
|
@ -43,7 +43,7 @@ def package(cmd, input_dir, output_dir, meta=None, force=False):
|
||||||
meta = util.read_json(meta_path)
|
meta = util.read_json(meta_path)
|
||||||
else:
|
else:
|
||||||
meta = generate_meta()
|
meta = generate_meta()
|
||||||
validate_meta(meta, ['lang', 'name', 'version'])
|
meta = validate_meta(meta, ['lang', 'name', 'version'])
|
||||||
|
|
||||||
model_name = meta['lang'] + '_' + meta['name']
|
model_name = meta['lang'] + '_' + meta['name']
|
||||||
model_name_v = model_name + '-' + meta['version']
|
model_name_v = model_name + '-' + meta['version']
|
||||||
|
@ -86,20 +86,32 @@ def generate_meta():
|
||||||
('email', 'Author email', False),
|
('email', 'Author email', False),
|
||||||
('url', 'Author website', False),
|
('url', 'Author website', False),
|
||||||
('license', 'License', 'CC BY-NC 3.0')]
|
('license', 'License', 'CC BY-NC 3.0')]
|
||||||
|
|
||||||
prints("Enter the package settings for your model.", title="Generating meta.json")
|
prints("Enter the package settings for your model.", title="Generating meta.json")
|
||||||
meta = {}
|
meta = {}
|
||||||
for setting, desc, default in settings:
|
for setting, desc, default in settings:
|
||||||
response = util.get_raw_input(desc, default)
|
response = util.get_raw_input(desc, default)
|
||||||
meta[setting] = default if response == '' and default else response
|
meta[setting] = default if response == '' and default else response
|
||||||
|
meta['pipeline'] = generate_pipeline()
|
||||||
return meta
|
return meta
|
||||||
|
|
||||||
|
|
||||||
|
def generate_pipeline():
|
||||||
|
prints("If set to 'True', the default pipeline is used. If set to 'False', "
|
||||||
|
"the pipeline will be disabled. Components should be specified as a "
|
||||||
|
"comma-separated list of component names, e.g. vectorizer, tagger, "
|
||||||
|
"parser, ner. For more information, see the docs on processing pipelines.",
|
||||||
|
title="Enter your model's pipeline components")
|
||||||
|
pipeline = util.get_raw_input("Pipeline components", True)
|
||||||
|
replace = {'True': True, 'False': False}
|
||||||
|
return replace[pipeline] if pipeline in replace else pipeline.split(', ')
|
||||||
|
|
||||||
|
|
||||||
def validate_meta(meta, keys):
|
def validate_meta(meta, keys):
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if key not in meta or meta[key] == '':
|
if key not in meta or meta[key] == '':
|
||||||
prints("This setting is required to build your package.",
|
prints("This setting is required to build your package.",
|
||||||
title='No "%s" setting found in meta.json' % key, exits=1)
|
title='No "%s" setting found in meta.json' % key, exits=1)
|
||||||
|
return meta
|
||||||
|
|
||||||
|
|
||||||
def get_template(filepath):
|
def get_template(filepath):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user