<jupyter_start><jupyter_text>WineBot Recommendations Demo<jupyter_code>cd /content/drive/My Drive/vinepair_chatbot
from google.colab import drive
drive.mount('/content/drive')
from src.information_retrieval_model import Wine_Information_Retrieval_Model
pir = Wine_Information_Retrieval_Model()
!pip install matplotlib==3.0.3
!pip install pymysql
!pip install mysql-connector
import pymysql
import pandas as pd
import numpy as np
import mysql.connector

db = mysql.connector.connect(
   host="database-3.cwonoul9fvix.us-east-1.rds.amazonaws.com",
   user="admin",
   passwd="password",
   database="VinePair_New"
)

print(db)
db_cursor = db.cursor()
db_cursor.execute('SELECT * FROM cb_review_draft2')
table_rows = db_cursor.fetchall()
df = pd.DataFrame(table_rows, columns =["title", "description"])
df
from IPython.display import display
from ipywidgets import widgets
from IPython.display import clear_output
import matplotlib.pyplot as plt
from textwrap import wrap


print("Hi, I'm Arthur, your personal bartender. What can I help you with today?")
text = widgets.Text()
display(text)
button = widgets.Button(description="Restart!")
display(button)

def on_button_clicked(b):
    clear_output()
    print("Hi, What can I help you with today?")
    display(text)
    display(button)

def handle_submit(sender):
  print("Got it! Hold tight while I find your recommendations!")
  message = text.value

  recs = pir.query_similar_wines(message, 5)
  print(recs)
  pir.view_recommendations(recs)

text.on_submit(handle_submit)
button.on_click(on_button_clicked)<jupyter_output>Hi, I'm Arthur, your personal bartender. What can I help you with today?
{'fraction_non_alphanumeric': 0.10012135922330097, 'fraction_numerical': 0.0048543689320388345, 'mean_word_length': 5.957805907172996, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '296483', 'license': 'MIT', 'n_tokens_mistral': 564, 'n_tokens_neox': 542, 'n_words': 141, 'path': 'run_model.ipynb', 'repo_name': 'ZhengWang01/WineBot', 'size': '1648'}