小编use*_*742的帖子

如何制作NLTK pos_tag字样而不是字符?

我有这个代码在一个句子中找到名词和动词.

 # -*- coding: utf-8 -*-
from nltk.corpus import wordnet as wn
from nltk import pos_tag
import nltk
syno =[]


sentence = '''His father suggested he study to become a parson instead, but Darwin was far more inclined to study natural history.DarwinDar·win (där'w?n),Charles Robert.1809-1882.British naturalist who revolutionized the study of biology with his theory ofevolutionbased on natural selection
Like several scientists before him, Darwin believed all the life on earth evolved (developed gradually) over millions of years from a few …
Run Code Online (Sandbox Code Playgroud)

python nltk

3
推荐指数
1
解决办法
7400
查看次数

从 NTLK pos_tag 中仅删除“NN”单词

我有一个使用 NLTK 查找名词和动词的代码。

from nltk.corpus import wordnet as wn
from nltk import pos_tag
import nltk


sentence = "Hello my name is Abhishek Mitra"
sentence = nltk.word_tokenize(sentence)
sent = pos_tag(sentence)
print sent
Run Code Online (Sandbox Code Playgroud)

它返回:

[('Hello', 'NNP'), ('my', 'PRP$'), ('name', 'NN'), ('is', 'VBZ'), ('Abhishek', 'NNP'), ('Mitra', 'NNP')]
Run Code Online (Sandbox Code Playgroud)

我怎样才能从列表中只删除“NN”单词。

python nltk

2
推荐指数
1
解决办法
6433
查看次数

功能不返回值.错误"NameError:name'urlss'未定义"

这是我的计划的一部分.它给出了错误NameError: name 'urlss' is not defined

def testfunc():
  urlss = "hey"
  return urlss

print urlss
Run Code Online (Sandbox Code Playgroud)

为什么会这样?

python

1
推荐指数
1
解决办法
1210
查看次数

如何防止"在变量中关闭"

我有一个变量

sentence = "In 1794, shortly after his arrival in Manchester, Dalton was elected a member of the Manchester Literary and Philosophical Society, the "Lit & Phil", and a few weeks later he communicated his first paper on "Extraordinary facts relating to the vision of colours", in which he postulated that shortage in colour perception was caused by discoloration of the liquid medium of the eyeball. In fact, a shortage of colour perception in some people had not even been …
Run Code Online (Sandbox Code Playgroud)

python string

1
推荐指数
1
解决办法
75
查看次数

标签 统计

python ×4

nltk ×2

string ×1