Skip to main content

中文公司名称解析器和提取工具,公司名称识别工具

项目描述

公司名称解析器

PyPI 版本 下载 欢迎投稿 许可 Apache 2.0 Python3 微信群

公司名称解析器,提取公司名称品牌。中文公司名称分词工具,支持公司名称中的地名,名称(主词),行业词,公司名称后缀品牌提取。

指导

特征

对公司名文本解析,识别并提取地名(地点)、名称(品牌)、行业词(行业)、公司名后缀词(后缀)。

评估

运行评估评估evaluate_file.py,使用预测结果与GroundTruth完成调查才为计算对的评估方法,评估结果:

  • 准确率:97.0%
  • 命中率:96.7%

安装

  • 安装:pip install -U companynameparser
  • 半自动安装:
git clone https://github.com/shibing624/companynameparser.git
cd companynameparser
python setup.py install

通过以上方法的一种完成安装都可以。如果不想安装,可以再下载github源码包,安装依赖requirements.txt使用。

用法

  • 提取公司名称

公司名称各元素提取功能base_demo.py

import companynameparser

company_strs = [
    "武汉海明智业电子商务有限公司",
    "泉州益念食品有限公司",
    "常州途畅互联网科技有限公司合肥分公司",
    "昆明享亚教育信息咨询有限公司",
]
for name in company_strs:
    r = companynameparser.parse(name)
    print(r)

输出:

{'place': '武汉', 'brand': '海明智业', 'trade': '电子商务', 'suffix': '有限公司', 'symbol': ''}
{'place': '泉州', 'brand': '益念', 'trade': '食品', 'suffix': '有限公司', 'symbol': ''}
{'place': '常州,合肥', 'brand': '途畅', 'trade': '互联网科技', 'suffix': '有限公司,分公司', 'symbol': ''}
{'place': '昆明', 'brand': '享亚', 'trade': '教育信息咨询', 'suffix': '有限公司', 'symbol': ''}

parse的方法在这里输入name是str;

输出是一个包括地点(地名),品牌(品牌名),贸易(词名),后缀(后缀名),符号(点符号)的字典;多个地名、品牌、行业词之间用,间隔,如'常州,合肥'

  • 所有演示

一个演示视频所有示例all_demo.py,包括:

  1. 公司名称 各元素抽取
  2. 元素名称结果带分词
  3. 显示各元素的位置
  4. 用户自定义分词词典,用于解决部分杀和漏词
import companynameparser

company_strs = [
    "武汉海明智业电子商务有限公司",
    "泉州益念食品有限公司",
    "常州途畅互联网科技有限公司合肥分公司",
    "昆明享亚教育信息咨询有限公司",
    "深圳光明区三晟股份有限公司",
]
for name in company_strs:
    r = companynameparser.parse(name)
    print(r)

print("*" * 42, ' enable word segment')
for name in company_strs:
    r = companynameparser.parse(name, pos_sensitive=False, enable_word_segment=True)
    print(r)

print("*" * 42, ' pos sensitive')
for name in company_strs:
    r = companynameparser.parse(name, pos_sensitive=True, enable_word_segment=False)
    print(r)

print("*" * 42, 'enable word segment and pos')
for name in company_strs:
    r = companynameparser.parse(name, pos_sensitive=True, enable_word_segment=True)
    print(r)

print("*" * 42, 'use custom name')
companynameparser.set_custom_split_file('./custom_name_split.txt')
for i in company_strs:
    r = companynameparser.parse(i)
    print(r)

输出:

{'place': '武汉', 'brand': '海明智业', 'trade': '电子商务', 'suffix': '有限公司', 'symbol': ''}
{'place': '泉州', 'brand': '益念', 'trade': '食品', 'suffix': '有限公司', 'symbol': ''}
{'place': '常州,合肥', 'brand': '途畅', 'trade': '互联网科技', 'suffix': '有限公司,分公司', 'symbol': ''}
{'place': '昆明', 'brand': '享亚', 'trade': '教育信息咨询', 'suffix': '有限公司', 'symbol': ''}
{'place': '深圳光明', 'brand': '区三晟', 'trade': '', 'suffix': '股份有限公司', 'symbol': ''}
******************************************  enable word segment
{'place': '武汉', 'brand': '海明智业', 'trade': '电子商务', 'suffix': '有限公司', 'symbol': ''}
{'place': '泉州', 'brand': '益念', 'trade': '食品', 'suffix': '有限公司', 'symbol': ''}
{'place': '常州,合肥', 'brand': '途畅', 'trade': '互联网,科技', 'suffix': '有限公司,分公司', 'symbol': ''}
{'place': '昆明', 'brand': '享亚', 'trade': '教育,信息,咨询', 'suffix': '有限公司', 'symbol': ''}
{'place': '深圳光明', 'brand': '区三晟', 'trade': '', 'suffix': '股份,有限公司', 'symbol': ''}
******************************************  pos sensitive
{'place': [('武汉', 0, 2)], 'brand': [('海明智业', 2, 6)], 'trade': [('电子商务', 6, 10)], 'suffix': [('有限公司', 10, 14)], 'symbol': []}
{'place': [('泉州', 0, 2)], 'brand': [('益念', 2, 4)], 'trade': [('食品', 4, 6)], 'suffix': [('有限公司', 6, 10)], 'symbol': []}
{'place': [('常州', 0, 2), ('合肥', 13, 15)], 'brand': [('途畅', 2, 4)], 'trade': [('互联网科技', 4, 9)], 'suffix': [('有限公司', 9, 13), ('分公司', 15, 18)], 'symbol': []}
{'place': [('昆明', 0, 2)], 'brand': [('享亚', 2, 4)], 'trade': [('教育信息咨询', 4, 10)], 'suffix': [('有限公司', 10, 14)], 'symbol': []}
{'place': [('深圳光明', 0, 4)], 'brand': [('区三晟', 4, 7)], 'trade': [], 'suffix': [('股份有限公司', 7, 13)], 'symbol': []}
****************************************** enable word segment and pos
{'place': [('武汉', 0, 2)], 'brand': [('海明智业', 2, 6)], 'trade': [('电子商务', 6, 10)], 'suffix': [('有限公司', 10, 14)], 'symbol': []}
{'place': [('泉州', 0, 2)], 'brand': [('益念', 2, 4)], 'trade': [('食品', 4, 6)], 'suffix': [('有限公司', 6, 10)], 'symbol': []}
{'place': [('常州', 0, 2), ('合肥', 13, 15)], 'brand': [('途畅', 2, 4)], 'trade': [('互联网', 4, 7), ('科技', 7, 9)], 'suffix': [('有限公司', 9, 13), ('分公司', 15, 18)], 'symbol': []}
{'place': [('昆明', 0, 2)], 'brand': [('享亚', 2, 4)], 'trade': [('教育', 4, 6), ('信息', 6, 8), ('咨询', 8, 10)], 'suffix': [('有限公司', 10, 14)], 'symbol': []}
{'place': [('深圳光明', 0, 4)], 'brand': [('区三晟', 4, 7)], 'trade': [], 'suffix': [('股份', 7, 9), ('有限公司', 9, 13)], 'symbol': []}
****************************************** use custom name
{'place': '武汉', 'brand': '海明智业', 'trade': '电子商务', 'suffix': '有限公司', 'symbol': ''}
{'place': '泉州', 'brand': '益念', 'trade': '食品', 'suffix': '有限公司', 'symbol': ''}
{'place': '常州,合肥', 'brand': '途畅', 'trade': '互联网科技', 'suffix': '有限公司,分公司', 'symbol': ''}
{'place': '昆明', 'brand': '享亚', 'trade': '教育信息咨询', 'suffix': '有限公司', 'symbol': ''}
{'place': '深圳光明区', 'brand': '三晟', 'trade': '', 'suffix': '股份有限公司', 'symbol': ''}

命令行用法

典型模式

支持标注地址:所在省市区信息

python3 -m companynameparser company_demo.txt -o out.csv

usage: python3 -m companynameparser [-h] -o OUTPUT input
@description:

positional arguments:
  input                 the input file path, file encode need utf-8.

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        the output file path.

输入文件:company_demo.txt;输出文件:out.csv,地名、行业名、后缀名以\t间隔

去做

  • 补充中国三级地名,优化地名抽取效果
  • 品牌名称
  • 多个行业词抽取

接触

  • 问题(建议):GitHub 问题
  • 邮件我:xuming: xuming624@qq.com
  • 微信我:加我微信号:xuming624 ,进Python-NLP交流群,备注:姓名-公司名-NLP

引文

如果你在研究中使用了公司名称解析器,请按以下格式引用:

@software{companynameparser,
  author = {Xu Ming},
  title = {companynameparser: Company Name parser Tool},
  year = {2021},
  url = {https://github.com/shibing624/companynameparser},
}

执照

阿帕奇许可证 2.0

贡献

项目代码还很粗糙,如果大家对项目代码有所改进,欢迎提交回本,在提交之前注意以下两点:

  • tests添加相应的单元测试
  • 使用python -m pytest来运行所有单元测试,确保所有单测都是通过的

之后可以提交 PR。

参考

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

companynameparser-0.1.8.tar.gz (1.5 MB 查看哈希

已上传 source