-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathgui.html
More file actions
59 lines (58 loc) · 2.17 KB
/
Copy pathgui.html
File metadata and controls
59 lines (58 loc) · 2.17 KB
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
<html>
<body>
<script>
function js_parse() {
var input_lyrics = document.getElementById("inp_lyrics");
var input_near_rhymes = document.getElementById("inp_near_rhymes");
if (input_lyrics.value.length == 0) {
return;
}
(async function() {
const result = await google.colab.kernel.invokeFunction(
'notebook.python_parse_hook', // The callback name.
[input_lyrics.value, input_near_rhymes.checked], // The arguments.
{}); // kwargs
const res = result.data['application/json'].result;
input_lyrics.value = res;
})();
/*
async function foo() {
const result = await google.colab.kernel.invokeFunction(
'notebook.python_parse_hook', // The callback name.
[input_lyrics.value, input_near_rhymes.checked], // The arguments.
{}); // kwargs
return result;
};
foo().then(function(value) {
var scheme_text = value.data['application/json'].result;
input_lyrics.value = scheme_text;
});
*/
}
function js_run() {
var input_lyrics = document.getElementById("inp_lyrics");
var input_prompt = document.getElementById("inp_prompt");
var input_recontextualize = document.getElementById("inp_recontextualize");
var input_near_rhymes = document.getElementById("inp_near_rhymes");
if (input_lyrics.value.length == 0 || input_prompt.value.length == 0) {
return;
}
// Call python
(async function() {
const result = await google.colab.kernel.invokeFunction(
'notebook.python_run_hook', // The callback name.
[input_prompt.value, input_lyrics.value, input_near_rhymes.checked, input_recontextualize.checked], // The arguments.
{}); // kwargs
const res = result.data['application/json'];
})();
}
</script>
<strong>Context prompt:</strong> <input id="inp_prompt" size="50"/><br>
<strong>Enter lyrics here:</strong><br />
<textarea rows = "5" cols = "70" name = "lyrics" id="inp_lyrics"></textarea><br />
<strong>Use near rhymes?</strong> <input type="checkbox" id="inp_near_rhymes" /><br />
<strong>Recontextualize?</strong> <input type="checkbox" id="inp_recontextualize" /><br />
<button onmouseup="js_run()">Parse and Run!</button>
<button onmouseup="js_parse()">Just Parse</button>
</body>
</html>