Erik Perrone 6 years ago
parent 2754f320a5
commit cc6b5c73c9

@ -6,7 +6,8 @@
<script type="text/javascript">
externalTest = function() {
var link = "http://data.d4science.org/SCs1TC9zdDYzYm1LSWsrWUNQdHk3MXo3YzBtWStMUEJHbWJQNStIS0N6Yz0";
link = "http://www.dropbox.com/s/cnyzf1bc3b5onj3/italian-text-4.txt?dl=0";
//link = "http://www.dropbox.com/s/cnyzf1bc3b5onj3/italian-text-4.txt?dl=0";
//link = "https://goo.gl/QgT25h";
location.href="index.jsp?input=" + encodeURIComponent(link);
}
</script>

@ -21,8 +21,10 @@
<script type="text/javascript" src="js/main.js"></script>
<script type="text/javascript" src="js/merge.js"></script>
<script type="text/javascript">
var activePage = "Named Entity Recognition";
var inputFile = '<%= ((request.getParameter(Constants.INPUT_FILE_PARAMETER) == null) ? "" : "" + request.getParameter(Constants.INPUT_FILE_PARAMETER)) %>';
var cGubeToken = '<%= ((request.getParameter(Constants.TOKEN_PARAMETER) == null) ? "" : "" + request.getParameter(Constants.TOKEN_PARAMETER)) %>';
var gCubeToken = '<%= ((request.getParameter(Constants.TOKEN_PARAMETER) == null) ? "" : "" + request.getParameter(Constants.TOKEN_PARAMETER)) %>';
var scheme = '<%= request.getScheme() %>';
</script>
</head>
<body style="padding: 0 15px;">
@ -36,8 +38,8 @@
<!-- tabs div: each tab must refer a page div -->
<div class="col s12">
<ul class="tabs">
<li class="tab col s3"><a href="#ner">NER</a></li>
<!-- <li class="tab col s3"><a href="#other">other</a></li> -->
<li class="tab col s3"><a href="#ner" onclick="activePage='Named Entity Recognition'">NER</a></li>
<!-- <li class="tab col s3"><a href="#other" onclick="activePage='Other'">other</a></li>-->
</ul>
</div>

@ -14,6 +14,7 @@ var txtFlag = true;
var checkedAnnotation = "";
var algIndexedArray = [];
var computedLanguage = "";
var dataMiner = "";
// ------------------------------------------------------------------------------------------------------
// Starting point: get the csv file with algorithm parameters and set the page
@ -34,22 +35,20 @@ checkInputLink = function() {
type : "GET",
async : true,
success : function(data, stato) {
$("#input-textarea").val(data);
freeText = $("#input-textarea").val();
freeText = data;
var uploaderUrl = "/nlphub/nlphub-uploader-servlet?getlang=on&freetext="
+ encodeURIComponent(freeText) + "&dataminer=" + encodeURIComponent(dataMiner);
if(gCubeToken.length > 0)
uploaderUrl += "&gcube-token=" + gCubeToken;
$.ajax({
url : "/nlphub/nlphub-uploader-servlet?getlang=on&freetext="
+ encodeURIComponent(freeText),
url : uploaderUrl,
type : "POST",
async : true,
contentType : "text/plain; charset=utf-8",
success : function(data, stato) {
//publicLink = data.message;
//if (publicLink == null) {
// alert("Error uploading file.");
//}
hideProgress();
$("#input-textarea").val(freeText);
computedLanguage = data.language;
//textAreaEnable(false);
initApplication();
},
error : function(richiesta, stato,
@ -64,7 +63,7 @@ checkInputLink = function() {
});
},
error : function(richiesta, stato, errori) {
alert("Unexpected error reading from link: '" + inputFile + "'.\nStatus: " + richiesta.status + "\nClick OK to start application.");
alert("Unexpected error reading from link: '" + inputFile + "'.\nStatus: " + richiesta.status + " Error: " + errori + "\nClick OK to start application.");
hideProgress();
initApplication();
}
@ -100,11 +99,14 @@ initApplication = function() {
});
disableExecuteButton();
var uploaderUrl = "/nlphub/nlphub-uploader-servlet?dataminer=" + encodeURIComponent(dataMiner);
if(gCubeToken.length > 0)
uploaderUrl += "&gcube-token=" + gCubeToken;
$("#upload-button")
.uploadFile(
{
url : "/nlphub/nlphub-uploader-servlet",
url : uploaderUrl,
fileName : "mytxtfile",
maxFileCount : 100,
multiple : false,
@ -243,9 +245,13 @@ setEventListeners = function() {
if ($("#input-textarea").val().length > 0) {
if(publicLink == null) {
freeText = $("#input-textarea").val();
var uploaderUrl = "/nlphub/nlphub-uploader-servlet?freetext="
+ encodeURIComponent(freeText) + "&dataminer=" + encodeURIComponent(dataMiner);
if(gCubeToken.length > 0)
uploaderUrl += "&gcube-token=" + gCubeToken;
$.ajax({
url : "/nlphub/nlphub-uploader-servlet?freetext="
+ encodeURIComponent(freeText),
url : uploaderUrl,
type : "POST",
async : true,
contentType : "text/plain; charset=utf-8",
@ -351,6 +357,8 @@ checkLanguage = function(lang) {
* CSV parser
*/
manageCsvData = function(data) {
var tokensPerLine = 8;
// first of all: split on the "newline" character in order to
// get all lines.
var lines = data.split("\n");
@ -372,14 +380,21 @@ manageCsvData = function(data) {
if (tokenStart == -1) {
tokenStart = j;
} else {
tokens[tokens.length] = line.substring(tokenStart + 1, j);
tokens.push(line.substring(tokenStart + 1, j));
tokenStart = j;
}
}
}
// get the new token and push it in the array
tokens[tokens.length] = line.substring(tokenStart + 1);
lineTokens[lineTokens.length] = tokens;
tokens.push(line.substring(tokenStart + 1));
if(tokens.length != tokensPerLine)
continue; // skip...
lineTokens.push(tokens);
var description = tokens[1].toUpperCase().trim();
if(description == "CLOUD COMPUTING")
dataMiner = tokens[2];
tokens = [];
}
@ -394,6 +409,8 @@ getAlgorithms = function(lineTokens) {
for (i = 0; i < lineTokens.length; i++) {
if ((i == 0) || (lineTokens[i].length != 8))
continue; // skip the header
if (lineTokens[i][1].toUpperCase().trim() != activePage.toUpperCase())
continue;
if (lineTokens[i][7].trim().toUpperCase() == "OK") {
var algName = lineTokens[i][0].trim();
var algDescription = lineTokens[i][1].trim();
@ -553,12 +570,16 @@ runAlgorithm = function() {
algList = algList.substring(0, algList.length - 1);
var parameters = "annotations=" + annList;
parameters += "&dataminer=" + encodeURIComponent(dataMiner);
parameters += "&lang=" + $("#language-select").val();
parameters += "&plink=" + encodeURI(publicLink);
parameters += "&plink=" + encodeURIComponent(publicLink);
parameters += "&algs=" + algList;
var nlphubUrl = "/nlphub/nlphub-servlet?" + parameters;
if(gCubeToken.length > 0)
nlphubUrl += "&gcube-token=" + gCubeToken;
$.ajax({
url : "/nlphub/nlphub-servlet?" + parameters,
url : nlphubUrl,
type : "POST",
async : true,
success : function(data, stato) {
@ -604,8 +625,12 @@ getOutputJson = function(message) {
parameters += "&tobemap=" + encodeURI(tobemap);
//console.log(parameters);
var mapperUrl = "/nlphub/nlphub-mapper-servlet?" + parameters;
if(gCubeToken.length > 0)
mapperUrl += "&gcube-token=" + gCubeToken;
$.ajax({
url : "/nlphub/nlphub-mapper-servlet?" + parameters,
url : mapperUrl,
type : "POST",
async : true,
success : function(data, stato) {

Loading…
Cancel
Save