Comments (3)
由于jieba的核心模型是基于训练数据上的词频信息,所以当在特定数据集上训练时,我们在该数据集的训练集上重新统计了词频信息。
以下是所使用的统计词频的代码:
def cal(file_name, outname):
mp = {}
with open(file_name, encoding='utf-8') as f:
lines = f.readlines()
for line in lines:
for i in line.strip().split(' '):
if len(i)==0:
continue
if not i in mp:
mp[i] = 0
mp[i] += 1
d = sorted(list(mp.items()), key=lambda x:(x[1], x[0]), reverse=True)
with open(outname, 'w', encoding='utf-8') as f:
for i, freq in d:
f.write(i+' '+str(freq)+'\n')
cal('icwb2-data/training/msr_training.utf8', 'msr_dict.txt')
以下是使用词频文件进行分词的代码:
tokenizer = jieba.Tokenizer(dictionary='msr_dict.txt')
tokenizer.cut(data)
from pkuseg-python.
明白了,非常感谢!
from pkuseg-python.
用户自定义字典可以加词频吗?
from pkuseg-python.
Related Issues (20)
- 能不能用自训练模型,对文件进行分词啊? HOT 1
- 打包缺少文件情况 FileNotFoundError: \\cache\\_MEI183882\\pkuseg\\dicts\\default.pkl' HOT 2
- 是否可以支持在 M1下使用 目前直接安装会报错。 HOT 2
- AttributeError: type object 'pkuseg' has no attribute 'pkuseg'
- TypeError: train() got an unexpected keyword argument 'nthread' HOT 1
- 词性标注效果过好 HOT 1
- Python3.9/3.9均无法pip安装成功 HOT 7
- 如何进行领域自适应训练? HOT 1
- 虚拟环境下使用出现FileNotFoundError,已单独下载postag还是无果
- cannot install in the environment of python 3.9 HOT 6
- pip install failed on Python 3.10.8 HOT 4
- 越训练,f-score越低 HOT 4
- pip install failed on Python 3.10.9 HOT 7
- 词性标注不准
- 预训练模型“default_v2”导入报错 HOT 2
- 祈使句/动宾短语,分词好像有些不对劲呢,望指点,谢谢
- 分词结果严重错误 HOT 5
- 词性输出错误
- Win10 3.10.14 安装失败 HOT 5
- Using Pre-Downloaded Domain Model is messy HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pkuseg-python.