Skip to content
Snippets Groups Projects
Commit 691462ab authored by Philipp Sautner's avatar Philipp Sautner
Browse files

Merge branch 'tag-cloud' into 'staging'

Merge 'tag-cloud' into 'staging'

See merge request arsnova/topic-cloud!81
parents a9bd65ce 46af03a9
No related merge requests found
......@@ -293,29 +293,20 @@
<mat-icon>close</mat-icon>
</button>
</mat-form-field>
<table class="themeRequirementInput">
<tr>
<td>
<mat-form-field class="themeRequirementInput" appearance="fill">
<mat-label>{{'topic-cloud-dialog.topic-requirement-begin-datetime' | translate}}</mat-label>
<input matInput type="datetime-local" [(ngModel)]="startDate">
<button *ngIf="startDate" matSuffix mat-icon-button aria-label="Clear" (click)="startDate=''">
<mat-icon>close</mat-icon>
</button>
</mat-form-field>
</td>
<td>
<mat-form-field class="themeRequirementInput" appearance="fill">
<mat-label>{{'topic-cloud-dialog.topic-requirement-end-datetime' | translate}}</mat-label>
<input matInput type="datetime-local" [(ngModel)]="endDate">
<button *ngIf="endDate" matSuffix mat-icon-button aria-label="Clear" (click)="endDate=''">
<mat-icon>close</mat-icon>
</button>
</mat-form-field>
</td>
</tr>
</table>
<mat-form-field class="themeRequirementInput" appearance="fill">
<mat-label>{{'topic-cloud-dialog.topic-requirement-begin-datetime' | translate}}</mat-label>
<input matInput type="datetime-local" [(ngModel)]="startDate">
<button *ngIf="startDate" matSuffix mat-icon-button aria-label="Clear" (click)="startDate=''">
<mat-icon>close</mat-icon>
</button>
</mat-form-field>
<mat-form-field class="themeRequirementInput" appearance="fill">
<mat-label>{{'topic-cloud-dialog.topic-requirement-end-datetime' | translate}}</mat-label>
<input matInput type="datetime-local" [(ngModel)]="endDate">
<button *ngIf="endDate" matSuffix mat-icon-button aria-label="Clear" (click)="endDate=''">
<mat-icon>close</mat-icon>
</button>
</mat-form-field>
</mat-expansion-panel>
</mat-accordion>
......
......@@ -4,6 +4,7 @@ import { Observable } from 'rxjs';
import { BaseHttpService } from './base-http.service';
import { catchError, map, tap } from 'rxjs/operators';
import { TopicCloudAdminService } from '../util/topic-cloud-admin.service';
import { CreateCommentKeywords } from '../../utils/create-comment-keywords';
export type Model = 'de' | 'en' | 'fr' | 'es' | 'it' | 'nl' | 'pt' | 'auto';
......@@ -183,7 +184,9 @@ export class SpacyService extends BaseHttpService {
.pipe(
tap(_ => ''),
catchError(this.handleError<any>('getKeywords')),
map((elem: KeywordList) => wanted != null ? elem.filter(e => wanted.includes(e.dep)) : elem),
map((elem: KeywordList) => wanted != null ?
elem.filter(e => wanted.includes(e.dep) && CreateCommentKeywords.isKeywordAcceptable(e.lemma)) :
elem),
map((result: KeywordList) => [...new Set(result.map(e => e.lemma.trim()))])
);
}
......
......@@ -3,6 +3,11 @@ import { map } from 'rxjs/operators';
export class CreateCommentKeywords {
static isKeywordAcceptable(keyword: string) {
const regex = /(^[ -@\[-`{-~]+$)/g;
return keyword.match(regex) === null;
}
static isSpellingAcceptable(languagetoolService: LanguagetoolService, text: string, language: Language = 'auto') {
text = this.cleaningFunction(text);
return languagetoolService.checkSpellings(text, language).pipe(
......@@ -21,13 +26,13 @@ export class CreateCommentKeywords {
static cleaningFunction(text: string): string {
// eslint-disable-next-line max-len
const regexEmoji = new RegExp('\uD918\uDD28|\ufe0f|\u200D|\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]', 'g');
const regexKatex = new RegExp('\\$[^$\\n ]+\\$|\\$\\$[^$\\n ]+\\$\\$','g');
const regexEmoji = new RegExp('\uD918\uDD28|\ufe0f|\u200D|\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]', 'g');
const regexKatex = new RegExp('\\$[^$\\n ]+\\$|\\$\\$[^$\\n ]+\\$\\$', 'g');
const regexMarkdown = new RegExp('(?:__|[*#])|\\[(.+?)]\\((.+?)\\)', 'g');
const regexBlank = new RegExp('[\\s]{2,}', 'gu');
text = text.replace(regexKatex,'');
text = text.replace(regexEmoji,'');
text = text.replace(regexMarkdown,'');
const regexBlank = new RegExp('[\\s]{2,}', 'gu');
text = text.replace(regexKatex, '');
text = text.replace(regexEmoji, '');
text = text.replace(regexMarkdown, '');
text = text.replace(regexBlank, ' ');
return text;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment