<jupyter_start><jupyter_text>------------- back-translation<jupyter_code>from googletrans import Translator
import googletrans

translator = Translator()
s
lang = ['fr','de','es','ru','it','ja','ko','zh-cn']
trans = []
print("original sentence:")
print(s)
predict_word(s)
print('\n')
for l in lang:
    tmp = translator.translate(s,dest=l ).text
    des = translator.translate(tmp,dest='en').text
    print(l,'###',des)
    predict_word(des)
    print('\n')
googletrans.LANGUAGES
predict_word(re.split('[^a-zA-Z\sn\'t]',s)[0])
for i in range(20):
    if flabel[i]==5:
        print(i,ftest[i])
predict_word("request")
fTEXT.vocab.freqs['request']
mTEXT.vocab.freqs['request']
w='never'
ls = find_sen(w,ftest)
ftest[ls[0]]
for i,n in enumerate(ls):
    print(i,test_other(w,n,ftest))
    print('\n')
m23 = find_sen('23rd',mtest)
for n in m23:
    print(test_otherm('23rd',n))
    print('\n')
mtest[m23[2]]
predict_word('closed')
predict_word('never')
predict_word('23rd')
predict_word('awful')
predict_word('raw')
predict_word('rude')
predict_word('elderly')
fTEXT.vocab.freqs['elerly']
mTEXT.vocab.freqs['elderly']
sen = find_sen('elderly',ftest)
sen
test_other('23rd',sen[2],ftest)
ftest[10791]
fdf.iloc[10791]
for i,x in enumerate(ftest):
    if "fillet" in x:
        print(i,fdf['f-m'][i])
w = 'utterly'
mls=[]
for i,x in enumerate(mtrain):
    if w in x:
        mls.append(i)
mstar=[]
for i in mls:
    mstar.append(int(mtrain[i].split('\t')[1].strip('\n')))
print(len(mls))

fls=[]
for i,x in enumerate(ftrain):
    if w in x:
        fls.append(i)
fstar=[]
for i in fls:
    fstar.append(int(ftrain[i].split('\t')[1].strip('\n')))
print(len(fls))
fstar = np.array(fstar)
mstar = np.array(mstar)
predict_word('utterly')
import matplotlib.pyplot as plt
plt.hist(mstar,density=True)
plt.xlabel('male sentiment distribution for "{}"'.format(w),fontsize=15)
plt.show()
plt.hist(fstar,density=True)
plt.xlabel('female sentiment distribution for "{}"'.format(w),fontsize=15)
plt.show()
for x in ftrain:
    if "wife" in x:
        print(x)
        break<jupyter_output>great food and excellent customer service . had lunch on sat . went with son and his wife . we 're chatting when bill came . glanced at bill , misread bill . payed way to much . contacted weary traveler regarding my error . they were happy to refund my overpayment . receive the check very quick . we will be back for more great food .	5
{'fraction_non_alphanumeric': 0.1803074366431242, 'fraction_numerical': 0.01578728707935189, 'mean_word_length': 4.733333333333333, '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': '126994', 'license': 'MIT', 'n_tokens_mistral': 959, 'n_tokens_neox': 928, 'n_words': 211, 'path': 'new_less700_analysis.ipynb', 'repo_name': 'rainyrainyguo/sentiment-analysis', 'size': '2407'}