词性标注

Python 中的 NLP 特征工程

Rounak Banik

Data Scientist

应用

  • 词义消歧
    • "The bear is a majestic animal"
    • "Please bear with me"
  • 情感分析
  • 问答系统
  • 虚假新闻与水军检测
Python 中的 NLP 特征工程

词性标注(POS)

  • 为每个词分配对应的词性。
    "Jane is an amazing guitarist."
    
  • 词性标注(POS Tagging):
    • Jane专有名词
    • is动词
    • an限定词
    • amazing形容词
    • guitarist名词
Python 中的 NLP 特征工程

使用 spaCy 进行词性标注

import spacy

# Load the en_core_web_sm model
nlp = spacy.load('en_core_web_sm')
# Initiliaze string
string = "Jane is an amazing guitarist"
# Create a Doc object
doc = nlp(string)
Python 中的 NLP 特征工程

使用 spaCy 进行词性标注

...
...
# Generate list of tokens and pos tags
pos = [(token.text, token.pos_) for token in doc]
print(pos)
[('Jane', 'PROPN'), 
 ('is', 'VERB'), 
 ('an', 'DET'), 
 ('amazing', 'ADJ'), 
 ('guitarist', 'NOUN')]
Python 中的 NLP 特征工程

spaCy 的词性标注

spaCy 关于词性标注的文档

Python 中的 NLP 特征工程

开始练习!

Python 中的 NLP 特征工程

Preparing Video For Download...