# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
from openpyxl import load_workbook
import random
import io

workbook = load_workbook(u'moli_for_cross_domain.xlsx')
booksheet = workbook.active
rows = booksheet.rows
columns = booksheet.columns

line_list = []
for row in rows:
    line = [col.value for col in row]
    line_list.append(line)

supintents = []
utters = []
for line in line_list[1:]:
    supintents.append(line[2])
    utters.append(line[1])
    
print(len(set(supintents)))
dict_supintent = {}
s_l = list(set(supintents))

# -

for i in range(len(s_l)):
    dict_supintent[s_l[i]] = i
print(dict_supintent)

train_list = []
for i in range(len(supintents)):
    text = utters[i] + "\t" + supintents[i]
    train_list.append(text)
random.shuffle(train_list)
fseq = open("./few_shot_induction/lena.txt", 'w', encoding="utf-8")
for text in train_list:
        fseq.write(text + "\n")
fseq.close()
print("Finish")

# +
from openpyxl import load_workbook
import random
import io
import matplotlib.pyplot as plt 

workbook = load_workbook(u'moli_for_cross_domain.xlsx')
booksheet = workbook.active
rows = booksheet.rows
columns = booksheet.columns
print("workbook")
line_list = []
for row in rows:
    line = [col.value for col in row]
    line_list.append(line)

intents = []
utters = []
for line in line_list[1:]:
    intents.append(line[2])
    utters.append(line[1])
print(len(set(intents)))

u_dict = {}
for u in utters:
    if len(u) not in u_dict.keys():
        u_dict[len(u)] = 1
    else:
        u_dict[len(u)] += 1

x = []
y = []
for k, v in u_dict.items():
    x.append(x)
    y.append(v)

plt.figure(figsize=(10, 10), dpi=80)
width = 0.45
p2 = plt.bar(y, x, width, label="num", color="#87CEFA")
plt.xlabel('length')
plt.ylabel('number of utterance')
plt.title('Length Distribution')
plt.show()
# -



StarcoderdataJupyterScriptsDedupFiltered