Mehyaar/Conflict_Tweets
收藏Hugging Face2024-07-08 更新2024-07-22 收录
下载链接:
https://hf-mirror.com/datasets/Mehyaar/Conflict_Tweets
下载链接
链接失效反馈官方服务:
资源简介:
该数据集包含2023年10月17日至2023年12月17日期间与以色列-巴勒斯坦冲突相关的推文。数据集包括推文ID、链接、文本、日期、点赞数和评论数等信息,并根据点赞数范围进行了分类。数据集总推文数为15,478条,其中唯一推文数为14,854条。数据集可以用于情感分析、趋势分析和事件影响研究等研究目的。
This dataset contains tweets related to the Israel-Palestine conflict from October 17, 2023, to December 17, 2023. It includes information on tweet IDs, links, text, date, likes, and comments, categorized into different ranges of like counts. The dataset consists of 15,478 tweets, with 14,854 unique tweets. It can be used for various research purposes, including sentiment analysis, trend analysis, and event impact studies.
提供机构:
Mehyaar
原始信息汇总
数据集概述
数据集详情
- 日期范围: 2023年10月17日至2023年12月17日
- 总推文数: 15,478
- 唯一推文数: 14,854
数据描述
数据集包含以下列:
| 列名 | 描述 |
|---|---|
id |
推文的唯一标识符 |
link |
推文的URL链接 |
text |
推文的文本内容 |
date |
推文的发布日期和时间 |
likes |
推文收到的点赞数 |
comments |
推文收到的评论数 |
Label |
点赞数范围类别 |
Count |
点赞数范围类别中的推文数量 |
数据处理
数据处理代码示例:
python import pandas as pd import re from nltk.tokenize import word_tokenize from nltk.corpus import stopwords from nltk.stem import WordNetLemmatizer from langdetect import detect, LangDetectException
定义TweetProcessor类
class TweetProcessor: def init(self, file_path): """ 使用CSV文件路径初始化对象。 """ self.df = pd.read_csv(file_path) # 将text列转换为字符串类型 self.df[text] = self.df[text].astype(str)
def clean_tweet(self, tweet):
"""
通过移除链接、特殊字符和多余空格来清理推文。
"""
# 移除链接
tweet = re.sub(rhttpsS+, , tweet, flags=re.MULTILINE)
# 移除特殊字符和数字
tweet = re.sub(rW, , tweet)
# 用单个空格替换多个空格
tweet = re.sub(rs+, , tweet)
# 移除前导和尾随空格
tweet = tweet.strip()
return tweet
def tokenize_and_lemmatize(self, tweet):
"""
通过转换为小写、移除停用词和词形还原来分词和词形还原推文。
"""
# 分词
tokens = word_tokenize(tweet)
# 移除标点符号和数字,并转换为小写
tokens = [word.lower() for word in tokens if word.isalpha()]
# 移除停用词
stop_words = set(stopwords.words(english))
tokens = [word for word in tokens if word not in stop_words]
# 词形还原
lemmatizer = WordNetLemmatizer()
tokens = [lemmatizer.lemmatize(word) for word in tokens]
# 将分词后的词连接回单个字符串
return .join(tokens)
def process_tweets(self):
"""
对DataFrame中的推文应用清理和词形还原函数。
"""
def lang(x):
try:
return detect(x) == en
except LangDetectException:
return False
# 过滤英语推文
self.df = self.df[self.df[text].apply(lang)]
# 应用清理函数
self.df[cleaned_text] = self.df[text].apply(self.clean_tweet)
# 应用分词和词形还原函数
self.df[tokenized_and_lemmatized] = self.df[cleaned_text].apply(self.tokenize_and_lemmatize)
使用
该数据集可用于与以色列-巴勒斯坦冲突相关的各种研究目的,包括情感分析、趋势分析和事件影响研究。
联系信息
- 姓名: Mehyar Mlaweh
- 邮箱: mehyarmlaweh0@gmail.com



