Commit 0efc170e authored by Konstantin Schulz's avatar Konstantin Schulz
Browse files

introducing OOV check highlight for texts

parent 230c5921
{
"name": "mcClient",
"version": "0.2.9",
"version": "0.3.0",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
......
......@@ -106,6 +106,7 @@
"SOLUTIONS_SHUFFLE": "Mischen",
"START": "Anfang",
"TEST": "Test",
"TEXT_SHOW_OOV": "Unbekannte Vokabeln markieren",
"TEXT_TOO_LONG": "Text zu lang, max. Wortzahl: ",
"VOCABULARY_CHECK": "Vokabular vergleichen",
"VOCABULARY_CHOOSE_CORPUS": "Korpus auswählen...",
......
......@@ -106,6 +106,7 @@
"SOLUTIONS_SHUFFLE": "Shuffle",
"START": "Start",
"TEST": "Test",
"TEXT_SHOW_OOV": "Highlight unknown vocabulary",
"TEXT_TOO_LONG": "Text too long, max. word count: ",
"VOCABULARY_CHECK": "Compare vocabulary",
"VOCABULARY_CHOOSE_CORPUS": "Choose corpus...",
......
......@@ -9,6 +9,7 @@ export class NodeMC {
public udep_xpostag: string;
public udep_feats: string;
public solution: string;
public is_oov: boolean;
constructor(init?:Partial<NodeMC>) {
Object.assign(this, init);
}
......
......@@ -4,7 +4,9 @@
{{ 'MACHINA_CALLIDA' | translate }}
</ion-title>
<ion-buttons end>
<button padding-right ion-button color="primary" (click)="refreshCorpora()">{{ 'CORPORA_REFRESH' | translate }}</button>
<button padding-right ion-button color="primary" (click)="refreshCorpora()">{{ 'CORPORA_REFRESH' | translate
}}
</button>
<button ion-button icon-only color="primary" (click)="navCtrl.push(FeedbackPage)">
<ion-icon name="help-circle"></ion-icon>
</button>
......
......@@ -24,113 +24,136 @@
<ion-content padding>
<div *ngIf="corpusProvider.currentText.length > 0; else loading">
<p>{{corpusProvider.currentText}}</p>
<h2>{{ 'EXERCISE_GENERATE' | translate }}</h2>
<ion-grid>
<ion-row>
<ion-col>
<ion-label>
{{ 'EXERCISE_TYPE' | translate }}
</ion-label>
<ion-select [(ngModel)]="exerciseProvider.exercise.type" name="exerciseType"
(ionChange)="adjustTranslations()">
<ion-option *ngFor="let key of ObjectKeys(ExerciseType)" [value]=ExerciseType[key]>{{
ExerciseTypeTranslation[key] | translate }}
</ion-option>
</ion-select>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-label>
{{ 'INSTRUCTIONS' | translate }}
</ion-label>
<ion-input [(ngModel)]="exerciseProvider.exercise.instructionsTranslation"
name="instructionsTranslation"></ion-input>
</ion-col>
</ion-row>
<ion-row *ngIf="exerciseProvider.exercise.type === ExerciseType.matching">
<ion-col><h3>{{ 'HEAD_WORD' | translate }}</h3></ion-col>
<ion-col><h3>{{ 'DEPENDENT_WORD' | translate }}</h3></ion-col>
</ion-row>
<ion-row>
<ion-col *ngFor="let query of exerciseProvider.exercise.queryItems; let i = index">
<ion-grid>
<ion-row>
<ion-col>
<ion-label>{{ 'QUERY_PHENOMENON' | translate }}</ion-label>
<ion-select [(ngModel)]="query.phenomenon" name="queryPhenomenon"
(ionChange)="adjustQueryValue(query)">
<ion-option *ngFor="let phenomenon of ObjectKeys(Phenomenon)" [value]=phenomenon>{{
PhenomenonTranslation[phenomenon] | translate }}
</ion-option>
</ion-select>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-label>{{ 'QUERY_VALUE' | translate }}</ion-label>
<ion-select *ngIf="exerciseProvider.exercise.type === ExerciseType.cloze; else matching"
[(ngModel)]="query.values" name="queryValue" multiple="true">
<ion-grid *ngIf="corpusProvider.currentText.length > 0; else loading">
<ion-row>
<ion-col>
<div *ngIf="highlightOOV; else default">
<span *ngFor="let node of exerciseProvider.annisResponse.graph.nodes" [class.oov]="node.is_oov">
{{node.annis_tok}}&#32;
</span>
</div>
<ng-template #default>
<div>{{corpusProvider.currentText}}</div>
</ng-template>
</ion-col>
</ion-row>
<ion-row *ngIf="HelperProvider.isVocabularyCheck">
<ion-col>
<label>{{ "TEXT_SHOW_OOV" | translate}}
<input type="checkbox" [(ngModel)]="highlightOOV"/>
</label>
<br>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<h2>{{ 'EXERCISE_GENERATE' | translate }}</h2>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-label>
{{ 'EXERCISE_TYPE' | translate }}
</ion-label>
<ion-select [(ngModel)]="exerciseProvider.exercise.type" name="exerciseType"
(ionChange)="adjustTranslations()">
<ion-option *ngFor="let key of ObjectKeys(ExerciseType)" [value]=ExerciseType[key]>{{
ExerciseTypeTranslation[key] | translate }}
</ion-option>
</ion-select>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-label>
{{ 'INSTRUCTIONS' | translate }}
</ion-label>
<ion-input [(ngModel)]="exerciseProvider.exercise.instructionsTranslation"
name="instructionsTranslation"></ion-input>
</ion-col>
</ion-row>
<ion-row *ngIf="exerciseProvider.exercise.type === ExerciseType.matching">
<ion-col><h3>{{ 'HEAD_WORD' | translate }}</h3></ion-col>
<ion-col><h3>{{ 'DEPENDENT_WORD' | translate }}</h3></ion-col>
</ion-row>
<ion-row>
<ion-col *ngFor="let query of exerciseProvider.exercise.queryItems; let i = index">
<ion-grid>
<ion-row>
<ion-col>
<ion-label>{{ 'QUERY_PHENOMENON' | translate }}</ion-label>
<ion-select [(ngModel)]="query.phenomenon" name="queryPhenomenon"
(ionChange)="adjustQueryValue(query)">
<ion-option *ngFor="let phenomenon of ObjectKeys(Phenomenon)" [value]=phenomenon>{{
PhenomenonTranslation[phenomenon] | translate }}
</ion-option>
</ion-select>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-label>{{ 'QUERY_VALUE' | translate }}</ion-label>
<ion-select *ngIf="exerciseProvider.exercise.type === ExerciseType.cloze; else matching"
[(ngModel)]="query.values" name="queryValue" multiple="true">
<ion-option *ngFor="let key of getSortedQueryValues(query)" [value]=key>{{
exerciseProvider.phenomenonMap[query.phenomenon][0][key] + " (" +
exerciseProvider.phenomenonMap[query.phenomenon][2][key]
+ ")" }}
</ion-option>
</ion-select>
<ng-template #matching>
<ion-select [(ngModel)]="query.values[0]" name="queryValue" multiple="false">
<ion-option *ngFor="let key of getSortedQueryValues(query)" [value]=key>{{
exerciseProvider.phenomenonMap[query.phenomenon][0][key] + " (" +
exerciseProvider.phenomenonMap[query.phenomenon][2][key]
+ ")" }}
</ion-option>
</ion-select>
<ng-template #matching>
<ion-select [(ngModel)]="query.values[0]" name="queryValue" multiple="false">
<ion-option *ngFor="let key of getSortedQueryValues(query)" [value]=key>{{
exerciseProvider.phenomenonMap[query.phenomenon][0][key] + " (" +
exerciseProvider.phenomenonMap[query.phenomenon][2][key]
+ ")" }}
</ion-option>
</ion-select>
</ng-template>
</ion-col>
</ion-row>
</ion-grid>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<h3>{{ 'EXERCISE_FEEDBACK' | translate }}</h3>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-label>{{ 'EXERCISE_FEEDBACK_GENERAL' | translate }}</ion-label>
<ion-textarea [(ngModel)]="exerciseProvider.exercise.feedback.general"
name="feedbackGeneral"></ion-textarea>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-label>{{ 'EXERCISE_FEEDBACK_CORRECT' | translate }}</ion-label>
<ion-textarea [(ngModel)]="exerciseProvider.exercise.feedback.correct"
name="feedbackCorrect"></ion-textarea>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-label>{{ 'EXERCISE_FEEDBACK_PARTIALLY_CORRECT' | translate }}</ion-label>
<ion-textarea [(ngModel)]="exerciseProvider.exercise.feedback.partiallyCorrect"
name="feedbackPartiallyCorrect"></ion-textarea>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-label>{{ 'EXERCISE_FEEDBACK_INCORRECT' | translate }}</ion-label>
<ion-textarea [(ngModel)]="exerciseProvider.exercise.feedback.incorrect"
name="feedbackIncorrect"></ion-textarea>
</ion-col>
</ion-row>
</ion-grid>
<button ion-button (click)="generateExercise()">{{ 'PREVIEW' | translate }}</button>
</div>
</ng-template>
</ion-col>
</ion-row>
</ion-grid>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<h3>{{ 'EXERCISE_FEEDBACK' | translate }}</h3>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-label>{{ 'EXERCISE_FEEDBACK_GENERAL' | translate }}</ion-label>
<ion-textarea [(ngModel)]="exerciseProvider.exercise.feedback.general"
name="feedbackGeneral"></ion-textarea>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-label>{{ 'EXERCISE_FEEDBACK_CORRECT' | translate }}</ion-label>
<ion-textarea [(ngModel)]="exerciseProvider.exercise.feedback.correct"
name="feedbackCorrect"></ion-textarea>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-label>{{ 'EXERCISE_FEEDBACK_PARTIALLY_CORRECT' | translate }}</ion-label>
<ion-textarea [(ngModel)]="exerciseProvider.exercise.feedback.partiallyCorrect"
name="feedbackPartiallyCorrect"></ion-textarea>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-label>{{ 'EXERCISE_FEEDBACK_INCORRECT' | translate }}</ion-label>
<ion-textarea [(ngModel)]="exerciseProvider.exercise.feedback.incorrect"
name="feedbackIncorrect"></ion-textarea>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<button ion-button (click)="generateExercise()">{{ 'PREVIEW' | translate }}</button>
</ion-col>
</ion-row>
</ion-grid>
<ng-template #loading>
<ion-spinner></ion-spinner>
</ng-template>
......
......@@ -3,4 +3,7 @@ page-show-text {
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
.oov {
text-decoration: underline;
}
}
......@@ -18,6 +18,7 @@ import {AnnisResponse} from "../../models/annisResponse";
import {NodeMC} from "../../models/nodeMC";
import {LinkMC} from "../../models/linkMC";
import {HomePage} from "../home/home";
import {VocabularyProvider} from "../../providers/vocabulary/vocabulary";
/**
* Generated class for the ShowTextPage page.
......@@ -42,16 +43,26 @@ export class ShowTextPage {
public ObjectKeys = Object.keys;
public FeedbackPage = FeedbackPage;
public emptyQueryValueString: string;
HelperProvider = HelperProvider;
highlightOOV: boolean = false;
constructor(public navCtrl: NavController, public navParams: NavParams,
public corpusProvider: CorpusProvider,
public exerciseProvider: ExerciseProvider,
public toastCtrl: ToastController,
public translateService: TranslateService) {
this.corpusProvider.getCTStextPassage(this.corpusProvider.currentUrn).subscribe((ar: AnnisResponse) => {
this.processAnnisResponse(ar);
this.corpusProvider.currentText = ar.graph.nodes.map(x => x.annis_tok).join(" ");
});
public translateService: TranslateService,
public vocProvider: VocabularyProvider) {
this.corpusProvider.currentText = "";
if (HelperProvider.isVocabularyCheck) {
this.vocProvider.getVocabularyCheck(this.corpusProvider.currentUrn, true).subscribe((ar: AnnisResponse) => {
this.processAnnisResponse(ar);
});
}
else {
this.corpusProvider.getCTStextPassage(this.corpusProvider.currentUrn).subscribe((ar: AnnisResponse) => {
this.processAnnisResponse(ar);
});
}
this.translateService.get("TEXT_TOO_LONG").subscribe((value) => {
this.textTooLongString = value + HelperProvider.config["maxTextLength"];
});
......@@ -152,5 +163,6 @@ export class ShowTextPage {
this.exerciseProvider.phenomenonMap[Phenomenon.dependency][2][DependencyValue.root] = rootNodeIds.length;
this.adjustQueryValue(this.exerciseProvider.exercise.queryItems[0]);
this.exerciseProvider.annisResponse = ar;
this.corpusProvider.currentText = ar.graph.nodes.map(x => x.annis_tok).join(" ");
}
}
......@@ -60,16 +60,16 @@
</ng-template>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-label>{{ 'VOCABULARY_MATCHING_PERCENTAGE_WANTED' | translate }}</ion-label>
<ion-range min="0" max="100" [(ngModel)]="vocProvider.desiredMatchingPercentage" color="primary"
pin="true">
<ion-label range-left>0</ion-label>
<ion-label range-right>100</ion-label>
</ion-range>
</ion-col>
</ion-row>
<!--<ion-row>-->
<!--<ion-col>-->
<!--<ion-label>{{ 'VOCABULARY_MATCHING_PERCENTAGE_WANTED' | translate }}</ion-label>-->
<!--<ion-range min="0" max="100" [(ngModel)]="vocProvider.desiredMatchingPercentage" color="primary"-->
<!--pin="true">-->
<!--<ion-label range-left>0</ion-label>-->
<!--<ion-label range-right>100</ion-label>-->
<!--</ion-range>-->
<!--</ion-col>-->
<!--</ion-row>-->
<ion-row>
<ion-col>
<ion-label>{{ 'VOCABULARY_SENTENCE_COUNT' | translate }}</ion-label>
......
......@@ -5,7 +5,6 @@ import {VocabularyCorpus, VocabularyCorpusTranslation} from "../../models/enum";
import {TranslateService} from "@ngx-translate/core";
import {CorpusProvider} from "../../providers/corpus/corpus";
import {AuthorPage} from "../author/author";
import {HelperProvider} from "../../providers/helper/helper";
import {HttpClient} from "@angular/common/http";
import {Sentence} from "../../models/sentence";
import {FeedbackPage} from "../feedback/feedback";
......@@ -66,20 +65,13 @@ export class VocabularyCheckPage {
toast.present().then();
return;
}
this.isLoading = true;
this.vocProvider.currentSentences = [];
this.currentRankingUnits = [];
this.vocProvider.ranking = [];
this.isLoading = true;
let url = HelperProvider.config["backendBaseUrl"] + HelperProvider.config["backendApiVocabularyPath"];
this.http.get(url, {
params: {
"vocabulary": VocabularyCorpus[this.vocProvider.currentReferenceVocabulary],
"matching_degree": this.vocProvider.desiredMatchingPercentage.toString(),
"sentence_count": this.vocProvider.desiredSentenceCount.toString(),
"frequency_upper_bound": this.vocProvider.frequencyUpperBound.toString(),
"query_urn": this.corpusProvider.currentUrn
}
}).subscribe((sentences: Sentence[]) => {
// remove old sentence boundaries
this.corpusProvider.currentUrn = this.corpusProvider.currentUrn.split("@")[0];
this.vocProvider.getVocabularyCheck(this.corpusProvider.currentUrn, false).subscribe((sentences: Sentence[]) => {
this.processSentences(sentences);
});
}
......@@ -123,6 +115,8 @@ export class VocabularyCheckPage {
}
showText(rank: Sentence[]) {
// remove old sentence boundaries
this.corpusProvider.currentUrn = this.corpusProvider.currentUrn.split("@")[0];
this.corpusProvider.currentUrn += `@${rank[0].id}-${rank[rank.length - 1].id}`;
this.navCtrl.push(ShowTextPage).then();
}
......
......@@ -3,6 +3,7 @@ import {Injectable} from '@angular/core';
import {VocabularyCorpus} from "../../models/enum";
import {Sentence} from "../../models/sentence";
import {Vocabulary} from "../../models/vocabulary";
import {HelperProvider} from "../helper/helper";
/*
Generated class for the VocabularyProvider provider.
......@@ -13,7 +14,7 @@ import {Vocabulary} from "../../models/vocabulary";
@Injectable()
export class VocabularyProvider {
currentReferenceVocabulary: VocabularyCorpus = VocabularyCorpus.bws;
desiredMatchingPercentage: number = 50;
// desiredMatchingPercentage: number = 50;
desiredSentenceCount: number = 10;
frequencyUpperBound: number = 500;
refVocMap: { [refVoc: string]: Vocabulary } = {};
......@@ -38,4 +39,15 @@ export class VocabularyProvider {
});
}
getVocabularyCheck(query_urn: string, showOOV: boolean) {
let url = HelperProvider.config["backendBaseUrl"] + HelperProvider.config["backendApiVocabularyPath"];
return this.http.get(url, {
params: {
"vocabulary": VocabularyCorpus[this.currentReferenceVocabulary],
"frequency_upper_bound": this.frequencyUpperBound.toString(),
"query_urn": query_urn,
"show_oov": showOOV ? "1" : "0"
}
});
}
}
Markdown is supported
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