diff --git a/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.html b/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.html new file mode 100644 index 0000000000000000000000000000000000000000..b2e6481ef20a02e3682aa44fa6cf83b010319aef --- /dev/null +++ b/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.html @@ -0,0 +1,9 @@ +<h1 mat-dialog-title>Spacy</h1> +<div mat-dialog-content> + <p>{{ 'spacy-dialog.spacyQ' | translate }}</p> +</div> +<div mat-dialog-actions> + <!-- <button mat-button (click)="testInput()">{{ 'spacy-dialog.no-thanks' | translate }}</button> --> + <button mat-button>{{ 'spacy-dialog.no-thanks' | translate }}</button> + <button mat-button>Ok</button> +</div> diff --git a/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.scss b/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..d795fb287789cde71d15807311ee8d34c1c79a17 --- /dev/null +++ b/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.scss @@ -0,0 +1,93 @@ +button { + min-width: 80px; +} + +form { + display: block; + width: 100%; + max-width: 800px; + margin-bottom: 50px; +} + +app-comment-list { + width: 100%; + max-width: 800px; +} + +textarea { + line-height: 120%; + color: var(--on-surface); + caret-color: var(--on-surface); +} + +.send { + color: var(--on-primary); + background-color: var(--primary); +} + +mat-hint { + color: var(--on-surface) !important; +} + +.mat-select-value-text { + color: var(--on-surface); + caret-color: var(--on-surface); +} + +.placeholder { + color: var(--on-surface); +} + +.tag-form-field{ + @media screen and (max-width:500px) { + width:70px; + } + z-index:10000; +} + +.tag-select{ +} + +.anchor-right{ + @media screen and (max-width:500px) { + width:70px; + left:calc( 100% - 70px ); + } + width:200px; + height:50px; + position:relative; + left:calc( 100% - 200px ); + top:0; +} + +.anchor-wrp{ + width:100%; + height:0; + position:relative; + left:0; + top:0; +} + +::ng-deep .mat-form-field-label { + color: var(--on-surface)!important; +} + +::ng-deep .mat-form-field-underline { + background-color: var(--on-surface)!important; +} + +::ng-deep .mat-form-field-ripple { + background-color: var(--on-surface)!important; +} + +::ng-deep .mat-select-arrow-wrapper .mat-select-arrow { + color: var(--on-surface); +} + +::ng-deep .mat-select-value-text { + color: var(--on-surface); +} + +::ng-deep .mat-primary .mat-option.mat-selected:not(.mat-option-disabled) { + color: var(--primary); +} diff --git a/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.spec.ts b/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..3f5cd69642c4f5d99d2d5ef62af3c9607ee7cde7 --- /dev/null +++ b/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SpacyDialogComponent } from './spacy-dialog.component'; + +describe('SpacyDialogComponent', () => { + let component: SpacyDialogComponent; + let fixture: ComponentFixture<SpacyDialogComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ SpacyDialogComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(SpacyDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.ts b/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..b34d37f7448fe4728cb130cb0fe9ce5540ea2f57 --- /dev/null +++ b/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.ts @@ -0,0 +1,44 @@ +import { Component, OnInit } from '@angular/core'; +import { TranslateService } from '@ngx-translate/core'; +import { LanguageService } from '../../../../services/util/language.service'; +import { HttpClient } from '@angular/common/http'; + +@Component({ + selector: 'app-spacy-dialog', + templateUrl: './spacy-dialog.component.html', + styleUrls: ['./spacy-dialog.component.scss'] +}) +export class SpacyDialogComponent implements OnInit { + + constructor(private translateService: TranslateService, protected langService: LanguageService, private client: HttpClient) { + langService.langEmitter.subscribe(lang => translateService.use(lang)); + } + + ngOnInit(): void { + } + + /* + testInput(): void { + console.log(this.evalInput('Wieviel Aufgaben gibt es in der Klausur?', 'de')); + } + */ + + evalInput(input: string, model: string): string[] { + const filterTag = 'N'; + let spacyData: any = []; + const words: string[] = []; + const body = '{"text": "' + input + '", "model": "' + model + '"}'; + this.client.post('https://spacy.frag.jetzt/dep', body).subscribe(data => { + spacyData = data; + // filter for tags in words (all Nouns) + for ( const word of spacyData.words ) { + // N at first pos = all Nouns(NN de/en) including singular(NN, NNP en), plural (NNPS, NNS en), proper Noun(NNE, NE de) + if (word.tag.charAt(0).includes(filterTag)) { + words.push(word.text); + } + } + }); + return words; + } + +}