Spaces:
Runtime error
Runtime error
anonymousauthors
commited on
Commit
•
1e00edb
1
Parent(s):
8314c41
Update secretlanguage.py
Browse files- secretlanguage.py +40 -13
secretlanguage.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import param
|
2 |
import panel as pn
|
3 |
-
pn.extension(sizing_mode="stretch_width")
|
4 |
import pickle
|
5 |
import pandas as pd
|
6 |
|
@@ -38,26 +38,52 @@ if (document.readyState === "complete") {
|
|
38 |
import pandas as pd
|
39 |
|
40 |
class ReactiveTables(param.Parameterized):
|
41 |
-
datas = pickle.load(open('all_secret_language.pkl', 'rb'))
|
42 |
-
name_ = param.String('deliberately')
|
43 |
-
|
44 |
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
-
@param.depends('name_')
|
47 |
def data(self):
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
@param.depends('name_')
|
51 |
def summary(self):
|
52 |
return self.data().describe()
|
53 |
|
54 |
-
|
55 |
-
# def table(self):
|
56 |
-
# return self.data()[self.start:self.stop]
|
57 |
-
|
58 |
-
@param.depends('name_')
|
59 |
def table_ours(self):
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
sizing_mode='stretch_width')
|
62 |
|
63 |
|
@@ -65,6 +91,7 @@ class ReactiveTables(param.Parameterized):
|
|
65 |
return pn.Row(
|
66 |
pn.Param(self, name="Settings", width=300, sizing_mode="fixed"),
|
67 |
pn.Column(
|
|
|
68 |
"## Description", self.summary,
|
69 |
"## Table", self.table_ours,
|
70 |
width=2000,
|
@@ -77,7 +104,7 @@ component = ReactiveTables().panel()
|
|
77 |
|
78 |
pn.template.FastListTemplate(site="ACL 23 Submission", title="Finding Secret Language of Language Models",
|
79 |
main=[
|
80 |
-
"This page presents
|
81 |
component
|
82 |
]).servable()
|
83 |
|
|
|
1 |
import param
|
2 |
import panel as pn
|
3 |
+
pn.extension(sizing_mode="stretch_width", notifications=True)
|
4 |
import pickle
|
5 |
import pandas as pd
|
6 |
|
|
|
38 |
import pandas as pd
|
39 |
|
40 |
class ReactiveTables(param.Parameterized):
|
|
|
|
|
|
|
41 |
|
42 |
+
name_ = param.String('Asian')
|
43 |
+
record_start_index = param.Integer(1)
|
44 |
+
record_stop_index = param.Integer(200)
|
45 |
+
old_data = None
|
46 |
+
datas = None
|
47 |
|
48 |
+
@param.depends('name_', 'record_start_index', 'record_stop_index')
|
49 |
def data(self):
|
50 |
+
print('new name', self.name_)
|
51 |
+
if len(self.name_) > 0:
|
52 |
+
if ord(self.name_[0]) in list(range(48, 57)):
|
53 |
+
file_name = 'num_dict.pkl'
|
54 |
+
elif ord(self.name_[0]) in list(range(97, 122)) + list(range(65, 90)):
|
55 |
+
file_name = f'{ord(self.name_[0])}_dict.pkl'
|
56 |
+
else:
|
57 |
+
file_name = 'other_dict.pkl'
|
58 |
+
print(f'all_secret_langauge_by_fist/{file_name}')
|
59 |
+
self.datas = pickle.load(open(f'all_secret_langauge_by_fist/{file_name}', 'rb'))
|
60 |
+
|
61 |
+
if self.name_ in self.datas.keys():
|
62 |
+
self.old_data = pd.DataFrame(self.datas[self.name_])
|
63 |
+
return self.old_data
|
64 |
|
65 |
@param.depends('name_')
|
66 |
def summary(self):
|
67 |
return self.data().describe()
|
68 |
|
69 |
+
@param.depends('name_', 'record_start_index', 'record_stop_index')
|
|
|
|
|
|
|
|
|
70 |
def table_ours(self):
|
71 |
+
data = self.data()
|
72 |
+
return pn.pane.HTML(data[max(0, self.record_start_index):
|
73 |
+
min(self.record_stop_index + 1, len(data))].to_html(
|
74 |
+
classes=['example', 'panel-df']) + script,
|
75 |
+
sizing_mode='stretch_width')
|
76 |
+
@param.depends('name_', 'record_start_index', 'record_stop_index')
|
77 |
+
def notification(self):
|
78 |
+
if self.datas:
|
79 |
+
if self.name_ in self.datas.keys():
|
80 |
+
return pn.pane.HTML(f'<h1>Found {self.name_}</h1>' ,
|
81 |
+
sizing_mode='stretch_width')
|
82 |
+
else:
|
83 |
+
return pn.pane.HTML(f'<h1>Error. {self.name_} not in the dict.</h1>' ,
|
84 |
+
sizing_mode='stretch_width')
|
85 |
+
else:
|
86 |
+
return pn.pane.HTML('<h1>initing</h1>' ,
|
87 |
sizing_mode='stretch_width')
|
88 |
|
89 |
|
|
|
91 |
return pn.Row(
|
92 |
pn.Param(self, name="Settings", width=300, sizing_mode="fixed"),
|
93 |
pn.Column(
|
94 |
+
self.notification,
|
95 |
"## Description", self.summary,
|
96 |
"## Table", self.table_ours,
|
97 |
width=2000,
|
|
|
104 |
|
105 |
pn.template.FastListTemplate(site="ACL 23 Submission", title="Finding Secret Language of Language Models",
|
106 |
main=[
|
107 |
+
"This page presents all secret languages discovered by our proposed SecretFinding algorithm on three multi-sentence datasets. To ensure optimal performance of this webapp, at a time at most 2000 entries can be showed. \n``Name'' is the word that you want to find secret languages for. record start index and record stop index mark the start and end indices of the entries.",
|
108 |
component
|
109 |
]).servable()
|
110 |
|