Created
May 28, 2021 13:53
-
-
Save alperbayram/78dc92c45388a6a96be072224df0c0f0 to your computer and use it in GitHub Desktop.
wordcloud.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "wordcloud.ipynb", | |
"provenance": [], | |
"authorship_tag": "ABX9TyNJNRs5+8hCHrz10VwEYVls", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/alperbayram/78dc92c45388a6a96be072224df0c0f0/wordcloud.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "J21fzuszMBh_", | |
"outputId": "a985fdb1-4121-42db-93cb-cb662a322ed0" | |
}, | |
"source": [ | |
"!pip install wordcloud" | |
], | |
"execution_count": 1, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"Requirement already satisfied: wordcloud in /usr/local/lib/python3.7/dist-packages (1.5.0)\n", | |
"Requirement already satisfied: pillow in /usr/local/lib/python3.7/dist-packages (from wordcloud) (7.1.2)\n", | |
"Requirement already satisfied: numpy>=1.6.1 in /usr/local/lib/python3.7/dist-packages (from wordcloud) (1.19.5)\n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "KKvuEV7sMQgz", | |
"outputId": "f6e0962a-4e96-464f-fdfa-3785362718ec" | |
}, | |
"source": [ | |
"!pip install numpy\n", | |
"!pip install pandas\n", | |
"!pip install pillow\n", | |
"!pip install matplotlib" | |
], | |
"execution_count": 3, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (1.19.5)\n", | |
"Requirement already satisfied: pandas in /usr/local/lib/python3.7/dist-packages (1.1.5)\n", | |
"Requirement already satisfied: numpy>=1.15.4 in /usr/local/lib/python3.7/dist-packages (from pandas) (1.19.5)\n", | |
"Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.7/dist-packages (from pandas) (2018.9)\n", | |
"Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.7/dist-packages (from pandas) (2.8.1)\n", | |
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.7.3->pandas) (1.15.0)\n", | |
"Requirement already satisfied: pillow in /usr/local/lib/python3.7/dist-packages (7.1.2)\n", | |
"Requirement already satisfied: matplotlib in /usr/local/lib/python3.7/dist-packages (3.2.2)\n", | |
"Requirement already satisfied: numpy>=1.11 in /usr/local/lib/python3.7/dist-packages (from matplotlib) (1.19.5)\n", | |
"Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib) (2.8.1)\n", | |
"Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib) (2.4.7)\n", | |
"Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib) (1.3.1)\n", | |
"Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib) (0.10.0)\n", | |
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.1->matplotlib) (1.15.0)\n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "BMZqqCoHMMdW" | |
}, | |
"source": [ | |
"import pandas as pd\n", | |
"from os import path\n", | |
"from PIL import Image\n", | |
"from wordcloud import WordCloud, STOPWORDS, ImageColorGenerator\n", | |
"from google.colab import drive\n", | |
"import matplotlib.pyplot as plt" | |
], | |
"execution_count": 11, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "hQsez_epNyFw" | |
}, | |
"source": [ | |
"drive veri setini alıyoruz" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "SQcmUp-COGyA", | |
"outputId": "cf9085a8-5128-488b-ce72-53892cd6e595" | |
}, | |
"source": [ | |
"data_path = \"/resource/\"\n", | |
"\n", | |
"try:\n", | |
" drive.mount('/content/drive')\n", | |
" data_path = \"/content/drive/My Drive/resource/\"\n", | |
"\n", | |
"except:\n", | |
" print(\"You are not working in Colab at the moment :(\")" | |
], | |
"execution_count": 12, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"Mounted at /content/drive\n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "9e2L3ZWnMdt6" | |
}, | |
"source": [ | |
"df = pd.read_csv(data_path + 'TrkceTwit.csv')" | |
], | |
"execution_count": 13, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "VqhajzL7PTP1", | |
"outputId": "79082a99-12ca-4cab-8621-80d4032b0b8b" | |
}, | |
"source": [ | |
"df.info()" | |
], | |
"execution_count": 15, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"<class 'pandas.core.frame.DataFrame'>\n", | |
"RangeIndex: 4900 entries, 0 to 4899\n", | |
"Data columns (total 2 columns):\n", | |
" # Column Non-Null Count Dtype \n", | |
"--- ------ -------------- ----- \n", | |
" 0 category 4900 non-null object\n", | |
" 1 text 4900 non-null object\n", | |
"dtypes: object(2)\n", | |
"memory usage: 76.7+ KB\n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 359 | |
}, | |
"id": "Z-IUyYogPX4T", | |
"outputId": "c79fd0b7-3b0e-4f88-d921-d16e281591bb" | |
}, | |
"source": [ | |
"df.sample(10)" | |
], | |
"execution_count": 16, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>category</th>\n", | |
" <th>text</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>830</th>\n", | |
" <td>dunya</td>\n", | |
" <td>türk israil ilişkileri sınanıyor new_york tim...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3064</th>\n", | |
" <td>saglik</td>\n", | |
" <td>epilasyonda renk sıkıntı değil ama + 18 i unu...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2514</th>\n", | |
" <td>kultur</td>\n", | |
" <td>sertab_erener tim 23 11 2012 20 00 sertab_ere...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1377</th>\n", | |
" <td>dunya</td>\n", | |
" <td>israil in güneyine roket saldırısı israil ask...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1909</th>\n", | |
" <td>ekonomi</td>\n", | |
" <td>3 liradan tezgaha düştü balıkçı tezgahlarına ...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2041</th>\n", | |
" <td>ekonomi</td>\n", | |
" <td>palamudun yediği hamsi bu yıl az olacak zongu...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4280</th>\n", | |
" <td>teknoloji</td>\n", | |
" <td>google dan macbook a rakip ! chromebook_pixel...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>919</th>\n", | |
" <td>dunya</td>\n", | |
" <td>israil den esad a sert yanıt israil hükümeti ...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>958</th>\n", | |
" <td>dunya</td>\n", | |
" <td>140 araç birbirine girdi 2 ölü 80 yaralı abd ...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017</th>\n", | |
" <td>ekonomi</td>\n", | |
" <td>konut satışları düştü türkiye de yılın üçüncü...</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" category text\n", | |
"830 dunya türk israil ilişkileri sınanıyor new_york tim...\n", | |
"3064 saglik epilasyonda renk sıkıntı değil ama + 18 i unu...\n", | |
"2514 kultur sertab_erener tim 23 11 2012 20 00 sertab_ere...\n", | |
"1377 dunya israil in güneyine roket saldırısı israil ask...\n", | |
"1909 ekonomi 3 liradan tezgaha düştü balıkçı tezgahlarına ...\n", | |
"2041 ekonomi palamudun yediği hamsi bu yıl az olacak zongu...\n", | |
"4280 teknoloji google dan macbook a rakip ! chromebook_pixel...\n", | |
"919 dunya israil den esad a sert yanıt israil hükümeti ...\n", | |
"958 dunya 140 araç birbirine girdi 2 ölü 80 yaralı abd ...\n", | |
"2017 ekonomi konut satışları düştü türkiye de yılın üçüncü..." | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 16 | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment