-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathloadfile.html
More file actions
194 lines (160 loc) · 5.91 KB
/
loadfile.html
File metadata and controls
194 lines (160 loc) · 5.91 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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!-- The following line is essential for the "position: fixed" property to work correctly in IE -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//ES">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
<head>
<title>Chatbot</title>
<meta charset="UTF-8">
<style>@import url(http://fonts.googleapis.com/css?family=Lato);
#progress_bar {
margin: 10px 0;
padding: 3px;
border: 1px solid #000;
font-size: 14px;
clear: both;
opacity: 0;
-moz-transition: opacity 1s linear;
-o-transition: opacity 1s linear;
-webkit-transition: opacity 1s linear;
}
#progress_bar.loading {
opacity: 1.0;
}
#progress_bar .percent {
background-color: #99ccff;
height: auto;
width: 0;
}
#loader {
position: absolute;
left:40%;
top:10%;
}
</style>
<link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.8.2.custom.css" type="text/css" media="screen" />
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.2.custom.min.js"></script>
<link type="text/css" href="EN/jquery.ui.chatboxmod.css" rel="stylesheet" />
<link type="text/css" href="head.css" rel="stylesheet" />
<script type="text/javascript" src="EN/jquery.ui.chatboxmod.js"></script>
<script type="text/javascript" src="AIchatloadfile.js"></script>
<script type="text/javascript" src="sinacento.js"></script>
<script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
</head>
<body>
<p>Upload a csv with headers Question, Answer, Weights(optional)</p>
<div id="loader">
<p align="center">Upload file<br><input type="file" id="files" name="files[]" multiple/>
</p>
<p align="center">
Success estimator (0-1)<br>
<input type="number" id="totalest" step="0.01" value="0.49" style="width: 50px;"></input>
<br>Error coef (0-1)<br>
<input type="number" id="totalcoef" step="0.05" value="0.7" style="width: 50px;"></input><br>
<input type="checkbox" id="weights" value="0" />Weights<br>
<input type="checkbox" id="memory" value="0" />Memory
</p>
<p align="center"><button onclick="abortRead();">Begin</button></p><div id="progress_bar"><div class="percent">0%</div></div>
</div>
<div id="chat_div">
</div>
<div id="log">
</div>
<!-- Chat Head -->
<a id="chat-head" href="#">
<i>1</i>
</a>
</body>
<script type="text/javascript">
var reader;
var arbol = 0;
var progress = document.querySelector('.percent');
function abortRead() {
abrir(arbol);
}
function errorHandler(evt) {
switch(evt.target.error.code) {
case evt.target.error.NOT_FOUND_ERR:
alert('File Not Found!');
break;
case evt.target.error.NOT_READABLE_ERR:
alert('File is not readable');
break;
case evt.target.error.ABORT_ERR:
break; // noop
default:
alert('An error occurred reading this file.');
};
}
function updateProgress(evt) {
// evt is an ProgressEvent.
if (evt.lengthComputable) {
var percentLoaded = Math.round((evt.loaded / evt.total) * 100);
// Increase the progress bar length.
if (percentLoaded < 100) {
progress.style.width = percentLoaded + '%';
progress.textContent = percentLoaded + '%';
}
}
}
function handleFileSelect(evt) {
// Reset progress indicator on new file selection.
progress.style.width = '0%';
progress.textContent = '0%';
reader = new FileReader();
reader.onerror = errorHandler;
reader.onprogress = updateProgress;
reader.onabort = function(e) {
alert('File read cancelled');
};
reader.onloadstart = function(e) {
document.getElementById('progress_bar').className = 'loading';
};
reader.onload = function(e) {
// Ensure that the progress bar displays 100% at the end.
progress.style.width = '100%';
progress.textContent = '100%';
setTimeout("document.getElementById('progress_bar').className='';", 2000);
//alert(d3.csv.parse(reader.result));
// alert(reader.result);
if(arbol===0){arbol=d3.csv.parse(reader.result);}
}
// Read in the image file as a binary string.
reader.readAsText(evt.target.files[0]);
//reader.readAsBinaryString(evt.target.files[0]);
}
document.getElementById('files').addEventListener('change', handleFileSelect, false);
function getUrlParameter(sParam)
{
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++)
{
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam)
{
return sParameterName[1];
}
}
}
function abrir(csv){
var check = null;
var reg = /\, |\. /g; // list of words to omit, if you use weights do not set score for that word
var decider=$('#totalest').attr('value') // jacobian estimator for sucessful clasification
var lengthmax=20; // max sentence length before being divided by two sentences
var weights=0;
var memory=0; // 1 takes the last message sent into account for clasification. 0 does not.
var coef=$('#totalcoef').attr('value') // coefficient that allows typing errors and associates words with similar stem
if($("#weights").is(':checked')) weights=1; // checked
if($("#memory").is(':checked')) memory=1; // checked
$(document).ready(function () {
$('#chat-head').addClass('animate');
$("#chat-head").click(function() {
if(check) { $("#chat_div").chatbox("option", "hidden", false);
}
else { init(csv,decider,reg,lengthmax,memory,coef,weights);check++;}
});
});}
</script>
</html>
</body>
</html>