|
|
|
@ -10,6 +10,7 @@ var wordTitleList
|
|
|
|
|
var randId
|
|
|
|
|
var globKeyword = ''
|
|
|
|
|
var stopwords = []
|
|
|
|
|
var tsvString
|
|
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
|
$.ajax({
|
|
|
|
@ -35,7 +36,7 @@ function init() {
|
|
|
|
|
$('#graphInfo').empty()
|
|
|
|
|
$('#graphInfo').attr('style', 'margin: 10px;').append('總文章數:' + json.info.posts + ',' + keywordCountString)
|
|
|
|
|
totalPosts = json.info.posts
|
|
|
|
|
buildSentetree(tsvString)
|
|
|
|
|
buildSentetree()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
@ -102,7 +103,6 @@ function addStopWord() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showStopwordEditor() {
|
|
|
|
|
console.log(stopwords)
|
|
|
|
|
$(window).unbind('keydown')
|
|
|
|
|
$(window).keydown(function(event) {
|
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
@ -175,7 +175,7 @@ function sendRequest() {
|
|
|
|
|
startDate: $('#startDate').val(),
|
|
|
|
|
endDate: $('#endDate').val(),
|
|
|
|
|
keyword: $('#keywordBox').val(),
|
|
|
|
|
stopwords: stopwords,
|
|
|
|
|
stopwords: [],
|
|
|
|
|
pos: {
|
|
|
|
|
noun: $('#noun').is(':checked'),
|
|
|
|
|
verb: $('#verb').is(':checked'),
|
|
|
|
@ -216,19 +216,21 @@ function changeGraph(data) {
|
|
|
|
|
$('#graphInfo').attr('style', 'margin: 10px;').append('總文章數:' + json.info.posts + keywordCountString)
|
|
|
|
|
totalPosts = json.info.posts
|
|
|
|
|
destroyCurrentGraph()
|
|
|
|
|
d3.select('#graph').append('div').attr('id', 'vis')
|
|
|
|
|
buildSentetree(tsvString)
|
|
|
|
|
buildSentetree()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function destroyCurrentGraph() {
|
|
|
|
|
d3.selectAll('#vis').remove()
|
|
|
|
|
d3.select('#graph').append('div').attr('id', 'vis')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function hideTitles() {
|
|
|
|
|
$('#titleListLayer').addClass('hidden')
|
|
|
|
|
$('#setToKeyword').unbind()
|
|
|
|
|
$("#addToStopwords").unbind()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function buildSentetree(tsvString) {
|
|
|
|
|
function buildSentetree() {
|
|
|
|
|
console.log("Build.")
|
|
|
|
|
var model;
|
|
|
|
|
var tree;
|
|
|
|
@ -253,10 +255,9 @@ function buildSentetree(tsvString) {
|
|
|
|
|
fontSize: [15, 40],
|
|
|
|
|
gapBetweenGraph: 10
|
|
|
|
|
});
|
|
|
|
|
console.log(tree)
|
|
|
|
|
tree.data(model.getRenderedGraphs(2))
|
|
|
|
|
.on('nodeClick', node => {
|
|
|
|
|
$("#keywordBox").val(node.data.entity)
|
|
|
|
|
$('#titleListLayer').removeClass('hidden')
|
|
|
|
|
seqList = node.data.seq.DBs.map(function(n) {
|
|
|
|
|
return n.rawText
|
|
|
|
|
})
|
|
|
|
@ -273,6 +274,27 @@ function buildSentetree(tsvString) {
|
|
|
|
|
info = wordTitleList[node.data.entity]
|
|
|
|
|
$('#titleListKeyword').html(node.data.entity)
|
|
|
|
|
$('#titleListKeywordInfo').html('')
|
|
|
|
|
if (stopwords.indexOf(node.data.entity) < 0) {
|
|
|
|
|
$("#addToStopwords").html('設為停用詞').css('background-color', '#379').click(() => {
|
|
|
|
|
stopwords.push(node.data.entity)
|
|
|
|
|
destroyCurrentGraph()
|
|
|
|
|
buildSentetree()
|
|
|
|
|
hideTitles()
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
$("#addToStopwords").html('從停用詞移除').css('background-color', '#933').click(() => {
|
|
|
|
|
stopwords.pop(node.data.entity)
|
|
|
|
|
destroyCurrentGraph()
|
|
|
|
|
buildSentetree()
|
|
|
|
|
hideTitles()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
$('#setToKeyword').click(() => {
|
|
|
|
|
$('#keywordBox').val(node.data.entity)
|
|
|
|
|
sendRequest()
|
|
|
|
|
hideTitles()
|
|
|
|
|
})
|
|
|
|
|
$('#titleListLayer').removeClass('hidden')
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'POST',
|
|
|
|
|
url: '/ptt/keywordFrequency',
|
|
|
|
|