gpt4 book ai didi

python-2.7 - Python nltk.clean_html未实现

转载 作者:行者123 更新时间:2023-12-03 21:15:37 28 4
gpt4 key购买 nike

我一直在尝试使用

myNews=urlopen(url).read()    
myNews=nltk.clean_html(myNews)

我收到以下错误:

在clean_html中的文件“/usr/local/lib/python2.7/dist-packages/nltk-3.0.0-py2.7.egg/nltk/util.py”,第346行
引发NotImplementedError(“要删除HTML标记,请使用BeautifulSoup的get_text()函数”)
NotImplementedError:要删除HTML标记,请使用BeautifulSoup的get_text()函数

当我查看文件util.py时,我看到它没有实现:
def clean_html(html):
raise NotImplementedError ("To remove HTML markup, use BeautifulSoup's get_text() function")

应该不执行吗?

最佳答案

clean_html()clean_url()是NLTK中的一个可爱函数,由于BeautifulSoup可以更好地完成工作并解析标记语言,因此已删除了该函数,请参阅https://github.com/nltk/nltk/commit/39a303e5ddc4cdb1a0b00a3be426239b1c24c8bb

这是BeautifulSoup的文档:http://www.crummy.com/software/BeautifulSoup/bs4/doc/

关于python-2.7 - Python nltk.clean_html未实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26002076/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com