diff --git a/__pycache__/dataHandlerPTT.cpython-37.pyc b/__pycache__/dataHandlerPTT.cpython-37.pyc
index d44fc12..fcedf97 100644
Binary files a/__pycache__/dataHandlerPTT.cpython-37.pyc and b/__pycache__/dataHandlerPTT.cpython-37.pyc differ
diff --git a/app.py b/app.py
index af48a53..0502f74 100755
--- a/app.py
+++ b/app.py
@@ -67,7 +67,7 @@ def ptt_push():
@app.route('/ptt_push/init', methods=['POST'])
def pttPushInit():
- author = 'yuetsu'
+ author = 'a58461351'
pushes = pttPush.findAuthorPush(
author=[author], stopwords=pttPush.defaultStopWords)
result: dict = {
diff --git a/dataHandlerPTT.py b/dataHandlerPTT.py
index 3c0a5d4..0b62c86 100755
--- a/dataHandlerPTT.py
+++ b/dataHandlerPTT.py
@@ -31,6 +31,8 @@ with open('/home/vis/pttDatabase/PTTData/Gossiping/content/content.pck', 'rb') a
defaultStopWords = []
data = PTTData('Gossiping', '/home/vis/pttDatabase/PTTData')
+sentence_length = 100
+use_push_count = False
with open('resource/stopWords.txt', 'r', encoding='UTF-8') as file:
for word in file.readlines():
@@ -75,7 +77,7 @@ def contentProcess(content, text):
result = []
for i in cutted:
result.append(i)
- if (len(result) >= 50):
+ if (len(result) >= sentence_length):
sentenses.append(result.copy())
result = []
if (result != []):
@@ -324,7 +326,7 @@ def getDefault(startDate, endDate):
'date': datetime.strptime(i['date'], '%Y%m%d%H%M%S').strftime("%a %b %d %H:%M:%S %Y"),
'part': i['content'][max(0, cut[0] - 20): min(len(i['content']), cut[1])].replace('\n', '')
}
- result.append([len(result), seq, 1000 + i['pushes']])
+ result.append([len(result), seq, (1000 + i['pushes'])if use_push_count else 3000])
fileString = io.StringIO()
writer = csv.writer(fileString, delimiter='\t')
diff --git a/resource/stopWords.txt b/resource/stopWords.txt
index 9aef6c5..4b61f5a 100755
--- a/resource/stopWords.txt
+++ b/resource/stopWords.txt
@@ -67,4 +67,9 @@
那
只
所以
-講
\ No newline at end of file
+講
+記者
+看
+者
+媒體
+和
\ No newline at end of file
diff --git a/static/css/main.css b/static/css/main.css
index 3480344..b38b365 100755
--- a/static/css/main.css
+++ b/static/css/main.css
@@ -112,6 +112,24 @@ html {
transition-duration: 0.5s;
}
+#pttPageWindowContent {
+ display: block;
+ position: fixed;
+ background-color: #FFF;
+ left: 50%;
+ top: 50%;
+ transform: translate(-50%, -50%);
+ width: 90%;
+ height: 90%;
+ border: lightgray;
+ border-width: 1px;
+ border-style: solid;
+ border-radius: 20px;
+ padding: 26px;
+ z-index: 99;
+ box-shadow: 0px 5px 20px rgba(0, 0, 0, .3);
+}
+
.deleteListElement {
position: absolute;
right: 0;
@@ -141,6 +159,18 @@ li a {
}
.info {
+ background-color: rgba(255, 255, 255, 0.6);
+ animation: fadeIn 0.2s;
+ animation-fill-mode: forwards;
+ position: fixed;
+ display: flex;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ z-index: 90;
+}
+
+.info99 {
background-color: rgba(255, 255, 255, 0.6);
animation: fadeIn 0.2s;
animation-fill-mode: forwards;
@@ -189,7 +219,7 @@ li a {
height: auto;
border-radius: 15px;
padding: 10px 15px;
- z-index: 99;
+ z-index: 90;
align-content: center;
}
diff --git a/static/js/ptt.js b/static/js/ptt.js
index 3379fad..235a60d 100755
--- a/static/js/ptt.js
+++ b/static/js/ptt.js
@@ -76,7 +76,41 @@ function init() {
hideIdfEditor()
}
})
+ $('#pttPageWindow').click(function(e) {
+ if ($('#pttPageWindow').is(e.target)) {
+ hidePTTPage()
+ }
+ })
changeMode(0)
+ destroyCurrentGraph()
+ buildSentetree()
+}
+
+function loadTemplate(num) {
+ templates = [{
+ startDate: '2020-12-01',
+ endDate: '2020-12-31',
+ keyword: '',
+ mode: 1
+ },
+ {
+ startDate: '2020-01-01',
+ endDate: '2020-03-01',
+ keyword: '衛生紙',
+ mode: 2
+ },
+ {
+ startDate: '2020-01-11',
+ endDate: '2020-01-12',
+ keyword: '',
+ mode: 2
+ }
+ ]
+ chosenTemp = templates[num]
+ setDate(chosenTemp.startDate, chosenTemp.endDate)
+ $('#keywordBox').val(chosenTemp.keyword)
+ changeMode(chosenTemp.mode)
+ sendRequest()
}
function clearStopWord() {
@@ -117,8 +151,6 @@ function changeMode(_mode) {
}
}
mode = _mode
- destroyCurrentGraph()
- buildSentetree()
}
function scrollIdfList() {
@@ -170,8 +202,12 @@ function showIdfEditor() {
.append($('
')
.attr('style', 'position: sticky; top: 0; background: white;')
.append('單詞'))
- .append($(' | '))
- .append($(' | ').attr('class', 'w3-right-align')
+ .append($(' | ')
+ .attr('class', 'w3-center-align')
+ .attr('style', 'position: sticky; top: 0; background: white;')
+ .append('操作'))
+ .append($(' | ')
+ .attr('class', 'w3-right-align')
.attr('style', 'position: sticky; top: 0; background: white;')
.append('單詞頻率')
)
@@ -259,6 +295,15 @@ function hideIdfEditor() {
$('#idfEditorLayer').addClass('hidden')
}
+function showPTTPage(url) {
+ $('#pttPageWindowContent iframe').attr('src', url)
+ $('#pttPageWindow').removeClass('hidden')
+}
+
+function hidePTTPage() {
+ $('#pttPageWindow').addClass('hidden')
+}
+
function updateIdfTable() {
let wordList = $("#ieContainer").find("tr").slice(1).map((_, a) => {
return [
@@ -315,6 +360,23 @@ function closeEventListner() {
}
function sendRequest() {
+ content = getContent()
+ startDate = $('#startDate').val()
+ endDate = $('#endDate').val()
+ console.log(content)
+ $.ajax({
+ type: 'POST',
+ url: '/addRequest',
+ data: content,
+ contentType: 'application/json',
+ success: function(data) {
+ console.log(data)
+ changeGraph(data.Result)
+ }
+ })
+}
+
+function getContent() {
content = JSON.stringify({
startDate: $('#startDate').val(),
endDate: $('#endDate').val(),
@@ -330,19 +392,7 @@ function sendRequest() {
other: $('#other').is(':checked')
}
})
- startDate = $('#startDate').val()
- endDate = $('#endDate').val()
- console.log(content)
- $.ajax({
- type: 'POST',
- url: '/addRequest',
- data: content,
- contentType: 'application/json',
- success: function(data) {
- console.log(data)
- changeGraph(data.Result)
- }
- })
+ return content
}
function changeGraph(data) {
@@ -466,8 +516,9 @@ function buildSentetree() {
$('#titleListContainer').empty()
for (i of titleList) {
$('#titleListContainer').append(
- $('').attr('class', 'w3-panel').append(
- $('').attr('href', i.url).attr('target', '_blank').append(
+ $('').attr('class', 'w3-panel')
+ .css('cursor', 'pointer').append(
+ $(' ').attr('target', '_blank').append(
$(' ').html(i.title)
).append(
$('').attr('style', 'margin: 0px 10px').html(i.author)
@@ -476,7 +527,10 @@ function buildSentetree() {
).append(
$('').attr('style', 'margin: 0px 10px').html('推文數:' + i.pushes)
)
- )
+ ).click(function() {
+ let indx = $(this).index()
+ showPTTPage((titleList[indx].url).replace('www.ptt.cc', 'www.pttweb.cc'))
+ })
)
}
})
diff --git a/static/js/pttPush.js b/static/js/pttPush.js
index 27ec55e..b5922dd 100644
--- a/static/js/pttPush.js
+++ b/static/js/pttPush.js
@@ -25,6 +25,7 @@ function init() {
console.log(wordPushList)
$('#idBox').val(data.Result.author)
buildSentetree(tsvString)
+ changeMode(2)
}
})
$(document).ready(function() {
@@ -66,6 +67,31 @@ function init() {
})
}
+function loadTemplate(num) {
+ templates = [{
+ userId: '',
+ aid: '1Vv4iFY6',
+ keyword: '',
+ mode: 0,
+ }, {
+ userId: '',
+ aid: '1VyJ2vP_',
+ keyword: '',
+ mode: 0
+ }, {
+ userId: 'xetherz3',
+ aid: '',
+ keyword: '',
+ mode: 0
+ }]
+ let chosenTemplate = templates[num]
+ $('#idBox').val(chosenTemplate.userId)
+ $('#titleBox').val(chosenTemplate.aid)
+ $('#keywordBox').val(chosenTemplate.keyword)
+ changeMode(0)
+ sendRequest()
+}
+
function clearStopWord() {
stopwords = []
$('#sweContainer').html('')
@@ -138,7 +164,10 @@ function showIdfEditor() {
.append($('')
.attr('style', 'position: sticky; top: 0; background: white;')
.append('單詞'))
- .append($(' | '))
+ .append($(' | ')
+ .attr('class', 'w3-center-align')
+ .attr('style', 'position: sticky; top: 0; background: white;')
+ .append('操作'))
.append($(' | ').attr('class', 'w3-right-align')
.attr('style', 'position: sticky; top: 0; background: white;')
.append('單詞頻率')
diff --git a/static/node_modules/sententree/dist/sententree-standalone.js b/static/node_modules/sententree/dist/sententree-standalone.js
index 00cc1b9..33b4503 100755
--- a/static/node_modules/sententree/dist/sententree-standalone.js
+++ b/static/node_modules/sententree/dist/sententree-standalone.js
@@ -19158,7 +19158,7 @@
maxc = value
}
} else {
- if (value < maxSupport && (value * Math.pow(distRatio, dist - 1)) > maxc && stopwords.indexOf(itemset[w]) < 0 && dist == 1) {
+ if (value < maxSupport && value > maxc && dist < 2 && stopwords.indexOf(itemset[w]) < 0 && dist == 1) {
maxw = +w
maxc = value
console.log(maxc)
diff --git a/templates/generalTxt.html b/templates/generalTxt.html
index 1915636..7c65940 100644
--- a/templates/generalTxt.html
+++ b/templates/generalTxt.html
@@ -41,7 +41,8 @@
-
+
diff --git a/templates/ptt.html b/templates/ptt.html
index 1e31493..78a09f6 100755
--- a/templates/ptt.html
+++ b/templates/ptt.html
@@ -15,6 +15,11 @@
+
@@ -66,17 +71,19 @@
diff --git a/templates/ptt_push.html b/templates/ptt_push.html
index 3639d19..73de566 100644
--- a/templates/ptt_push.html
+++ b/templates/ptt_push.html
@@ -67,6 +67,12 @@
SentenTree https://github.com/twitter/SentenTree
+ 可直接從下方範例搜尋條件中選擇
+
+
+
+
+
| |