Skip to Content
Python和NLTK实现自然语言处理
book

Python和NLTK实现自然语言处理

by Posts & Telecom Press, Nitin Hardeniya
February 2024
Intermediate to advanced
649 pages
9h 58m
Chinese
Packt Publishing
Content preview from Python和NLTK实现自然语言处理

第4章 词性标注——识别单词

在自然语言处理中,词性(POS)标注是众多任务的其中一个。将它定义为将特定词性标签分配给句子中的单个单词。词性标签确定了某个单词是名词、动词、形容词,还是其他词性。词性标注具有多种应用,如信息检索、机器翻译、命名实体识别(NER)、语言分析等。

本章包括以下主题。

  • 创建词性标注的语料库。
  • 选择某个机器学习算法。
  • 涉及n元组方法的统计建模。
  • 使用POS标记的数据开发组块器。

词性标注是将类别(例如,名词、动词、形容词等)标签分配给句子中单个标记的过程。在NLTK中,标注器存在于nltk.tag包中,TaggerIbase类继承了这个标注器。

思考在NLTK中对给定句子实现POS标注的示例。

>>> import nltk
>>> text1=nltk.word_tokenize("It is a pleasant day today")
>>> nltk.pos_tag(text1)
[('It', 'PRP'), ('is', 'VBZ'), ('a', 'DT'), ('pleasant', 'JJ'),
('day', 'NN'), ('today', 'NN')]

在TaggerI的所有子类中,可以实现tag()方法。为了评估标注器,TaggerI提供了evaluate()方法。可以使用标注器的组合,形成回退链,这样如果前一个标注器未进行标注,可以使用下一标注器进行标注。

下面是由宾州树库提供的可用标签的列表参见upenn网站。

CC - 并列连词 CD -基数 DT - 限定词 EX - 存在的there FW - 外来词 IN - 介词或从属连词 JJ - 形容词 JJR - 形容词,比较级 JJS - 形容词,最高级 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Java持续交付

Java持续交付

Daniel Bryant, Abraham Marín-Pérez
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普
软件开发实践:项目驱动式的Java开发指南

软件开发实践:项目驱动式的Java开发指南

Raoul-Gabriel Urma, Richard Warburton
Spark机器学习实战

Spark机器学习实战

Posts & Telecom Press, Siamak Amirghodsi, Meenakshi Rajendran, Broderick Hall, Shuen Mei

Publisher Resources

ISBN: 9781835083451