<jupyter_start><jupyter_text><jupyter_code>!ls ./drive/MyDrive/Forkspoon/tok_index_word.pkl
!python -m pip install konlpy
!curl -O https://raw.githubusercontent.com/konlpy/konlpy/master/scripts/mecab.sh
!source ./mecab.sh
import tensorflow as tf

model = tf.keras.models.load_model('./drive/MyDrive/Forkspoon/test_dummy_LSTM.h5')
print(model)
import pickle
import sqlite3
import pandas as pd
import numpy as np
connect = sqlite3.connect('./drive/MyDrive/Forkspoon/db.sqlite3')

stopwords = pd.read_sql_query('select * from stopwords',connect)
ko_stopwords_list = np.array(stopwords['words'].tolist())
import konlpy
from konlpy.tag import Mecab
mecab= Mecab()
input_sentance= mecab.morphs('성실합니다')
input_sentance= [tok for tok in input_sentance if tok not in stopwords]
print(input_sentance)
tokenizer = pickle.load(open('./drive/MyDrive/Forkspoon/tokenizers.pkl','rb'))
vocb_size = len(tokenizer.word_index)
vocb_size
encoded = tokenizer.texts_to_sequences([input_sentance])
encoded

pad_new = tf.keras.preprocessing.sequence.pad_sequences(encoded, maxlen=300)
pad_new
score = model.predict(pad_new)
score
import numpy as np

np.argmax(score)<jupyter_output><empty_output><jupyter_text>함수로 만들기<jupyter_code># mecab = Mecab(dicpath=r"C:\mecab\mecab-ko-dic")
def sentance_predict(sentence):
  mecab= Mecab()
  input_sentance= mecab.morphs(sentence)
  input_sentance= [tok for tok in input_sentance if tok not in stopwords]
  encoded = tokenizer.texts_to_sequences([input_sentance])
  pad_new = tf.keras.preprocessing.sequence.pad_sequences(encoded, maxlen=300)
  score = model.predict(pad_new)
  return score
sentencess = '성실하네요' 
sentance_predict(sentencess)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11736810906935388, 'fraction_numerical': 0.005927682276229994, 'mean_word_length': 6.851162790697674, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '345890', 'license': 'Apache-2.0', 'n_tokens_mistral': 666, 'n_tokens_neox': 650, 'n_words': 113, 'path': 'Deeplearning/to_web.ipynb', 'repo_name': 'yoonputer/Team_Project2', 'size': '1687'}