去除URL的#符号

需要服务器配置nginx。
参考资料:
https://router.vuejs.org/zh/guide/essentials/history-mode.html#后端配置例子

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
import re import jieba import pandas as pd # 读取微博数据 df = pd.read_csv('/Users/dashan/postgraduate/研一下/4_LIU_positive_compute/期末/期末作业-文本分析/期末作业-操作.csv', encoding='gbk') # 读取停用词文件 stopwords = [] with open('/Users/dashan/postgraduate/研一下/4_LIU_positive_compute/期末/期末作业-文本分析/hit_stopwords.txt', encoding='utf-8') as f: for line in f: stopwords.append(line.strip()) # 去除 HTML 标签和表情符号 def clean_text(text): # 去除 HTML 标签 text = re.sub('<[^>]+>', '', text) # 去除表情符号 text = re.sub('\[.*?\]', '', text) return text # 去除网址和@用户 def remove_url_and_at(text): # 去除网址 text = re.sub('https?://[^\s]+', '', text) # 去除@用户 text = re.sub('@[^\s]+', '', text) return text # 分词,去除停用词和标点符号 def tokenize(text): # 分词 words = jieba.cut(text) # 去除停用词和标点符号 words = [word.strip() for word in words if word.strip() not in stopwords and re.match(r'^[\w\u4e00-\u9fa5]+$', word)] return words # 对每条微博进行处理 for i, row in df.iterrows(): text = row['text'] # 去除 HTML 标签和表情符号 text = clean_text(text) # 去除网址和@用户 text = remove_url_and_at(text) # 分词,去除停用词和标点符号 words = tokenize(text) # 将处理后的文本保存到新列中 df.at[i, 'processed_text'] = ' '.join(words) # 将处理后的数据保存到新的 csv 文件中 df.to_csv('weibo_processed.csv', index=False, encoding='gbk')
06-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值