File size: 3,340 Bytes
88f59a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import param
import panel as pn
pn.extension(sizing_mode="stretch_width")
import pickle
import pandas as pd

css = ['https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css',
       # Below: Needed for export buttons
       'https://cdn.datatables.net/buttons/1.7.0/css/buttons.dataTables.min.css'
]
js = {
    '$': 'https://code.jquery.com/jquery-3.5.1.js',
    'DataTable': 'https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js',
    # Below: Needed for export buttons
    'buttons': 'https://cdn.datatables.net/buttons/1.7.0/js/dataTables.buttons.min.js',
    'jszip': 'https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js',
    'pdfmake': 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js',
    'vfsfonts': 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js',
    'html5buttons': 'https://cdn.datatables.net/buttons/1.7.0/js/buttons.html5.min.js',
}

pn.extension(css_files=css, js_files=js)

script = """
<script>
if (document.readyState === "complete") {
  $('.example').DataTable();
} else {
  $(document).ready(function () {
    $('.example').DataTable();
  })
}
</script>
"""

# html = autompg.to_html(classes=['example', 'panel-df'])


class ReactiveTables(param.Parameterized):    
    dataset = param.ObjectSelector(default='SNLI (DistillBERT)', objects=['SNLI (DistillBERT)', 'MRPC (ALBERT)', 'SQuAD (Roberta)'])
    split = param.ObjectSelector(default='train', objects=['train', 'validation or test'])
    start = param.Integer(1)
    stop = param.Integer(200)
    
    @param.depends('dataset', 'split')
    def data(self):
        _path = f'{self.dataset.split(" ")[0]}_{self.split}.pkl'
        if self.split != 'train':
            _path = _path.replace('validation or test', 'validation' if 'SQuAD' in self.dataset else 'test')
        dataframe = pickle.load(open(_path, 'rb'))
        return dataframe

    @param.depends('dataset', 'split', 'data')
    def summary(self):
        return self.data().describe()
    
#     @param.depends('data', 'stop')
#     def table(self):
#         return self.data()[self.start:self.stop]
    
    @param.depends('dataset', 'split', 'start', 'stop')
    def table_ours(self):
        return pn.pane.HTML(self.data()[self.start:self.stop + 1].to_html(classes=['example', 'panel-df']) + script, 
                                   sizing_mode='stretch_width')
    
    
    def panel(self):
        return pn.Row(
            pn.Param(self, name="Settings", width=300, sizing_mode="fixed"),
            pn.Column(
                "## Description", self.summary, 
                "## Table", self.table_ours, 
                width=2000, 
#                 sizing_mode='stretch_height'
            )
            , sizing_mode="stretch_width"
        )
    
component = ReactiveTables().panel()

# dash = 
pn.template.FastListTemplate(site="ACL 23 Submission", title="Finding Secret Language of Language Models", 
                             main=[
                                 "This page presents some secret languages discovered by our proposed SecretFinding algorithm on three multi-sentence datasets. To ensure optimal performance of this webapp, we recommend presenting less than 2000 data at a time.",
                                 component 
                             ]).servable()
# pn.serve(dash)