当前位置:网站首页>结巴分词器_分词器原理
结巴分词器_分词器原理
2022-06-28 09:22:00 【Java架构师必看】
大家好,我是架构君,一个会写代码吟诗的架构师。今天说一说结巴分词器_分词器原理,希望能够帮助大家进步!!!
安装jieba库:pip3 install jieba
#结巴分词
# -*- coding:utf-8 -*-
import sys
import os
import jiebasent = '天善智能是一个专注于商业智能BI、数据分析、数据挖掘和大数据技术领域的技术社区 www.hellobi.com 。内容从最初的商业智能 BI 领域也扩充到了数据分析、数据挖掘和大数据相关 的技术领域,包括 R、Python、SPSS、Hadoop、Spark、Hive、Kylin等,成为一个专注于数据领域的垂直社区。天善智能致力于构建一个基于数据领域的生态圈,通过社区链接一切 与数据相关的资源:例如数据本身、人、数据方案供应商和企业,与大家一起共同努力推动大数据、商业智能BI在国内的普及和发展。'
print (sent)结巴分词模块有三种分词模式:
1. 全模式 :把句子中所有可以成词的词语都扫描出来,速度非常快,但是不能解决歧义。这种全模式,会根据字典,将所有出现的字词全部匹配划分,所以会出现重复,显然,这不是我们需要的。
2.精确模式 :试图将句子最精确地切开,适合文本分析(类似LTP分词方式),而这种精确模式就比较接近我们想要的了。
3.搜索引擎模式:在精确模式的基础上对长词再次切分,提高召回率,适合用于搜索引擎分词。这种搜索引擎模式也不错呢,更加细化了。
#全模式
wordlist = jieba.cut(sent,cut_all = True)
print('|'.join(wordlist))#精确切分
wordlist = jieba.cut(sent)
print('|'.join(wordlist)) #搜索引擎模式
wordlist = jieba.cut_for_search(sent)
print('|'.join(wordlist))发现新问题--增加用户自定义词典:回看精确模式的结果,发现有些新词汇或者专业词汇,例如:天善智能、大数据,这些不应该再被切分,所以在默认词典的基础上,我们可以加载自定义的词典。进入我的jieba模块目录->看到有个dict的词典,打开->发现有 1.词 2.数字(代表词频,越高越容易匹配到) 3.词性。为了方便,我们自己定义添加一个词典命名为userdict.txt
#增加用户自定义字典
#使用用户字典
jieba.load_userdict('D:\\Anaconda3\\Lib\\site-packages\\jieba\\userdict.txt')
wordlist = jieba.cut(sent)
print('|'.join(wordlist)) 参考资料:
https://zhuanlan.zhihu.com/p/29747350?utm_source=qq&utm_medium=social&utm_oi=780081763178258432
今天文章到此就结束了,感谢您的阅读,Java架构师必看祝您升职加薪,年年好运。
边栏推荐
- Screen settings in the source code of OBS Live Room
- A classic JVM class loaded interview question class singleton{static singleton instance = new singleton(); private singleton() {}
- Decision table method for basic content learning of software testing (2)
- Calculation of stock purchase and sale expenses
- 详解final、finally和finalize
- State machine program framework
- I want to register my stock account online. How do I do it? Is online account opening safe?
- rman备份报ORA-19809 ORA-19804
- Ingersoll Rand面板维修IR英格索兰微电脑控制器维修XE-145M
- Implement global double finger long press to return to the desktop
猜你喜欢

Machine virtuelle 14 installer win7 (tutoriel)

Import and export of a single collection in postman

For the development of short video app, the elder warned me to choose the open source code

线程的生命周期

硬盘基本知识(磁头、磁道、扇区、柱面)

1182:合影效果

Redis5.0 slot migration, free play (single machine migration cluster)

Postman interface test

DEJA_ Vu3d - 051 of cesium function set - perfect realization of terrain excavation

Resource scheduling and task scheduling of spark
随机推荐
[ybtoj advanced training guide] maximum separation [hash] [Floyd]
学习阿里如何进行数据指标体系的治理
new URL(“www.jjj.com“)
Which occupational groups are suitable for the examination
在本类私有属性直接使用?new()在使用!!!
为什么SELECT * 会导致查询效率低?
STL -- binder
Deployment of MySQL database in Linux Environment
[share OpenGL tutorial]
Campus honey decoration of APP course design (e-commerce platform)
Differences between task parameter types inout and ref
1181: integer parity sort
買賣股票費用計算
From knowledge to wisdom: how far will the knowledge map go?
A classic JVM class loaded interview question class singleton{static singleton instance = new singleton(); private singleton() {}
Illustration of MySQL binlog, redo log and undo log
Data modeling based on wide table
我想网上注册股票开户,如何操作?在线开户安全么?
Do static code blocks always execute first? The pattern is smaller!!!
How to reduce the risk of project communication?