Fine-grained analysis of Chinese company names: intelligent word segmentation tools help extraction of place names, brand names, industry words and suffixes
The word segmentation tool for Chinese company names supports the extraction of place names, brand names (subject words), industry words, and company name suffixes in company names.
Analyze the company name text, identify and extract place names (place), brand names (brand), industry words (trade), and company name suffixes (suffix).
- Supplement the third-level place names in China and optimize the extraction effect of place names
- Optimizing the Brand Name Boundary Problem
- Word extraction from multiple industries
Run the evaluation script evaluate_file.py , use the conservative evaluation method that the prediction result is equal to the GroundTruth completion, and
evaluate the result:
-
Accuracy: 97.0%
-
Recall rate: 96.7%
-
Fully automatic installation: pip install -U companynameparser
-
Semi-automatic installation:
git clone https://github.com/shibing624/companynameparser.git
cd companynameparser
python setup.py install
It is fine to complete the installation by either of the above two methods. If you don't want to install, you can download the github source package, install and depend on requirements.txt and use it again.
- Extract Company Name
Company name element extraction function base_demo.py
import companynameparser
company_strs = [
"武汉海明智业电子商务有限公司",
"泉州益念食品有限公司",
"常州途畅互联网科技有限公司合肥分公司",
"昆明享亚教育信息咨询有限公司",
]
for name in company_strs:
r = companynameparser.parse(name)
print(r)
output:
{'place': '武汉', 'brand': '海明智业', 'trade': '电子商务', 'suffix': '有限公司', 'symbol': ''}
{'place': '泉州', 'brand': '益念', 'trade': '食品', 'suffix': '有限公司', 'symbol': ''}
{'place': '常州,合肥', 'brand': '途畅', 'trade': '互联网科技', 'suffix': '有限公司,分公司', 'symbol': ''}
{'place': '昆明', 'brand': '享亚', 'trade': '教育信息咨询', 'suffix': '有限公司', 'symbol': ''}
parse
The input here of the methodname
is str;
The output is a dict including place (place name), brand (brand name), trade (industry word name), suffix (suffix name), symbol (punctuation mark); multiple place names, brands, and industry words are separated by
,
intervals , eg'常州,合肥'
.
- All Demo
A demo demonstrates all examples all_demo.py , including:
- Extraction of each element of the company name
- Element name result with participle
- Show the position of each element
- User-defined word segmentation dictionary, used to solve some manslaughter and missed recall
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)
output:
{'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': ''}
Support batch extraction of province and city information of addresses:
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.
Input file:
company_demo.txt
; Output file:out.csv
, place name, brand name, industry name, suffix name with\t
interval
Reference link: https://github.com/shibing624/companynameparser
If you can't enter github, you can also enter https://download.csdn.net/download/sinat_39620217/88205221 to download relevant information for free