{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from datasets import load_dataset\n", "\n", "dataset = load_dataset(\"divyasharma0795/AppleVisionPro_Tweets\")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "HuggingFaceDataset(id=1769458624638619691, tweetText=\"Mordecai I can't sell nft for 10 dollars, how does this nft business work? #bloodbath #AppleVisionPro #DeadpoolAndWolverine #RegularShow @JGQuintel link: https://t.co/Bq3dzV4wgR https://t.co/rbrerIFcIs\", tweetURL='https://twitter.com/harndefty/status/1769458624638619691', tweetAuthor='Harndefty 🐔🍗', handle='@harndefty', replyCount=0, quoteCount=0, retweetCount=0, likeCount=0, views='26', bookmarkCount=0, createdAt='2024-03-17 13:19:45')\n" ] } ], "source": [ "from dataclasses import dataclass\n", "from typing import List\n", "from datasets import load_dataset\n", "\n", "\n", "@dataclass\n", "class HuggingFaceDataset:\n", " id: int\n", " tweetText: str\n", " tweetURL: str\n", " tweetAuthor: str\n", " handle: str\n", " replyCount: int\n", " quoteCount: int\n", " retweetCount: int\n", " likeCount: int\n", " views: int\n", " bookmarkCount: int\n", " createdAt: str\n", "\n", "\n", "def load_custom_dataset(dataset_name):\n", " dataset = load_dataset(dataset_name)\n", "\n", " # Extract relevant information and create a list of HuggingFaceDataset instances\n", " custom_dataset = [\n", " HuggingFaceDataset(\n", " id=row[\"id\"],\n", " tweetText=row[\"tweetText\"],\n", " tweetURL=row[\"tweetURL\"],\n", " tweetAuthor=row[\"tweetAuthor\"],\n", " handle=row[\"handle\"],\n", " replyCount=row[\"replyCount\"],\n", " quoteCount=row[\"quoteCount\"],\n", " retweetCount=row[\"retweetCount\"],\n", " likeCount=row[\"likeCount\"],\n", " views=row[\"views\"],\n", " bookmarkCount=row[\"bookmarkCount\"],\n", " createdAt=row[\"createdAt\"],\n", " )\n", " for row in dataset[\"train\"]\n", " ]\n", "\n", " return custom_dataset\n", "\n", "\n", "# Usage\n", "custom_dataset = load_custom_dataset(\"divyasharma0795/AppleVisionPro_Tweets\")\n", "print(custom_dataset[0]) # Print the first instance" ] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.5" } }, "nbformat": 4, "nbformat_minor": 2 }