<jupyter_start><jupyter_text>Introduction In this file, we will find the synonymstags and establish a table for them.<jupyter_code>import pymysql
db=pymysql.connect(host='localhost',user='root',password='<PASSWORD>@',database='ski_project_test1',charset='utf8mb4')
cursor=db.cursor()
cursor.execute('USE ski_project_test1')
ins_post=[]
cursor.execute('SELECT hashtag,post_caption FROM ski_project_test1.inshashtag;')
for row in cursor.fetchall():
    ins_post.append(row)
test11=ins_post[:]
test11[3]
test11[2][0]
#test11[0][1][test11[0][1].find('#')+1:].split(' #')
test11[0][1]
#post_list=[]
#for i in range(len(test11)):
    
    #ele1=test11[i][0].split()
    #ele2=test11[i][1][test11[i][1].find('#')+1:].split(' #') 
    #ele3=ele1+ele2
    #post_list.append(ele3)
    
post_list=[]
for i in range(len(test11)):
    try:
        ele1=test11[i][0].split()
        ele2=test11[i][1][test11[i][1].find('#')+1:].split(' #') 
        ele3=ele1+ele2
        post_list.append(ele3)
    except:
        i = i+1 
        pass;
    
post_list[0][0]
from datetime import datetime
from datetime import timedelta
from itertools import dropwhile, takewhile
import pandas as pd
import numpy as np
import instaloader
df_1 = pd.read_csv('skiResort_ins_final 1.csv')
df_1_np = np.array(df_1)
csv_list = df_1_np.tolist()
ins_hashtag = csv_list[:]
for i in range(len(ins_hashtag)):
    ins_hashtag[i] = ins_hashtag[i][1]
ins_hashtag
hushtag_set={}
for i in range(len(ins_hashtag)):
    hushtag_set[ins_hashtag[i]]=set()
for i in range(len(post_list)):
    if post_list[i][0]in hushtag_set:
        for x in post_list[i]:
            hushtag_set[post_list[i][0]].add(x)
len(post_list)
ins_hashtag[0]
len(hushtag_set)
for key in list(hushtag_set.keys()):
    if not hushtag_set.get(key):
        del hushtag_set[key]
len(hushtag_set)
syn_hash=[]
for k,v in hushtag_set.items():
    ssssss=process.extract(k, v,limit=3)
    syn_hash.append(ssssss)
final_syn=syn_hash[:]
final_syn
for i in range(len(final_syn)):
    try:
        if final_syn[i][2][1]<60:
            del final_syn[i][2]
    except:
        i=i+1
        pass

for i in range(len(final_syn)):
    try:
        if final_syn[i][1][1]<60:
            del final_syn[i][1]
    except:
        i=i+1
        pass
final_syn
final_test=final_syn[:]
final_test
final_test_pd= pd.DataFrame(final_test)
final_test_pd
final_test_na=final_test_pd.dropna(axis=0, how='any')
final_test_pd_np = np.array(final_test_na)
final_test_list = final_test_pd_np.tolist()
hash_tag_na=final_test_list[:]
syn_tag_1=final_test_list[:]
syn_tag_2=final_test_list[:]
for i in range(len(hash_tag_na)):
    hash_tag_na[i]=hash_tag_na[i][0][0]
for i in range(len(syn_tag_1)):
    syn_tag_1[i]=syn_tag_1[i][1][0]
for i in range(len(syn_tag_2)):
    syn_tag_2[i]=syn_tag_2[i][2][0]
hash_tag_na_df=pd.DataFrame(hash_tag_na)
syn_tag_1_df=pd.DataFrame(syn_tag_1)
syn_tag_2_df=pd.DataFrame(syn_tag_2)
syn_tag_1_df
hash_tag_na_df['tag_1'] = syn_tag_1_df
hash_tag_na_df['tag_2']=syn_tag_2_df
hash_tag_na_df
hash_tag_na_np= np.array(hash_tag_na_df)
hash_tag_list = hash_tag_na_np.tolist()
hash_tag_list
import pymysql
db=pymysql.connect(host='localhost',user='root',password='<PASSWORD>@',database='ski_project_test1',charset='utf8mb4')
cursor=db.cursor()
cursor.execute('USE ski_project_test1')
sql='''CREATE TABLE IF NOT EXISTS synonymstag (
hashtag TEXT,
hashtag_1 TEXT,
hashtag_2 TEXT);
'''
cursor.execute(sql)
for i in range(len(hash_tag_list)):
    query = 'insert into synonymstag(hashtag, hashtag_1, hashtag_2) values(%s, %s, %s)'
    hashtag = hash_tag_list[i][0]
    hashtag_1 = hash_tag_list[i][1]
    hashtag_2 = hash_tag_list[i][2]
    values = (hashtag, hashtag_1, hashtag_2)
    cursor.execute(query, values)
    db.commit()
db.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15108293713681986, 'fraction_numerical': 0.033544638140517696, 'mean_word_length': 5.407783417935702, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '613671', 'license': 'MIT', 'n_tokens_mistral': 1631, 'n_tokens_neox': 1600, 'n_words': 252, 'path': 'ski_resort_project/synonymstag_table.ipynb', 'repo_name': 'howardxjy/info6210_project_team_Cerberus', 'size': '3786'}