当前位置:网站首页>2、自然語言處理入門
2、自然語言處理入門
2022-06-10 02:10:00 【C--G】
簡介

自然語言入門
文本預處理



文本處理的基本方法



jieba分詞
安裝
pip install jieba
使用
- 精確模式分詞
視圖將句子最精確地切開,適合文本分析
- 全模式分詞
把句子中所有的可以成詞的詞語讀掃描出來,速度非常快,但是不能消除歧義

- 搜索引擎模式
在精確模式的基礎上,對長詞再次切分,提高召回率,適合用於搜索引擎分詞
- 中文繁體分詞
針對中國香港,臺灣地區的繁體文本進行分詞
- 使用用戶自定義詞典


流行中英文分詞工具hanlp
中英文NLP處理工具包,基於tensorflow2.0,使用在學術界和行業中推廣最先進的深度學習技術
安裝
pip install hanlp
中文分詞

英文分詞


hanlp進行中文命名實體識別

hanlp進行英文命名實體識別



使用jieba進行中文詞性標注

使用hanlp進行中文詞性標注

使用hanlp進行英文詞性標注

文本張量錶示方法


one-hot






word2vec






使用fasttext工具實習word2vec的訓練和使用
- 數據准備

- 數據處理


- 訓練詞向量


- 模型超參數設定

- 模型效果檢驗

- 模型的保存與重加載

文本數據分析

標簽數量分布


在這裏插入圖片描述
句子長度分布








不同詞匯總數統計


高頻形容詞詞雲






文本特征處理

n-gram特征




文本長度規範



文本數據增强




附
jieba詞性對照錶


hanlp詞性對照錶


案例:新聞主題分類任務

# 導入相關torch工具包
import torch
import torchtext
# 導入torchtext.datasets中的文本分類任務
from torchtext.datasets import text_classification
import os
load_data_path = "./data"
if not os.path.isdir(load_data_path):
os.mkdir(load_data_path)
# 選取torchtext中的文本分類數據集‘AG_NEWS’即新聞主題分類數據,保存在指定目錄下
# 並將數值映射後的訓練和驗證數據加載到內存中
train_dataset,test_dataset = text_classification.DATASETS['AG_NEWS'](root=load_data_path)


構建帶有Embedding層的文本分類模型



對數據進行batch處理

構建訓練與驗證函數


進行模型訓練和驗證



經典序列模型——HMM與CRF
HMM



CRF



边栏推荐
- Can write a desktop digital hour clock program without programming, which can be easily realized in only 3 steps
- [win] the browser cannot open the web page and DNS appears_ PROBE_ FINISHED_ NO_ INTERNET
- Inftnews | when the meta universe is going on: how are those big Internet companies planning their layout?
- MySql安装+测试连接+常用终端mysql命令(超详细)
- 2022年上海市安全员C证考试模拟100题及模拟考试
- NACK of webrtc's audio weak network countermeasure
- When the MySQL service is started during initialization, it shows that net is neither an internal or external command nor a runnable program. How to solve this problem? This is the same as net Exe mis
- 10 common high-frequency business scenarios that trigger IO bottlenecks
- Is it appropriate for novice investors to buy financial products with a rate of return?
- Environment configuration and initial compilation of source code analysis of virtual engine ue4.26
猜你喜欢

Phantom engine plug-in - Maya LIVELINK - install and use

在keras中使用gpu加速训练模型;安装cuda;cudnn;cudnn_cnn_infer64_8.dll 不在path中;device_lib.list_local_devices无gpu;挂掉

Smart Cloud Light Gateway Service pour améliorer l'efficacité de la gestion de la production

Alibaba cloud 618 award winning experience: build an OSS based image sharing website

LeetCode 700:二叉搜索树中的搜索

副业收入是我做程序员的3倍,工作外的B面人生是怎样的?

Inftnews | the future of NFT in Web3 economy

Cordova website packaging_ Cordova packaging website

MySql安装+测试连接+常用终端mysql命令(超详细)

With all due respect: programmers spend most of their time not writing code, but...
随机推荐
Two software test questions
Nodejs reported an internal error typeerror: cannot read property 'destroy' of undefined
LabVIEW在波形图或波形图表上显示时间和日期
Deepin runs Cherrytree and reports an error. The module gtksourceview2 cannot be found
重塑 IT 领导职业生涯的六种方法
投资新手买收益率多少的理财产品合适?
Smart cloud light gateway service to improve production management efficiency
iNFTnews | NFT在Web3經濟裏的未來
35岁职场焦虑,越来越多的人这样选择
Hoo Hufu Research Institute | houlang in the coin circle - gamefi like baokemeng: evoverses
Redis advanced knowledge points (can be learned, reviewed and interviewed)
[no title] 416 Split equal sum subset
SSM framework integration - build a simple account login system
[experience sharing] summary of database operations commonly used in Django development
NACK of webrtc's audio weak network countermeasure
Dry goods | touch screen operation automation of mobile app automation
步进电机总结
Numpy Library Learning
MySQL installation + test connection + common terminal MySQL commands (super detailed)
【LeetCode】64. Minimum path sum