介绍

你对互联网上的大量文本数据着迷吗?你是否正在寻找处理这些文本数据的方法,但不确定从哪里开始?毕竟,机器识别的是数字,而不是我们语言中的字母。在机器学习中,这可能是一个棘手的问题。

那么,我们如何操作和处理这些文本数据来构建模型呢?答案就在自然语言处理(NLP)的奇妙世界中。

解决一个NLP问题是一个多阶段的过程。在进入建模阶段之前,我们需要首先处理非结构化文本数据。处理数据包括以下几个关键步骤:

在本文中,我们将讨论第一步—标识化。我们将首先了解什么是标识化,以及为什么在NLP中需要标识化。然后,我们将研究在Python中进行标识化的六种独特方法。

阅读本文不需要什么先决条件,任何对NLP或数据科学感兴趣的人都可以跟读。

在NLP中,什么是标识化?

标识化是处理文本数据时最常见的任务之一。但是标识化(tokenization)具体是什么意思呢?

标识化(tokenization)本质上是将短语、句子、段落或整个文本文档分割成更小的单元,例如单个单词或术语。每个较小的单元都称为标识符(token)

看看下面这张图片,你就能理解这个定义了:

标识符可以是单词、数字或标点符号。在标识化中,通过定位单词边界创建更小的单元。等等,可能你又有疑问,什么是单词边界呢?

单词边界是一个单词的结束点和下一个单词的开始。而这些标识符被认为是词干提取(stemming)和词形还原(lemmatization )的第一步。

为什么在NLP中需要标识化?

在这里,我想让你们思考一下英语这门语言。想一句任何你能想到的一个英语句子,然后在你接下去读这部分的时候,把它记在心里。这将帮助你更容易地理解标识化的重要性。

在处理一种自然语言之前,我们需要识别组成字符串的单词,这就是为什么标识化是处理NLP(文本数据)的最基本步骤。这一点很重要,因为通过分析文本中的单词可以很容易地解释文本的含义。

让我们举个例子,以下面的字符串为例:

“This is a cat.”

你认为我们对这个字符串进行标识化之后会发生什么?是的,我们将得到[' This ', ' is ', ' a ', cat ']。

这样做有很多用途,我们可以使用这个标识符形式:

之外,还有其他用途。我们可以提取更多的信息,这些信息将在以后的文章中详细讨论。现在,是我们深入研究本文的主要内容的时候了——在NLP中进行标识化的不同方法。

在Python中执行标识化的方法

我们将介绍对英文文本数据进行标识化的六种独特方法。我已经为每个方法提供了Python代码,所以你可以在自己的机器上运行示例用来学习。

1.使用python的split()函数进行标识化

让我们从split()方法开始,因为它是最基本的方法。它通过指定的分隔符分割给定的字符串后返回字符串列表。默认情况下,split()是以一个或多个空格作为分隔符。我们可以把分隔符换成任何东西。让我们来看看。

单词标识化

text = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed liquid-fuel launch vehicle to orbit the Earth."""# 以空格为分隔符进行分割text.split() 
# 以空格为分隔符进行分割
text.split() 
Output : ['Founded', 'in', '2002,', 'SpaceX’s', 'mission', 'is', 'to', 'enable', 'humans',           'to', 'become', 'a', 'spacefaring', 'civilization', 'and', 'a', 'multi-planet',           'species', 'by', 'building', 'a', 'self-sustaining', 'city', 'on', 'Mars.', 'In',           '2008,', 'SpaceX’s', 'Falcon', '1', 'became', 'the', 'first', 'privately',           'developed', 'liquid-fuel', 'launch', 'vehicle', 'to', 'orbit', 'the', 'Earth.']'in', '2002,', 'SpaceX’s', 'mission', 'is', 'to', 'enable', 'humans', 
          'to', 'become', 'a', 'spacefaring', 'civilization', 'and', 'a', 'multi-planet', 
          'species', 'by', 'building', 'a', 'self-sustaining', 'city', 'on', 'Mars.', 'In', 
          '2008,', 'SpaceX’s', 'Falcon', '1', 'became', 'the', 'first', 'privately', 
          'developed', 'liquid-fuel', 'launch', 'vehicle', 'to', 'orbit', 'the', 'Earth.']

句子标识化:

这类似于单词标识化。这里,我们在分析中研究句子的结构。一个句子通常以句号(.)结尾,所以我们可以用"."作为分隔符来分割字符串:

text = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed liquid-fuel launch vehicle to orbit the Earth."""# 以"."作为分割符进行分割 text.split('. ') 
# 以"."作为分割符进行分割 
text.split('. ') 
Output : ['Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring            civilization and a multi-planet \nspecies by building a self-sustaining city on            Mars',           'In 2008, SpaceX’s Falcon 1 became the first privately developed \nliquid-fuel            launch vehicle to orbit the Earth.']
          'In 2008, SpaceX’s Falcon 1 became the first privately developed \nliquid-fuel 
           launch vehicle to orbit the Earth.']

使用Python的split()方法的一个主要缺点是一次只能使用一个分隔符。另一件需要注意的事情是——在单词标识化中,split()没有将标点符号视为单独的标识符。

2.使用正则表达式(RegEx)进行标识化

让我们理解正则表达式是什么,它基本上是一个特殊的字符序列,使用该序列作为模式帮助你匹配或查找其他字符串或字符串集。

我们可以使用Python中的re库来处理正则表达式。这个库预安装在Python安装包中。

现在,让我们记住正则表达式并执行单词标识化和句子标识化。

单词标识化

import retext = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed liquid-fuel launch vehicle to orbit the Earth."""tokens = re.findall("[\w']+", text)tokens
text = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet 
species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed 
liquid-fuel launch vehicle to orbit the Earth."""
tokens = re.findall("[\w']+", text)
tokens
Output : ['Founded', 'in', '2002', 'SpaceX', 's', 'mission', 'is', 'to', 'enable',           'humans', 'to', 'become', 'a', 'spacefaring', 'civilization', 'and', 'a',           'multi', 'planet', 'species', 'by', 'building', 'a', 'self', 'sustaining',           'city', 'on', 'Mars', 'In', '2008', 'SpaceX', 's', 'Falcon', '1', 'became',           'the', 'first', 'privately', 'developed', 'liquid', 'fuel', 'launch', 'vehicle',           'to', 'orbit', 'the', 'Earth']'in', '2002', 'SpaceX', 's', 'mission', 'is', 'to', 'enable', 
          'humans', 'to', 'become', 'a', 'spacefaring', 'civilization', 'and', 'a', 
          'multi', 'planet', 'species', 'by', 'building', 'a', 'self', 'sustaining', 
          'city', 'on', 'Mars', 'In', '2008', 'SpaceX', 's', 'Falcon', '1', 'became', 
          'the', 'first', 'privately', 'developed', 'liquid', 'fuel', 'launch', 'vehicle', 
          'to', 'orbit', 'the', 'Earth']

re.findall()函数的作用是查找与传递给它的模式匹配的所有单词,并将其存储在列表中。\w表示“任何字符”,通常表示字母数字和下划线(_)。+表示任意出现次数。因此[\w']+表示代码应该找到所有的字母数字字符,直到遇到任何其他字符为止。

句子标识化

要执行句子标识化,可以使用re.split()函数,将通过传递一个模式给函数将文本分成句子。

import retext = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet species by building a self-sustaining city on, Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed liquid-fuel launch vehicle to orbit the Earth."""sentences = re.compile('[.!?] ').split(text)sentences
text = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet 
species by building a self-sustaining city on, Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed 
liquid-fuel launch vehicle to orbit the Earth."""
sentences = re.compile('[.!?] ').split(text)
sentences
Output : ['Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring            civilization and a multi-planet \nspecies by building a self-sustaining city on            Mars.',           'In 2008, SpaceX’s Falcon 1 became the first privately developed \nliquid-fuel            launch vehicle to orbit the Earth.']
          'In 2008, SpaceX’s Falcon 1 became the first privately developed \nliquid-fuel 
           launch vehicle to orbit the Earth.']

这里,我们相比split()方法上有一个优势,因为我们可以同时传递多个分隔符。在上面的代码中,我们使用了的re.compile()函数,并传递一个模式[.?!]。这意味着一旦遇到这些字符,句子就会被分割开来。

有兴趣阅读更多关于正则表达式的信息吗?下面的参考资料将帮助你开始学习NLP中的正则表达式:

  • https://www.analyticsvidhya.com/blog/2015/06/regular-expression-python/

  • https://www.analyticsvidhya.com/blog/2017/03/extracting-information-from-reports-using-regular-expressons-library-in-python/

3.使用NLTK进行标识化

NLTK是Natural Language ToolKit的缩写,是用Python编写的用于符号和统计自然语言处理的库。

你可以使用以下命令安装NLTK:

pip install --user -U nltk

NLTK包含一个名为tokenize()的模块,它可以进一步划分为两个子类别:

让我们一个一个来看是怎么操作的。

单词标识化

from nltk.tokenize import word_tokenize text = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed liquid-fuel launch vehicle to orbit the Earth."""word_tokenize(text)import word_tokenize 
text = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet 
species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed 
liquid-fuel launch vehicle to orbit the Earth."""
word_tokenize(text)
Output: ['Founded', 'in', '2002', ',', 'SpaceX', '’', 's', 'mission', 'is', 'to', 'enable',          'humans', 'to', 'become', 'a', 'spacefaring', 'civilization', 'and', 'a',          'multi-planet', 'species', 'by', 'building', 'a', 'self-sustaining', 'city', 'on',          'Mars', '.', 'In', '2008', ',', 'SpaceX', '’', 's', 'Falcon', '1', 'became',          'the', 'first', 'privately', 'developed', 'liquid-fuel', 'launch', 'vehicle',          'to', 'orbit', 'the', 'Earth', '.']'in', '2002', ',', 'SpaceX', '’', 's', 'mission', 'is', 'to', 'enable', 
         'humans', 'to', 'become', 'a', 'spacefaring', 'civilization', 'and', 'a', 
         'multi-planet', 'species', 'by', 'building', 'a', 'self-sustaining', 'city', 'on', 
         'Mars', '.', 'In', '2008', ',', 'SpaceX', '’', 's', 'Falcon', '1', 'became', 
         'the', 'first', 'privately', 'developed', 'liquid-fuel', 'launch', 'vehicle', 
         'to', 'orbit', 'the', 'Earth', '.']

注意到NLTK是如何考虑将标点符号作为标识符的吗?因此,对于之后的任务,我们需要从初始列表中删除这些标点符号。

句子标识化

from nltk.tokenize import sent_tokenizetext = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed liquid-fuel launch vehicle to orbit the Earth."""sent_tokenize(text)import sent_tokenize
text = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet 
species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed 
liquid-fuel launch vehicle to orbit the Earth."""
sent_tokenize(text)
Output: ['Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring           civilization and a multi-planet \nspecies by building a self-sustaining city on           Mars.',          'In 2008, SpaceX’s Falcon 1 became the first privately developed \nliquid-fuel           launch vehicle to orbit the Earth.']
         'In 2008, SpaceX’s Falcon 1 became the first privately developed \nliquid-fuel 
          launch vehicle to orbit the Earth.']

4.使用`spaCy`库进行标识化

我喜欢spaCy这个库,我甚至不记得上次我在做NLP项目时没有使用它是什么时候了。是的,它就是那么有用。

spaCy是一个用于高级自然语言处理(NLP)的开源库。它支持超过49种语言,并具有最快的的计算速度。

在Linux上安装Spacy的命令:

pip install -U spacy

python -m spacy download en

要在其他操作系统上安装它,可以通过下面链接查看:

https://spacy.io/usage

所以,让我们看看如何利用spaCy的神奇之处来进行标识化。我们将使用spacy.lang.en以支持英文。

单词标识化

from spacy.lang.en import English# 加载英文分词器,标记器、解析器、命名实体识别和词向量nlp = English()text = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed liquid-fuel launch vehicle to orbit the Earth."""#"nlp" 对象用于创建具有语言注解的文档my_doc = nlp(text)# 创建单词标识符列表token_list = []for token in my_doc:    token_list.append(token.text)token_listimport English

# 加载英文分词器,标记器、解析器、命名实体识别和词向量
nlp = English() text = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet 
species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed 
liquid-fuel launch vehicle to orbit the Earth.""" #"nlp" 对象用于创建具有语言注解的文档
my_doc = nlp(text) # 创建单词标识符列表
token_list = []
for token in my_doc:
    token_list.append(token.text)
token_list
Output : ['Founded', 'in', '2002', ',', 'SpaceX', '’s', 'mission', 'is', 'to', 'enable',           'humans', 'to', 'become', 'a', 'spacefaring', 'civilization', 'and', 'a',           'multi', '-', 'planet', '\n', 'species', 'by', 'building', 'a', 'self', '-',           'sustaining', 'city', 'on', 'Mars', '.', 'In', '2008', ',', 'SpaceX', '’s',           'Falcon', '1', 'became', 'the', 'first', 'privately', 'developed', '\n',           'liquid', '-', 'fuel', 'launch', 'vehicle', 'to', 'orbit', 'the', 'Earth', '.']'in', '2002', ',', 'SpaceX', '’s', 'mission', 'is', 'to', 'enable', 
          'humans', 'to', 'become', 'a', 'spacefaring', 'civilization', 'and', 'a', 
          'multi', '-', 'planet', '\n', 'species', 'by', 'building', 'a', 'self', '-', 
          'sustaining', 'city', 'on', 'Mars', '.', 'In', '2008', ',', 'SpaceX', '’s', 
          'Falcon', '1', 'became', 'the', 'first', 'privately', 'developed', '\n', 
          'liquid', '-', 'fuel', 'launch', 'vehicle', 'to', 'orbit', 'the', 'Earth', '.']

句子标识化

from spacy.lang.en import English# 加载英文分词器,标记器、解析器、命名实体识别和词向量nlp = English()# 创建管道 'sentencizer' 组件sbd = nlp.create_pipe('sentencizer')# 将组建添加到管道中nlp.add_pipe(sbd)text = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed liquid-fuel launch vehicle to orbit the Earth."""#  "nlp" 对象用于创建具有语言注解的文档doc = nlp(text)# 创建句子标识符列表sents_list = []for sent in doc.sents:    sents_list.append(sent.text)sents_listimport English

# 加载英文分词器,标记器、解析器、命名实体识别和词向量
nlp = English() # 创建管道 'sentencizer' 组件
sbd = nlp.create_pipe('sentencizer') # 将组建添加到管道中
nlp.add_pipe(sbd) text = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet 
species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed 
liquid-fuel launch vehicle to orbit the Earth.""" #  "nlp" 对象用于创建具有语言注解的文档
doc = nlp(text) # 创建句子标识符列表
sents_list = []
for sent in doc.sents:
    sents_list.append(sent.text)
sents_list
Output : ['Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring            civilization and a multi-planet \nspecies by building a self-sustaining city on            Mars.',           'In 2008, SpaceX’s Falcon 1 became the first privately developed \nliquid-fuel            launch vehicle to orbit the Earth.']
          'In 2008, SpaceX’s Falcon 1 became the first privately developed \nliquid-fuel 
           launch vehicle to orbit the Earth.']

在执行NLP任务时,与其他库相比,spaCy的速度相当快(是的,甚至相较于NLTK)。我鼓励你收听下面的DataHack Radio播客,以了解spaCy是如何创建的,以及你可以在哪里使用它:

https://www.analyticsvidhya.com/blog/2019/06/datahack-radio-ines-montani-matthew-honnibal-brains-behind-spacy/?utm_source=blog&utm_medium=how-get-started-nlp-6-unique-ways-perform-tokenization

之外,下面是关于spaCy的一个更深入的教程:

https://www.analyticsvidhya.com/blog/2017/04/natural-language-processing-made-easy-using-spacy-%E2%80%8Bin-python/?utm_source=blog&utm_medium=how-get-started-nlp-6-unique-ways-perform-tokenization

5.使用Keras进行标识化

Keras!!目前业界最热门的深度学习框架之一。它是Python的一个开源神经网络库。Keras非常容易使用,也可以运行在TensorFlow之上。

在NLP上下文中,我们可以使用Keras处理我们通常收集到的非结构化文本数据。

在你的机子上,只需要一行代码就可以在机器上安装Keras:

pip install Keras

让我们开始进行实验,要使用Keras执行单词标记化,我们使用keras.preprocessing.text类中的text_to_word_sequence方法.

让我们看看keras是怎么做的。

单词标识化

from keras.preprocessing.text import text_to_word_sequence# 文本数据text = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed liquid-fuel launch vehicle to orbit the Earth."""# 标识化result = text_to_word_sequence(text)resultimport text_to_word_sequence
# 文本数据
text = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet 
species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed 
liquid-fuel launch vehicle to orbit the Earth."""
# 标识化
result = text_to_word_sequence(text)
result
Output : ['founded', 'in', '2002', 'spacex’s', 'mission', 'is', 'to', 'enable', 'humans',           'to', 'become', 'a', 'spacefaring', 'civilization', 'and', 'a', 'multi',           'planet', 'species', 'by', 'building', 'a', 'self', 'sustaining', 'city', 'on',           'mars', 'in', '2008', 'spacex’s', 'falcon', '1', 'became', 'the', 'first',           'privately', 'developed', 'liquid', 'fuel', 'launch', 'vehicle', 'to', 'orbit',           'the', 'earth']'in', '2002', 'spacex’s', 'mission', 'is', 'to', 'enable', 'humans', 
          'to', 'become', 'a', 'spacefaring', 'civilization', 'and', 'a', 'multi', 
          'planet', 'species', 'by', 'building', 'a', 'self', 'sustaining', 'city', 'on', 
          'mars', 'in', '2008', 'spacex’s', 'falcon', '1', 'became', 'the', 'first', 
          'privately', 'developed', 'liquid', 'fuel', 'launch', 'vehicle', 'to', 'orbit', 
          'the', 'earth']

Keras在进行标记之前将所有字母转换成小写。你可以想象,这为我们节省了很多时间!

6.使用Gensim进行标识化

我们介绍的最后一个标识化方法是使用Gensim库。它是一个用于无监督主题建模和自然语言处理的开源库,旨在从给定文档中自动提取语义主题。

下面我们在机器上安装Gensim:

pip install gensim

我们可以用gensim.utils类导入用于执行单词标识化的tokenize方法。

单词标识化

from gensim.utils import tokenizetext = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed liquid-fuel launch vehicle to orbit the Earth."""list(tokenize(text))import tokenize
text = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet 
species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed 
liquid-fuel launch vehicle to orbit the Earth."""
list(tokenize(text))
Outpur : ['Founded', 'in', 'SpaceX', 's', 'mission', 'is', 'to', 'enable', 'humans', 'to',           'become', 'a', 'spacefaring', 'civilization', 'and', 'a', 'multi', 'planet',           'species', 'by', 'building', 'a', 'self', 'sustaining', 'city', 'on', 'Mars',           'In', 'SpaceX', 's', 'Falcon', 'became', 'the', 'first', 'privately',           'developed', 'liquid', 'fuel', 'launch', 'vehicle', 'to', 'orbit', 'the',           'Earth']'in', 'SpaceX', 's', 'mission', 'is', 'to', 'enable', 'humans', 'to', 
          'become', 'a', 'spacefaring', 'civilization', 'and', 'a', 'multi', 'planet', 
          'species', 'by', 'building', 'a', 'self', 'sustaining', 'city', 'on', 'Mars', 
          'In', 'SpaceX', 's', 'Falcon', 'became', 'the', 'first', 'privately', 
          'developed', 'liquid', 'fuel', 'launch', 'vehicle', 'to', 'orbit', 'the', 
          'Earth']

句子标识化

from gensim.summarization.textcleaner import split_sentencestext = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed liquid-fuel launch vehicle to orbit the Earth."""result = split_sentences(text)resultimport split_sentences
text = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet 
species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed 
liquid-fuel launch vehicle to orbit the Earth."""
result = split_sentences(text)
result
Output : ['Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring            civilization and a multi-planet ',           'species by building a self-sustaining city on Mars.',           'In 2008, SpaceX’s Falcon 1 became the first privately developed ',           'liquid-fuel launch vehicle to orbit the Earth.']
          'species by building a self-sustaining city on Mars.', 
          'In 2008, SpaceX’s Falcon 1 became the first privately developed ', 
          'liquid-fuel launch vehicle to orbit the Earth.']

你可能已经注意到,Gensim对标点符号非常严格。每当遇到标点符号时,它就会分割。在句子分割中,Gensim在遇到\n时会分割文本,而其他库则是忽略它。

总结

标识化是整个处理NLP任务中的一个关键步骤。如果不先处理文本,我们就不能简单地进入模型构建部分。

在本文中,对于给定的英文文本,我们使用了六种不同的标识化方法(单词和句子)。当然,还有其他的方法,但是这些方法已经足够让你开始进行标识化了。

[1]: 有部分中文将其翻译为分词,但中文文本和英文文本在分词上有所差别,且在本文中,不只演示将英文文本段落分割成单词,还演示将其分割成句子,所以在本文中将其翻译为标识化而不是分词。

欢迎关注磐创博客资源汇总站:

http://docs.panchuang.net/

欢迎关注PyTorch官方中文教程站:

http://pytorch.panchuang.net/

NLPer入门指南 | 完美第一步的更多相关文章

  1. 【OpenCV入门指南】第一篇 安装OpenCV

    http://blog.csdn.net/morewindows/article/details/8225783/ win10下vs2015配置Opencv3.1.0过程详解(转) http://ww ...

  2. OKR新手入门指南 (第一部分)

    什么是OKR? OKR(目标和关键结果)是Google和其他公司使用的目标系统.这是一个简单的工具,围绕可衡量的目标进行调整和互动. OKR:Google的目标设定方法 与传统的规划方法有何不同? O ...

  3. github入门教程:第一步

    [git教程] 以前在网上找过一些,见 http://www.wojilu.com/Forum1/Topic/702  我自己会一边学,一边写教程,过程中有不明白的,会跟大家请教交流.   ----- ...

  4. opencv入门指南(转载)

    转载链接:http://blog.csdn.net/morewindows/article/details/8426318 网上的总结的一些用openncv的库来做的事: 下面列出OpenCV入门指南 ...

  5. Kaggle初学者五步入门指南,七大诀窍助你享受竞赛

    Kaggle 是一个流行的数据科学竞赛平台,已被谷歌收购,参阅<业界 | 谷歌云官方正式宣布收购数据科学社区 Kaggle>.作为一个竞赛平台,Kaggle 对于初学者来说可能有些难度.毕 ...

  6. [EntLib]微软企业库5.0 学习之路——第一步、基本入门

    话说在大学的时候帮老师做项目的时候就已经接触过企业库了但是当初一直没明白为什么要用这个,只觉得好麻烦啊,竟然有那么多的乱七八糟的配置(原来我不知道有配置工具可以进行配置,请原谅我的小白). 直到去年在 ...

  7. (大数据工程师学习路径)第一步 Linux 基础入门----文件系统操作与磁盘管理

    介绍 本节的文件系统操作的内容十分简单,只会包含几个命令的几个参数的讲解,但掌握这些也将对你在学习后续其他内容的过程中有极大帮助. 因为本课程的定位为入门基础,尽快上手,故没有打算涉及太多理论内容,前 ...

  8. Django入门第一步:构建一个简单的Django项目

    Django入门第一步:构建一个简单的Django项目 1.简介 Django是一个功能完备的Python Web框架,可用于构建复杂的Web应用程序.在本文中,将通过示例跳入并学习Django.您将 ...

  9. Newbe.Claptrap 框架入门,第一步 —— 开发环境准备

    Newbe.Claptrap 框架依托于一些关键性的基础组件和一些可选的辅助组件.本篇我们来介绍一下如何准备一个开发环境. Newbe.Claptrap 是一个用于轻松应对并发问题的分布式开发框架.如 ...

随机推荐

  1. 运输层协议TCP和UDP

    运输层协议TCP和UDP 一.用户数据报协议 UDP 1.1.UDP 概述 UDP 只在 IP 的数据报服务之上增加了很少一点的功能,即端口的功能和差错检测的功能. 虽然 UDP 用户数据报只能提供不 ...

  2. 最近做的一个Spring Boot小项目,欢迎大家访问 http://39.97.115.152/

    最近做的一个Spring Boot小项目,欢迎大家访问 http://39.97.115.152/,帮忙找找bug,网站里有源码地址 网站说明 甲壳虫社区(Beetle Community) 一个开源 ...

  3. jq拖拽插件

    (function ($) { var move = false; //标记控件是否处于被拖动状态 var dragOffsetX = 0; //控件左边界和鼠标X轴的差 var dragOffset ...

  4. 随手撸一个简单的带检查的printf

    #include <stdio.h> #include <iostream> #include <vector> #include <string> # ...

  5. 我的webpack学习笔记(二)

    前言 上一篇文章我们讲了多页面js的打包,本篇文章我们继续scss的打包. 多页面css单独打包 首先,我们css编写采用的是sass,所以我们先来安装sass-loader以及可以用到的依赖 $ n ...

  6. 为XHR对象所有方法和属性提供钩子 全局拦截AJAX

    摘要 ✨长文 阅读约需十分钟 ✨跟着走一遍需要一小时以上 ✨约100行代码 前段时间打算写一个给手机端用的假冒控制台 可以用来看console的输出 这一块功能目前已经完成了 但是后来知道有一个腾讯团 ...

  7. 前端每日实战:60# 视频演示如何用纯 CSS 创作一块乐高积木

    效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/qKKqrv 可交互视频 此视频是可 ...

  8. FCC 成都社区·技术周刊 第 14 期

    [前端] 1. React Fiber 架构 React16 启用了全新的架构,叫做 Fiber,其最大的使命是解决大型 React 项目的性能问题,再顺手解决之前的一些痛点. 详情:https:// ...

  9. 关于 InnoDB 锁的超全总结

    有点全的 InnoDB 锁 几个月之前,开始深入学习 MySQL .说起数据库,并发控制是其中很重要的一部分.于是,就这样开起了 MySQL 锁的学习,随着学习的深入,发现想要更好的理解锁,需要了解 ...

  10. 编写程序实现根据考试成绩将成绩分为A,B,C,D四档。

    score = float(input("请输入你的成绩:"))if 90 <= score <= 100: print("你的成绩为A档")eli ...