This commit is contained in:
szymonj98 2023-06-10 15:00:46 +02:00
parent 8c42d9e380
commit 44ee7aa796
5 changed files with 56 additions and 15 deletions

View File

@ -6,7 +6,7 @@
<div class="text">Ola G cos tu se wpiszesz albo nie xD</div>
<div class="ready-examples-button">
<button (click)="analyzeSentiment(true)" class="button-primary irony-btn">Wyolsuj gotowe przykłady</button>
<button (click)="analyzeIrony(true)" class="button-primary irony-btn">Wyolsuj gotowe przykłady</button>
</div>
<div class="form-container">
<div class="form">
@ -22,13 +22,23 @@
</div>
<div class="button-container">
<button (click)="duplicateField()" class="button-primary irony-btn">Dodaj pole</button>
<button [disabled]="!sentimentForm.valid" (click)="analyzeSentiment(false)"
<button [disabled]="!sentimentForm.valid" (click)="analyzeIrony(false)"
class="button-primary irony-btn">Analizuj tekst</button>
</div>
</div>
<div class="results-table" *ngIf="analysisStart">
<ng-container *ngIf="analysisLoading; else loading">
<ng-container *ngIf="!error; else errorTemplate">
<div *ngFor="let res of analysisResults">
<div class="result-row">
<div class="sentence">{{res.sentence}}</div>
<div [ngSwitch]="res.label">
<div class="label-0" *ngSwitchCase="0">Brak ironii</div>
<div class="label-1" *ngSwitchCase="1">Ironia</div>
</div>
</div>
</div>
</ng-container>
</ng-container>
</div>
</div>
@ -37,3 +47,6 @@
<ng-template #loading>
<div class="spinner"><mat-spinner></mat-spinner></div>
</ng-template>
<ng-template #errorTemplate>
<div class="spinner error">Wystąpił nieoczekiwany błąd.</div>
</ng-template>

View File

@ -41,6 +41,7 @@
justify-content: space-between;
border-bottom: 1px solid grey;
padding-top: 15px;
column-gap: 15px;
}
.results-container {
@ -49,16 +50,15 @@
}
.label-0 {
color: rgb(255, 66, 66)
color: rgb(126, 126, 126);
min-width:75px;
}
.label-1 {
color: rgb(84, 84, 255)
color: rgb(134, 2, 164);
font-weight:600;
}
.label-2 {
color: rgb(196, 196, 196)
}
.chart {
padding-top: 30px;
@ -104,3 +104,7 @@
background-repeat: no-repeat;
}
}
.error {
color: white
}

View File

@ -3,18 +3,27 @@ import { Component, OnInit } from '@angular/core';
import { FormGroup, Validators, FormBuilder, FormArray } from '@angular/forms';
import { Router } from '@angular/router';
import { ChartConfiguration, ChartOptions, ChartType } from 'chart.js';
import { environment } from 'src/environments/environment';
@Component({
selector: 'app-irony-analysis',
templateUrl: './irony-analysis.component.html',
styleUrls: ['./irony-analysis.component.scss']
selector: 'app-irony-analysis',
templateUrl: './irony-analysis.component.html',
styleUrls: ['./irony-analysis.component.scss']
})
export class IronyAnalysisComponent implements OnInit {
randomSampleList = []
randomSampleList = [
'testowy przyklad',
'testowy przyklad',
'testowy przyklad',
'testowy przyklad',
'testowy przyklad',
]
analysisStart = false;
analysisLoading = false;
analysisResults: { label: number, score: number, sentence: string }[] = [];
error = false;
sentimentForm: FormGroup = this.fb.group({
@ -41,7 +50,8 @@ export class IronyAnalysisComponent implements OnInit {
}
analyzeSentiment(isRandomSample: boolean) {
analyzeIrony(isRandomSample: boolean) {
this.error = false
this.analysisStart = true
this.analysisLoading = false
let sentences = []
@ -52,6 +62,18 @@ export class IronyAnalysisComponent implements OnInit {
let value = this.sentimentForm.value
sentences = value.sentences.map((value: any) => value.text)
}
this.http.post(environment.irony, { sentences: sentences }).subscribe({
next: (resp: any) => {
console.log(resp)
this.analysisLoading = true;
this.analysisResults = resp.predictions;
},
error: () => {
this.analysisLoading = true
this.error = true
console.log('error')
}
})
}

View File

@ -2,6 +2,7 @@ export const environment = {
production: true,
sentiment: 'https://magisterka-backend.azurewebsites.net/get_sentiment_data',
errors: 'https://magisterka-backend.azurewebsites.net/get_errors',
facebook: 'https://magisterka-backend.azurewebsites.net/scrapp_comments'
facebook: 'https://magisterka-backend.azurewebsites.net/scrapp_comments',
irony: 'https://magisterka-backend.azurewebsites.net/get_irony_data'
};

View File

@ -6,7 +6,8 @@ export const environment = {
production: false,
sentiment: 'http://127.0.0.1:5000/get_sentiment_data',
errors: 'http://127.0.0.1:5000/get_errors',
facebook: 'http://127.0.0.1:5000/scrapp_comments'
facebook: 'http://127.0.0.1:5000/scrapp_comments',
irony: 'http://127.0.0.1:5000/get_irony_data'
};
/*