- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
function saveTrainingData() {
function getStorylineCsvStr(lineNumber) {
var storyline = loadedLines[lineNumber];
var csvStr = "";
for (var i = 0; i < storyline.entities.length; i++) {
if (i > 0) {
csvStr = csvStr + ",";
}
var entityName = storyline.entities[i].name;
if (storyline.entities[i].relation != null && storyline.entities[i].relation.length > 0) {
for (var j = 0; j < storyline.entities[i].relation.length; j++) {
if ($("#relation-checkbox-" + lineNumber + "-" + i + "-" + j).is(":checked")) {
entityName = entityName + ":" + storyline.entities[i].relation[j];
}
}
}
if (entityName.indexOf(",") >= 0 || entityName.indexOf("\"") >= 0) {
if (entityName.indexOf("\"") >= 0) {
entityName = entityName.replace(/"/g, "\"\"");
}
entityName = "\"" + entityName + "\"";
}
csvStr = csvStr + entityName;
}
return csvStr;
}
var trainingData = "";
$(".training").each(function (index, element) {
var trainingHolder = $(element);
var lineNumber = trainingHolder.attr("line-number");
if (trainingHolder.find(".positive").is(":checked")) {
trainingData = trainingData + getStorylineCsvStr(lineNumber) + ",1\n";
} else if (trainingHolder.find(".negative").is(":checked")) {
trainingData = trainingData + getStorylineCsvStr(lineNumber) + ",0\n";
}
});
var groupId = $('#group-name-selector :selected').val();
var bandType = $('#band-selector').val();
sendRequest("/app/view/set/trainingData", {
trainingData: trainingData,
groupId: groupId,
bandType: bandType
}, true, true);
}
Комментарии (0) RSS
Добавить комментарий