用于去除网络术语/俚语/缩略语的python模块
有没有什么Python模块(可能是在nltk这个库里)可以用来去掉网络用语或者聊天用语,比如“lol”、“brb”等等?如果没有的话,有人能提供一个包含这些网络用语的大列表的CSV文件吗?
这个网站 http://www.netlingo.com/acronyms.php 提供了一些缩写的列表,但我找不到可以在我的程序中使用的CSV文件。
2 个回答
4
这段代码是用来抓取网站 http://www.netlingo.com/acronyms.php 上的信息的。
from bs4 import BeautifulSoup
import requests, json
resp = requests.get("http://www.netlingo.com/acronyms.php")
soup = BeautifulSoup(resp.text, "html.parser")
slangdict= {}
key=""
value=""
for div in soup.findAll('div', attrs={'class':'list_box3'}):
for li in div.findAll('li'):
for a in li.findAll('a'):
key =a.text
value = li.text.split(key)[1]
slangdict[key]=value
with open('myslang.json', 'w') as f:
json.dump(slangdict, f, indent=2)
2
凯文的词汇列表页面:可以查看俚语词汇列表和字典的链接。