<jupyter_start><jupyter_text>Sandbox<jupyter_code>import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from string import punctuation
sentences = {
    0:'How do you know this works',
    1:'How are you',
    2:'What do you do',
    3:'How have you been',
    4:'Who are you'
}
df = pd.DataFrame.from_dict(sentences,orient='index')
df[0]
mat = TfidfVectorizer().fit_transform(df[0])
mat.todense()
from medibo import cleaning
from medibo.cleaning import *
import re
import json
from pprint import pprint
# cleaning.clean('This! is amazing. Are you, planning,?')
x = 'This! is amzaing. Are you, planning,?'
# [[spell_check(w) for w in burst_punc(s).split(' ')] for s in x.split('.')]
clean(x)
with open('users.json') as users_data:
    users = json.load(users_data)[0]

pprint(users)
from_number = "+19292088929"
human = users[from_number]["name"] if from_number in users.keys() else None
import pandas as pd
pd.DataFrame.from_dict(users,orient='index')
keys = ["Name","Address","Phone"]
a = dict(zip(keys, [None]*len(keys)))
if(int('100ds7')):
    print('YES')
import json

with open('emoji.json') as json_data:
    d = json.load(json_data)
new_d = {}
for e in d:
    name = e['name'].replace(' ','_')
    char = e['char']
    code = e['code']
    no = e['no']
    new_d[name] = [char,code,no]
with open("new_emoji.json","w") as file:
    file.write(json.dumps([new_d]))

file.close()
with open("emoji.json","r") as file:
    x = json.loads(file.read())[0]
print(u'\U0001F947')
s = u'Welcome! \U0001f604'
print(s)
# with open("messages.json",encoding="utf-8",mode="r") as file:
#     x = json.loads(file.read())[0]
text  = "This is amazing"<jupyter_output><empty_output><jupyter_text>Testing 1<jupyter_code>import os
from flask import Flask, request, redirect, session
from twilio.twiml.messaging_response import MessagingResponse
from twilio.twiml.voice_response import VoiceResponse
import json
from pprint import pprint
import time
# =======================[ READING DATA FILES ]=================================

with open('data/users.json') as users_data:
    users = json.load(users_data)[0]  # This is a dictionary of users indexed
    								  # by their phone numbers

with open('data/messages.json') as messages_data:
    messages = json.load(messages_data)[0]  # This is a dictionary of messages
    
with open('data/stories.json') as stories_data:
    stories = json.load(stories_data)[0]  # This is a dictionary of stories
# ======================[ DECLARING CODE FLAGS ]================================

# These flags hold sesssion level contextual information

intent_flag = 0
tags_flag = 0
targets_flag = 0
text_flag = 0

input_keys = ['timestamp','user_id','session_id','tags','targets','intent','text']
def sms_reply(counter,from_number):
    
    timestamp = time.time()
    output = []
    resp = MessagingResponse()

#     counter = session.get('counter', 0)
#     input_text = request.values.get('Body', None)
    counter += 1


#     from_number = request.values.get('From', None)
    human = users[from_number]["name"] if from_number in users else None
    print("\n\nTalking to " + str(human))
    
    input_data = dict.fromkeys(input_keys)
    
    
    if(counter == 1): # If this is the first session
        output += [messages[str(_id)]["text"] for _id in stories["welcome"]["messages"]]

    if(human == None):  # A record for this user doesn't exist
        
        output += onboard(from_number)
    else:
        resp.message("Hi " + human + "! How are you feeling today?")
    
    for i in range(len(output)):
        resp.message(output[i])
    
    return str(resp)
def onboard(number):
    print("\nOnboarding " + str(number))
    
    return []
sms_reply(0,'+19292088449')
stories<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1693569727441122, 'fraction_numerical': 0.016671077004498543, 'mean_word_length': 4.286713286713287, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '480026', 'license': 'MIT', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1265, 'n_words': 323, 'path': 'res/medbot-janak/sandbox/sandbox.ipynb', 'repo_name': 'dhbilton/where-is-jojo', 'size': '3779'}