-
大小: 35.62MB文件类型: .gz金币: 1下载: 0 次发布日期: 2023-06-13
- 语言: Python
- 标签: spacy_model en_core_web_
资源简介
Spacy是自然语言处理需要使用的一个工具包,加载模型后就可以做分词,词性标注等任务啦。 当你执行这条命令python -m spacy download en。但是没有网的时候,可能这个包有用。
spaCy >=2.0.0a18
代码片段和文件信息
#!/usr/bin/env python
# coding: utf8
from __future__ import unicode_literals
import io
import json
from os import path walk
from shutil import copy
from setuptools import setup
def load_meta(fp):
with io.open(fp encoding=‘utf8‘) as f:
return json.load(f)
def list_files(data_dir):
output = []
for root _ filenames in walk(data_dir):
for filename in filenames:
if not filename.startswith(‘.‘):
output.append(path.join(root filename))
output = [path.relpath(p path.dirname(data_dir)) for p in output]
output.append(‘meta.json‘)
return output
def list_requirements(meta):
parent_package = meta.get(‘parent_package‘ ‘spacy‘)
requirements = [parent_package + meta[‘spacy_version‘]]
if ‘setup_requires‘ in meta:
requirements += meta[‘setup_requires‘]
return requirements
def setup_package():
root = path.abspath(path.dirname(__file__))
meta_path = path.join(root ‘meta.json‘)
meta = load_meta(meta_path)
model_name = str(meta[‘lang‘] + ‘_‘ + meta[‘name‘])
model_dir = path.join(model_name model_name + ‘-‘ + meta[‘version‘])
copy(meta_path path.join(model_name))
copy(meta_path model_dir)
setup(
name=model_name
description=meta[‘description‘]
author=meta[‘author‘]
author_email=meta[‘email‘]
url=meta[‘url‘]
version=meta[‘version‘]
license=meta[‘license‘]
packages=[model_name]
package_data={model_name: list_files(model_dir)}
install_requires=list_requirements(meta)
zip_safe=False
)
if __name__ == ‘__main__‘:
setup_package()
评论
共有 条评论