97久久精品无码一区二区天美,开裆裤羞辱调教高h绳子,欧美成人brazzers,成人免费午夜性大片,成人国产一区二区精品小说

Skip to content

liwenju0/cutword

Folders and files

NameName
Last commit message
Last commit date

Latest commit

?

History

75 Commits
?
?
?
?
?
?
?
?
?
?
?
?
?
?

Repository files navigation

cutword

jieba不維護(hù)了,所以有了cutword。

cutword 是一個(gè)中文分詞庫(kù),字典文件根據(jù)截止到2024年1月份的最新數(shù)據(jù)統(tǒng)計(jì)得到,詞頻更加合理。 基于ac自動(dòng)機(jī)實(shí)現(xiàn)的分詞算法,分詞速度是jieba的兩倍。 可通過(guò) python -m cutword.comparewithjieba 進(jìn)行測(cè)試。

Note:本項(xiàng)目并不支持英文實(shí)體的識(shí)別。如需要英文實(shí)體的識(shí)別,推薦使用nltk。

1、安裝:

pip install -U cutword

2、使用:

2.1分詞功能

from  cutword import Cutter

cutter = Cutter()
res = cutter.cutword("你好,世界")
print(res)

本分詞器提供兩種詞典庫(kù),一種是基本的詞庫(kù),默認(rèn)加載。一種是升級(jí)詞庫(kù),升級(jí)詞庫(kù)總體長(zhǎng)度會(huì)比基本詞庫(kù)更長(zhǎng)一點(diǎn)。

如需要加載升級(jí)詞庫(kù),需要將 want_long_word 設(shè)為T(mén)rue

from  cutword import Cutter

cutter = Cutter()
res = cutter.cutword("精誠(chéng)所至,金石為開(kāi)")
print(res) # ['精誠(chéng)', '所', '至', ',', '金石為開(kāi)']

cutter = Cutter(want_long_word=True)
res = cutter.cutword("精誠(chéng)所至,金石為開(kāi)")
print(res) # ['精誠(chéng)所至', ',', '金石為開(kāi)']

初始化Cutter時(shí),支持傳入用戶(hù)自定義的詞典,詞典格式需要和本項(xiàng)目的dict文件保持一致,詞典中的詞性一列,暫時(shí)沒(méi)有使用,可隨意填寫(xiě)。

2.2命名實(shí)體識(shí)別

2.2.1 使用方法

from pprint import pprint
from  cutword import NER

ner = NER()
res = ner.predict(
  "奈雪的茶,新茶飲賽道開(kāi)創(chuàng)者,創(chuàng)立于2015年,推出“茶飲+軟歐包”雙品類(lèi)模式。聚焦以茶為核心的現(xiàn)代生活方式,奈雪已形成“現(xiàn)制茶飲”、“奈雪茗茶”及“RTD瓶裝茶”三大業(yè)務(wù)版塊,成功打造“霸氣玉油柑”、“鴨屎香寶藏茶”等多款行業(yè)經(jīng)典產(chǎn)品。",
  return_words=False
)
# 如果需要分詞結(jié)果,可將return_words設(shè)為T(mén)rue。返回的是(res, words)
pprint(res) 
'''
[[NERItem(entity='奈雪的茶', begin=0, end=4, ner_type_en='COMMERCIAL', ner_type_zh='商業(yè)'),
  NERItem(entity='茶飲', begin=6, end=8, ner_type_en='MANUFACTURE', ner_type_zh='物品'),
  NERItem(entity='2015年', begin=17, end=22, ner_type_en='TIME', ner_type_zh='時(shí)間'),
  NERItem(entity='茶飲', begin=26, end=28, ner_type_en='MANUFACTURE', ner_type_zh='物品'),
  NERItem(entity='軟歐包', begin=29, end=32, ner_type_en='MANUFACTURE', ner_type_zh='物品'),
  NERItem(entity='茶', begin=42, end=43, ner_type_en='FOOD', ner_type_zh='食品'),
  NERItem(entity='現(xiàn)代', begin=47, end=49, ner_type_en='TIME', ner_type_zh='時(shí)間'),
  NERItem(entity='奈雪', begin=54, end=56, ner_type_en='ORG', ner_type_zh='組織'),
  NERItem(entity='茶飲', begin=62, end=64, ner_type_en='MANUFACTURE', ner_type_zh='物品'),
  NERItem(entity='奈雪茗茶', begin=67, end=71, ner_type_en='COMMERCIAL', ner_type_zh='商業(yè)'),
  NERItem(entity='RTD瓶裝茶', begin=74, end=80, ner_type_en='FOOD', ner_type_zh='食品'),
  NERItem(entity='玉油柑', begin=95, end=98, ner_type_en='FOOD', ner_type_zh='食品'),
  NERItem(entity='鴨屎香寶藏茶', begin=101, end=107, ner_type_en='FOOD', ner_type_zh='食品')]]
'''

2.2.2 支持的實(shí)體類(lèi)型

編號(hào) 英文類(lèi)型名 中文類(lèi)型名
1 FOOD 食品
2 MATTER 物質(zhì)
3 MANUFACTURE 物品
4 CREATION 作品
5 ORG 組織
6 PC 計(jì)算機(jī)
7 PROPERTY 屬性
8 COMMERCIAL 商業(yè)
9 INCIDENT 事件
10 CREATURE 生物
11 BASE 基礎(chǔ)
12 AFFAIR 活動(dòng)
13 TIME 時(shí)間
14 LOC 位置
15 PHYSIOLOGY 組織器官
16 PERSON 人名
17 TERMINOLOGY 領(lǐng)域術(shù)語(yǔ)

2.2.3 性能比較

下面比較使用的數(shù)據(jù)集是我們內(nèi)部的驗(yàn)證集

cutword:

Category Precision Recall F1
ACTIVITY 0.786 0.679 0.729
ATTR 0.772 0.703 0.736
BASIC 0.878 0.854 0.866
BIOLOGY 0.867 0.877 0.872
BUSINESS 0.728 0.552 0.628
COMPUTER 0.854 0.645 0.735
EVENT 0.786 0.716 0.75
FOOD 0.758 0.742 0.75
KAFIELD 0.753 0.706 0.728
LIFE 0.798 0.766 0.782
MATTER 0.826 0.748 0.785
PRODUCT 0.776 0.72 0.747
TIME 0.916 0.897 0.906
WORK 0.912 0.794 0.849
ORG 0.814 0.765 0.788
LOC 0.83 0.81 0.82
PERSON 0.888 0.876 0.882

LAC:

Category Precision Recall F1
ORG 0.665 0.422 0.516
LOC 0.608 0.436 0.508
PERSON 0.776 0.741 0.758

本項(xiàng)目是匠數(shù)科技根據(jù)多年業(yè)務(wù)積累開(kāi)發(fā)的NLP基礎(chǔ)工具。匠數(shù)科技是一家專(zhuān)注于內(nèi)容安全領(lǐng)域的國(guó)家高新技術(shù)企業(yè)??梢詫?duì)大模型輸出內(nèi)容、各類(lèi)網(wǎng)站、媒體進(jìn)行安全性檢測(cè)并生成檢測(cè)報(bào)告。

本項(xiàng)目借鑒了蘇神的bytepiece的代碼,在此表示感謝。

Star History

Star History Chart

About

一個(gè)簡(jiǎn)單快速的分詞、命名實(shí)體識(shí)別工具

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages