diff --git a/VANA-php/resources/css/app.css b/VANA-php/resources/css/app.css index 321b444..8c15ff0 100644 --- a/VANA-php/resources/css/app.css +++ b/VANA-php/resources/css/app.css @@ -238,6 +238,10 @@ main { gap: 1em; } +ol{ + padding-left: 1em +} + #video { grid-area: video; } @@ -343,3 +347,30 @@ ul.segments li{ .track-viz svg{ width: 100% !important; } + +#sentiments-list{ + list-style: none; + padding: 0; +} + +#sentiments-list li{ + margin-top: .5em; +} + +#sentiments-list span{ + display: inline-block; + background: #d01c8b; + width: 1.5em; + height: 1.5em; + border-radius: 50%; + text-align: center; +} + +#sentiments-list span.pos{ + background: #4dac26; +} + +#sentiments-list span.neut{ + background: #f7f7f7; + color: #000; +} diff --git a/VANA-php/resources/js/app.js b/VANA-php/resources/js/app.js index 90e6b56..b3ce73a 100644 --- a/VANA-php/resources/js/app.js +++ b/VANA-php/resources/js/app.js @@ -47,6 +47,8 @@ function setWordCountChart(){ // let max = totalWordCount / count; let data = []; + + let wordWordsLen = wordWords.length; let chunks = Math.floor(wordWordsLen / count); @@ -69,8 +71,6 @@ function setWordCountChart(){ } }) - console.log(max) - for(let i = 0; i < count; i++){ grid.push({ left: `${i * (100 / count)}%`, @@ -170,12 +170,22 @@ const chartSentimentsOptions = { type: "category", data: ["-1", "0", "1"] }, - color: '#fff', series: [ { symbolSize: sentiWeights, data: sentiPol, - type: 'scatter' + type: 'scatter', + itemStyle: { + color: (e) => { + if(e.data == -1){ + return '#d01c8b' + }else if(e.data == 0){ + return '#f7f7f7' + }else{ + return '#4dac26' + } + } + } } ] }; @@ -288,40 +298,5 @@ document.querySelector('#timeline-bar').addEventListener('click', e => { player.currentTime(calcCurrenttimeByPosition(x)); }) */ -const topics = [ - ["Topic1 Topic2 Topic3"], - ["Topic1 Topic2 Topic3", "Topic3 Topic4 Topic5"], - ["Topic1 Topic2 Topic3", "Topic3 Topic4 Topic5", "Topic6 Topic7 Topic8"], - ["Topic1 Topic2 Topic3", "Topic3 Topic4 Topic5", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3"], - ["Topic1 Topic2 Topic3", "Topic3 Topic4 Topic5", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3"], - ["Topic1 Topic2 Topic3", "Topic3 Topic4 Topic5", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3"], - ["Topic1 Topic2 Topic3", "Topic3 Topic4 Topic5", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3"], - ["Topic1 Topic2 Topic3", "Topic3 Topic4 Topic5", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3"], - ["Topic1 Topic2 Topic3", "Topic3 Topic4 Topic5", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3"], - ["Topic1 Topic2 Topic3", "Topic3 Topic4 Topic5", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3", "Topic1 Topic2 Topic3"], -]; - -function setTopicSegments(count){ - - let html = ''; - - topics[count - 1].forEach(t => { - html += `
  • ${t}
  • `; - }) - - let list = document.querySelector('#topic-segement-list'); - list.innerHTML = html; - list.style.gridTemplate = `1fr / repeat(${count}, 1fr)`; - -} -let topicSegmentCtrl = document.getElementById('topic-track-segment-ctrl'); - -topicSegmentCtrl.addEventListener('change', e => { - setTopicSegments(e.target.value); - -}) - -setTopicSegments(topicSegmentCtrl.value); - diff --git a/VANA-php/resources/views/detail.blade.php b/VANA-php/resources/views/detail.blade.php index 5ed17f4..1986e02 100644 --- a/VANA-php/resources/views/detail.blade.php +++ b/VANA-php/resources/views/detail.blade.php @@ -31,7 +31,7 @@
    + Topics
    @@ -69,9 +69,15 @@
    @@ -109,27 +115,13 @@

    Sentiment

    -

    1 = Positiv
    0 = Neutral
    -1 = Negativ

    +
    -
    -
    -

    Topics

    - -
    -
    - -
    -
    diff --git a/VANA-php/routes/web.php b/VANA-php/routes/web.php index ac3b8a8..1986db9 100644 --- a/VANA-php/routes/web.php +++ b/VANA-php/routes/web.php @@ -23,23 +23,40 @@ Route::get('/detail/{id}', function(int $id) { $subtitles = $ep->subtitles; $mediacomposition = json_decode($ep->mediacomposition, 1); $durationSteps = $mediacomposition['chapterList'][0]['duration'] / 1000 / 10; + $topics = json_decode($ep->topics); $subdata = json_decode($ep->subtitle_data, 1); $subdata_senti = json_decode($ep->sentiments_from_sub, 1); + $subdata_senti['data'] = ""; $subdata_senti['weights'] = ""; + $subdata_senti['verteilung'] = ['neutral' => 0, 'negative' => 0, 'positive' => 0]; + foreach ($subdata_senti['sentiments'] as $value) { $subdata_senti['data'] .= $value[0].","; - $subdata_senti['weights'] .= (30 * $value[1]).","; + $subdata_senti['weights'] .= (50 * $value[1]).","; + if($value[0] === 0){ + $subdata_senti['verteilung']['neutral']++; + }else if($value[0] === 1){ + $subdata_senti['verteilung']['positive']++; + }else{ + $subdata_senti['verteilung']['negative']++; + } } + $subdata_senti_all = $subdata_senti['verteilung']['neutral'] + $subdata_senti['verteilung']['negative'] + $subdata_senti['verteilung']['positive']; + + $subdata_senti['verteilung_perc'] = ['negative' => (100 / $subdata_senti_all) * $subdata_senti['verteilung']['negative'], 'neutral' => (100 / $subdata_senti_all) * $subdata_senti['verteilung']['neutral'], 'positive' => (100 / $subdata_senti_all) * $subdata_senti['verteilung']['positive']]; + + $wordsPerMinute = array_slice($subdata['word_count'], -1)[0] / (($mediacomposition['chapterList'][0]['duration'] / 1000) / 60); $parser = new Podlove\Webvtt\Parser(); $subtitles = $parser->parse($subtitles); - return view('detail', ['title' => $title, 'subtitles' => $subtitles, 'mediacomposition' => $mediacomposition, 'durationSteps' => $durationSteps, 'dom_color' => $ep->viz_data, 'subdata' => $subdata, 'senti_subdata' => $subdata_senti, 'wpm' => $wordsPerMinute]); + + return view('detail', ['title' => $title, 'subtitles' => $subtitles, 'mediacomposition' => $mediacomposition, 'durationSteps' => $durationSteps, 'dom_color' => $ep->viz_data, 'subdata' => $subdata, 'senti_subdata' => $subdata_senti, 'wpm' => $wordsPerMinute, 'topics' => $topics]); }); diff --git a/VANA-python/subtitles_processing/README.md b/VANA-python/subtitles_processing/README.md index ece58c9..c1a57f7 100644 --- a/VANA-python/subtitles_processing/README.md +++ b/VANA-python/subtitles_processing/README.md @@ -14,8 +14,14 @@ Zählt die Wortanzahl pro Satz. python src/normalize_subtitles/count_words.py -ep ``` -## count_words.py +## sentence_sentiment.py Rechnet die Sentimente pro Satz. ```bash python src/normalize_subtitles/sentence_sentiment.py -ep ``` + +## topics.py +Generiert Topics mittels LDA. +```bash +python src/normalize_subtitles/topics.py -ep +``` diff --git a/database.sqlite b/database.sqlite index 446ef79..995f457 100644 Binary files a/database.sqlite and b/database.sqlite differ