使用nltk.pos出现IndexError: string index out of range
2018-02-12 15:02
786 查看
问题重现:# -*- encoding:utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import nltk
from nltk.corpus import stopwords
text="I've got a very big apple "
text=text.split(" ")
# text.remove('')
text = list(set(text))
print text
text_list=nltk.pos_tag(text)
print text_list
for item in text_list:
if item[1]=='JJ':#如果该英文单词是形容词
print"item[0]=",item[0]
解决方案如下:# -*- encoding:utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import nltk
from nltk.corpus import stopwords
text="I've got a very big apple "
text=text.split(" ")
text.remove('')
text = list(set(text))
print text
text_list=nltk.pos_tag(text)
print text_list
for item in text_list:
if item[1]=='JJ':#如果该英文单词是形容词
print"item[0]=",item[0]
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import nltk
from nltk.corpus import stopwords
text="I've got a very big apple "
text=text.split(" ")
# text.remove('')
text = list(set(text))
print text
text_list=nltk.pos_tag(text)
print text_list
for item in text_list:
if item[1]=='JJ':#如果该英文单词是形容词
print"item[0]=",item[0]
解决方案如下:# -*- encoding:utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import nltk
from nltk.corpus import stopwords
text="I've got a very big apple "
text=text.split(" ")
text.remove('')
text = list(set(text))
print text
text_list=nltk.pos_tag(text)
print text_list
for item in text_list:
if item[1]=='JJ':#如果该英文单词是形容词
print"item[0]=",item[0]
相关文章推荐
- Android Studio 2.0+发布APK出现ExternalSystemException: String index out of range: -123错误
- MySQL使用like出现 操作MySQL数据库报出:Parameter index out of range (1 > number of parameters
- .NET中使用GridView控件输入数据时出现“ Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"的问题
- Hibernate query.list()查询发生java.lang.StringIndexOutOfBoundsException: String index out of range: 0错误
- 生成web service client时Error generating services (String index out of range: 3)
- BIRT出现java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0)的问题
- eclipse Java文件打开异常解决方法 :java.lang.StringIndexOutOfBoundsException: String index out of range: 26
- 使用vector出现的错误 subscript out of range
- ViewPager中的图片多点触摸出现java.lang.IllegalArgumentException: pointerIndex out of range解决方案
- 【解决问题.思路篇】StringIndexOutOfBoundsException:String index out of range: -1
- mvn install:java.lang.StringIndexOutOfBoundsException: String index out of range: -1问题的解决
- java.lang.StringIndexOutOfBoundsException: String index out of range: 0错误的原因 3ff0
- DataGridView绑定Ilist对象,出现IndexOutOfRangeException错误的解决方法
- IndexError: list index out of range的错误原因
- DataGridView绑定Ilist对象,出现IndexOutOfRangeException错误的解决方法
- String index out of range: -1
- python PIL, 错误:IndexError: string index out of range
- C# B/S程序中使用DropDownList出现System.ArgumentOutOfRangeException: “DropDownList1”有一个无效 SelectedValue,因为它不在项目列表中的解决方法
- 使用容器出现vector subscript out of range等类似错误
- selenium cant start a new browser(ie7):java.lang.StringIndexOutOfBoundsException: String index out of range: -1