function showKMAResult(data) {
	var html = "";
	
	html = "<b><분석결과></b><p>";
	html += "<table cellpadding='0' cellspacing='1' style='width:100%'>";

	var kma = data["kma"];
	
	for (var i=0; i<kma.length; i++){
		var sentences = kma[i];

		var sentence = sentences['sentence'];
		html += "<tr><td>" + sentence + "</td></tr>";
		html += "<tr><td>&nbsp;</td></tr>";
		var wordlist = sentences['wordlist'];
		
		for (var j=0; j<wordlist.length; j++){
			var words = wordlist[j];
			
			var word = words['word'];
			var morphemelist = words['morphemelist'];
			
			for (var k=0; k<morphemelist.length; k++){
				var morphemes = morphemelist[k];
				var morpheme = morphemes['morpheme'];
				var pos = morphemes['pos'];

				html += "<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + morpheme + " / " + pos + "</td></tr>";
			}
			html += "<tr><td>&nbsp;</td></tr>";
		}
	}
	html += "<table>";
	
	$('#analysis_result').get(0).innerHTML = html;
}

function analyze_kma() {
	var text = $('#postagger_textarea').get(0).value;
	var param = "http://ncue.net:8080/text.ncue?cmd=analyzeKOR&text="+encodeURIComponent(text);

    $.ajax({
        url : param,
        type: 'POST',
        data : "id=user",
        dataType : "jsonp",
        jsonp : "callback",
        error: function(){
            alert('Error loading data');
        },
        success: function(data) {
            showKMAResult(data);
        }
    });
}


function showAutospacingResult(data) {
	var html = "";
	
	html = "<b><분석결과></b><p>";
	html += data["sentence"];
	
	$('#analysis_result').get(0).innerHTML = html;
}

function analyze_autospacing() {
	var text = $('#postagger_textarea').get(0).value;
	var param = "http://ncue.net:8083/autospacing?text="+encodeURIComponent(text);

    $.ajax({
        url : param,
        type: 'POST',
        data : "id=user",
        dataType : "jsonp",
        jsonp : "callback",
        error: function(){
            alert('Error loading data');
        },
        success: function(data) {
        	showAutospacingResult(data);
        }
    });
}




