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 index 2d2755d43f564dded9abe3b2a066a3fe3f4c5030..cfcad0b481eaf935b4b2aa7ceb4fa586119e6c3c 100644 --- a/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.ts +++ b/src/app/components/shared/_dialogs/spacy-dialog/spacy-dialog.component.ts @@ -23,6 +23,7 @@ export class SpacyDialogComponent implements OnInit, AfterContentInit { comment: Comment; commentLang: Model; commentBodyChecked: string; + spacyKeywords: string[] = []; keywords: Keyword[] = []; constructor( @@ -51,7 +52,8 @@ export class SpacyDialogComponent implements OnInit, AfterContentInit { buildCreateCommentActionCallback() { return () => { - this.comment.keywords = this.keywords.filter(kw => kw.selected).map(kw => kw.word); + this.comment.keywordsFromQuestioner = this.keywords.filter(kw => kw.selected).map(kw => kw.word); + this.comment.keywordsFromSpacy = this.spacyKeywords; this.dialogRef.close(this.comment); }; } @@ -61,8 +63,10 @@ export class SpacyDialogComponent implements OnInit, AfterContentInit { // N at first pos = all Nouns(NN de/en) including singular(NN, NNP en), plural (NNPS, NNS en), proper Noun(NNE, NE de) this.spacyService.analyse(this.commentBodyChecked, model) .subscribe(res => { - for(const word of res.words) { + this.spacyKeywords.length = 0; + for (const word of res.words) { if (word.tag.charAt(0) === 'N') { + this.spacyKeywords.push(word.text); words.push({ word: word.text, completed: false, @@ -73,6 +77,7 @@ export class SpacyDialogComponent implements OnInit, AfterContentInit { } this.keywords = words; }, () => { + this.spacyKeywords = []; this.keywords = []; }); } diff --git a/src/app/components/shared/comment/comment.component.html b/src/app/components/shared/comment/comment.component.html index 6a509b76846379d666f6f38c5d6acea5a62b76cc..f64383ad8be785425e53d38469d15abf19673ddb 100644 --- a/src/app/components/shared/comment/comment.component.html +++ b/src/app/components/shared/comment/comment.component.html @@ -320,16 +320,16 @@ <div fxLayoutAlign="center center" matTooltip="{{ 'comment-page.keywords-per-question' | translate }}" [mat-menu-trigger-for]="keywordsMenu" - *ngIf="(comment.keywords != undefined && comment.keywords.length > 0)" + *ngIf="(comment.keywordsFromQuestioner != undefined && comment.keywordsFromQuestioner.length > 0)" class="comment-keywords"> <mat-icon svgIcon="comment_tag"></mat-icon> <span> {{ 'comment-page.keywords' | translate }} </span> <mat-menu #keywordsMenu> - + <mat-list dense class="keywords-list"> - <mat-list-item *ngFor="let keyword of comment.keywords; let odd = odd; let even = even" + <mat-list-item *ngFor="let keyword of comment.keywordsFromQuestioner; let odd = odd; let even = even" [class.keywords-alternate]="odd" [class.keywords-even]="even"> <span class="keyword-span">{{keyword}}</span> diff --git a/src/app/components/shared/tag-cloud/tag-cloud.data-manager.ts b/src/app/components/shared/tag-cloud/tag-cloud.data-manager.ts index 79ebcc754954ed89cf5588130404db354de193e0..90ac54d32b5655c4623a8b92be4b8cdad29ad988 100644 --- a/src/app/components/shared/tag-cloud/tag-cloud.data-manager.ts +++ b/src/app/components/shared/tag-cloud/tag-cloud.data-manager.ts @@ -205,7 +205,6 @@ export class TagCloudDataManager { return; } let newData: TagCloudData; - //TODO SORT if (this._isAlphabeticallySorted) { newData = new Map<string, TagCloudDataTagEntry>([...current] .sort(([aTag], [bTag]) => aTag.localeCompare(bTag))); @@ -213,7 +212,6 @@ export class TagCloudDataManager { newData = new Map<string, TagCloudDataTagEntry>([...current] .sort(([_, aTagData], [__, bTagData]) => bTagData.weight - aTagData.weight)); } - //TODO APPLY OTHER this._dataBus.next(newData); } @@ -252,10 +250,19 @@ export class TagCloudDataManager { const data: TagCloudData = new Map<string, TagCloudDataTagEntry>(); const users = new Set<number>(); for (const comment of this._lastFetchedComments) { - //TODO Check supply types - let keywords = comment.keywords || []; + let keywords = comment.keywordsFromQuestioner; + if (this._supplyType === TagCloudDataSupplyType.keywordsAndFullText) { + if (!keywords || !keywords.length) { + keywords = comment.keywordsFromSpacy; + } + } else if (this._supplyType === TagCloudDataSupplyType.fullText) { + keywords = comment.keywordsFromSpacy; + } + if (!keywords) { + keywords = []; + } for (const keyword of keywords) { - //TODO Check spelling + //TODO Check spelling & check profanity let current = data.get(keyword); if (current === undefined) { current = {cachedVoteCount: 0, comments: [], weight: 0, adjustedWeight: 0}; diff --git a/src/app/models/comment.ts b/src/app/models/comment.ts index 1d488d077c1638391e1b98accac44441fe1eb5c0..2c00741a2d8fcf731699596822cea5716a524ebc 100644 --- a/src/app/models/comment.ts +++ b/src/app/models/comment.ts @@ -20,7 +20,8 @@ export class Comment { answer: string; userNumber: number; number: number; - keywords: string[]; + keywordsFromQuestioner: string[]; + keywordsFromSpacy: string[]; constructor(roomId: string = '', creatorId: string = '', @@ -37,7 +38,8 @@ export class Comment { tag: string = '', answer: string = '', userNumber: number = 0, - keywords: string[] = []) { + keywordsFromQuestioner: string[] = [], + keywordsFromSpacy: string[] = []) { this.id = ''; this.roomId = roomId; this.creatorId = creatorId; @@ -55,6 +57,7 @@ export class Comment { this.tag = tag; this.answer = answer; this.userNumber = userNumber; - this.keywords = keywords; + this.keywordsFromQuestioner = keywordsFromQuestioner; + this.keywordsFromSpacy = keywordsFromSpacy; } } diff --git a/src/app/services/http/comment.service.ts b/src/app/services/http/comment.service.ts index 66ab1d529173dc3a6a5109e0bceba6970de095f3..d379615bf8df7dcb98690ce87c75257916c87929 100644 --- a/src/app/services/http/comment.service.ts +++ b/src/app/services/http/comment.service.ts @@ -83,7 +83,9 @@ export class CommentService extends BaseHttpService { return this.http.post<Comment>(connectionUrl, { roomId: comment.roomId, body: comment.body, - read: comment.read, creationTimestamp: comment.timestamp, tag: comment.tag, keywords: JSON.stringify(comment.keywords) + read: comment.read, creationTimestamp: comment.timestamp, tag: comment.tag, + keywordsFromSpacy: JSON.stringify(comment.keywordsFromSpacy), + keywordsFromQuestioner: JSON.stringify(comment.keywordsFromQuestioner) }, httpOptions).pipe( tap(_ => ''), catchError(this.handleError<Comment>('addComment')) @@ -111,8 +113,11 @@ export class CommentService extends BaseHttpService { map(commentList => { return commentList.map(comment => { const newComment = this.parseUserNumber(comment); + console.log(comment); // @ts-ignore - newComment.keywords = JSON.parse(newComment.keywords as string); + newComment.keywordsFromQuestioner = JSON.parse(newComment.keywordsFromQuestioner as string); + // @ts-ignore + newComment.keywordsFromSpacy = JSON.parse(newComment.keywordsFromSpacy as string); return newComment; }); }),