<jupyter_start><jupyter_text>create emotion classfier using Naive Bayes * 0: negative* 1 : positive<jupyter_code>import pandas as pd
reviews =pd.read_csv("ratings_train.txt",delimiter='\t')
reviews.head(10)
neg = reviews[(reviews.document.str.len() >= 30) & (reviews.label == 0)].sample(3000, random_state=43)
pos = reviews[(reviews.document.str.len() >= 30) & (reviews.label == 1)].sample(3000, random_state=43)
# str -> can be access to column of document

"""
import re
import konlpy
from konlpy.tag import Twitter # normal one is twitter

okt = Twitter()

"""
"""
def parse(s):
    s= re.sub(r''[?$.!,-_\'\"(){}~]+', '', s)
    try:
        return okt.nouns(s)
    except:
        return[]
"""
"""
neg['parsed_doc'] = neg.document.apply(parse)
pos['parsed_doc'] = pos.document.apply(parse)
"""
neg_test =pd.read_csv("neg.cvs",delimiter='\t')

neg_test.head()

# in case of 'NLP', pre-processing of data is most important thing
pos.head()
neg_train = neg[:2900]
pos_train = pos[:2900]
neg_test = neg[2900:]
pos_test = pos[2900:]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18567389255419417, 'fraction_numerical': 0.03581526861451461, 'mean_word_length': 4.9, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '348103', 'license': 'MIT', 'n_tokens_mistral': 427, 'n_tokens_neox': 397, 'n_words': 87, 'path': 'DSES_2nd_review/lecturenote_0330_unfinished.ipynb', 'repo_name': 'MinJiH/TIL', 'size': '1061'}