# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/fonslucens/test_deeplearning/blob/master/wordcloud.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + id="wOI1GjeTBa4E"
import pandas as pd

# + colab={"base_uri": "https://localhost:8080/", "height": 1000} id="AXlrIbycBpk9" outputId="45f3a04f-057e-42d4-95c9-eb633398c9c6"
df = pd.read_csv('smtph_total.csv')
df.head(5)

# + colab={"base_uri": "https://localhost:8080/"} id="tlD7aYlIB4ia" outputId="02945c23-4b9c-4894-be5c-cadf60751133"
df.columns

# + colab={"base_uri": "https://localhost:8080/"} id="YlU0OZaxCNCy" outputId="fda89198-6b2e-44d0-9e61-416bee427fc1"
posts = df['Title'] + ['Description']
type(posts)

# + colab={"base_uri": "https://localhost:8080/"} id="kYzya3OeCegh" outputId="6a04bcbb-40bf-444c-9b34-ec9cb7860<PASSWORD>"
# !python3 -m pip install konlpy

# + id="VLhzvEYfCybp"
from konlpy.tag import Okt
tagger = Okt()

# + id="Acv_tzcuER7T"
stop_words = ['강,', '글,', '애', '미', '번', '은', '이', '것', '등', '더', '를', '좀', '즉', '인', '옹', '때', '만', '원', '이때', '개']

# + colab={"base_uri": "https://localhost:8080/"} id="FGrFfS1PDVl6" outputId="5ce21f42-b61a-4f31-e2a9-1865a0a61405"
posts_noun = []
for post in posts:
  # print(tagger.nouns(post))
  for noun in tagger.nouns(post):
    posts_noun.append(noun)

len(posts_noun)


# + colab={"base_uri": "https://localhost:8080/"} id="6WbAWbpwWYeg" outputId="7c038f7a-13d8-4590-b385-eeb2c0384cd3"
len(posts_noun)

# + colab={"base_uri": "https://localhost:8080/"} id="rKOv4OCWD_FK" outputId="513bc15e-0889-45c1-c955-fffec87e4296"
posts_noun

# + id="fs-b3NcJWUMb"
from collections import Counter

# + colab={"base_uri": "https://localhost:8080/"} id="Qa8ZNsQNWbfk" outputId="ab1e2be4-d409-4888-f3ed-c1b719fbc836"
noun_counter = Counter(posts_noun)
noun_counter

# + colab={"base_uri": "https://localhost:8080/"} id="thLpjvQ9YJxL" outputId="aec5721c-ccfd-4811-eb97-342db743416f"
top_30_nouns = noun_counter.most_common(301)
type(top_30_nouns), top_30_nouns

# + colab={"base_uri": "https://localhost:8080/"} id="tHQW6YQIY-Nz" outputId="69baca08-7403-49a6-d2e0-e7f9c92c9b8a"
top_nouns_dict = dict(top_30_nouns)
type(top_nouns_dict)

# + id="NI04T9dtZA7W"
from wordcloud import WordCloud

# + id="dBgPRMEmZZIx"
nouns_wordcloud = WordCloud()

# + colab={"base_uri": "https://localhost:8080/"} id="hCZ1WPXXZ0rR" outputId="bfa1d538-8d24-4bb7-fc5c-c933ac512ce6"
nouns_wordcloud.generate_from_frequencies(top_nouns_dict)

# + id="iLYuk0oOZ6qz"
import matplotlib.pyplot as plt

# + colab={"base_uri": "https://localhost:8080/", "height": 237} id="nGnaEKW7Z_TJ" outputId="9fb2688a-81ee-4eb3-ac87-ffc82a0081c8"
plt.imshow(nouns_wordcloud)

# + id="sNpYFsjOaThI"
from sklearn.feature_extraction.text import CountVectorizer

# + id="C1eAYOIffdZp"
corpus = [
    'you know I want your love',
    'I like you',
    'what should I do ',    
]

# + colab={"base_uri": "https://localhost:8080/"} id="cgPFlRAEflXV" outputId="aa12f35c-ebf7-4774-dd15-9a969004e501"
countvectorizer = CountVectorizer()
countvectorizer.fit_transform(corpus).toarray()

# + colab={"base_uri": "https://localhost:8080/"} id="yGu2T4V4fphP" outputId="77b0ca93-8a70-48b0-beee-7804ed1ea281"
print(countvectorizer.vocabulary_)

# + id="me808u39gJGE"


StarcoderdataJupyterScriptsDedupFiltered