我刚刚开始尝试自然语言处理。我使用NLTK编写的前几行代码产生了令人困惑的结果。 import nltk
exampleArray = ['The book is hers',
'The book is his']
for item in exampleArray:
tokenized = nltk.word_tokenize(item)
tagged = nltk.pos_tag(tokenized)
print(tagged) 输出: [('The', 'DT'), (&
当使用带有NLTK的通用标记集时,它将“那里”标识为一个限定符,但它没有意义。例如,
import nltk
from nltk import word_tokenize
sentence = 'If there is a cat under the table'
tokens = word_tokenize(sentence)
tags = nltk.pos_tag(tokens, tagset='universal')
产出如下:
[('If', 'ADP'), ('there', 'DET
我试着分析一篇课文,并计算课文中的字数。但我需要每个不同形式的单词算作一个单词。例如:
document = "I your hand. I see your hands."
见=2 face =2我知道如何把这个词变成字典形式。
document = "I saw your face I see your faces"
sentences = nltk.word_tokenize(document)
lemmatizer = WordNetLemmatizer()
for key, val in freq.items():
print(lemmatiz
我有一句话是这样的: txt = "i am living in the West Bengal and my brother live in New York. My name is John Smith" 我需要的是: 使用GPE/location作为标签获取这些块,并使用“_“ 获取带有PERSON标签的块,并删除这些块。 我需要的输出: preprocessed_txt = "i am living in the West_Bengal and my brother live in New_York. My name is " 我使用的代码来自NL
我有一个字符串s=“X先生很棒,他很棒,Y先生也很棒。”
我需要从字符串中提取所有的形容词以及每个形容词的计数。例如,这个字符串有形容词“令人敬畏”,“令人惊异”,计数为2表示令人敬畏,1表示惊人。
在提取形容词时,我使用了NLTK。这是提取形容词的代码,
adjectives =[token for token, pos in nltk.pos_tag(nltk.word_tokenize(b)) if pos.startswith('JJ')]
我需要代码为字符串中的每个形容词得到一个计数器。它应该像形容词一样:计数器。
我只是在使用Python学习nltk。我正在使用POS标签。我想知道的是如何使用标签。例如,这是伪代码:
words = []
teststr = "George did well in the test."
tokens = nltk.word_tokenize(teststr)
words = nltk.pos_tag(tokens)
我想做这样的事情:
if words[i] == "proper noun":
#do something
如何检查一个单词是名词、动词还是其他词性。有没有人能帮帮我?谢谢。
我正在nltk库中学习BigramTagger类。我用nltk附带的棕色语料库来训练一个“部分句子”标签。
我注意到,如果我对这个语料库进行训练,然后在语料库的第一句中标注几个单词,它就会非常有效。
from nltk.corpus import brown
from nltk.tag import BigramTagger
from nltk import word_tokenize
# Works completely fine:
brown_train = brown.tagged_sents(categories='news')
bigram_tagger = Bi
我从python的NLTK库中搜索了定制NER语料库来培训模型,但是所有的答案都直接指向nltk 第七章,并且诚实地让我搞不懂如何用如下结构的正确的流程和数据集来训练语料库:
Eddy N B-PER
Bonte N I-PER
is V O
woordvoerder N O
van Prep O
diezelfde Pron O
Hogeschool N B-ORG
. Punc O
我有一些问题:
我发现了这么多的文章,如果你要用NLTK来训练定制的语料库,那么它也会使用StanfordNER库吗?或者我们可以用纯的NLTK库来做它?
如果要将语法模式应用于其他语言,是否应该包括它?流程如
我想使用nltk从文本中提取所有提到的国家和国籍,我使用了POS标签来提取所有GPE标记的令牌,但结果并不令人满意。
abstract="Thyroid-associated orbitopathy (TO) is an autoimmune-mediated orbital inflammation that can lead to disfigurement and blindness. Multiple genetic loci have been associated with Graves' disease, but the genetic basis for TO
我正试图在马达加斯加(我的母语)创建一个有标记的语料库。我遵循了文档、Python、文本处理、和、自然语言、处理和页面中的说明。我成功地创建了我自己的基于通用词性Tagset和一个小标记语料库的词性Tagset。这是我的密码:
import os, os.path
path = os.path.expanduser('D:/Mes documents/MY_POS_tagger/nltk_data')
if not os.path.exists(path):
os.mkdir(path)
p