Commit 2f496bdc authored by Konstantin Schulz's avatar Konstantin Schulz

corpus texts are now selectable and users can search for all kinds of POS tags for the exercises

parent edc5ad2c
Pipeline #1406 failed with stages
......@@ -15,6 +15,7 @@ import {ShowTextPageModule} from "../pages/show-text/show-text.module";
import {ExerciseProvider} from '../providers/exercise/exercise';
import {PreviewPageModule} from "../pages/preview/preview.module";
import {AuthorPageModule} from "../pages/author/author.module";
import {HelperProvider} from '../providers/helper/helper';
// The translate loader needs to know where to load i18n files
// in Ionic's static asset pipeline.
......@@ -60,7 +61,8 @@ class CustomErrorHandler extends IonicErrorHandler {
StatusBar,
{provide: ErrorHandler, useClass: CustomErrorHandler},
CorpusProvider,
ExerciseProvider
ExerciseProvider,
HelperProvider
]
})
export class AppModule {
......
......@@ -23,7 +23,21 @@
"INSTRUCTIONS": "Anweisungen",
"INSTRUCTIONS_FILL_THE_GAP": "Ordne die Wörter aus dem Pool den richtigen Lücken zu!",
"INVALID_TEXT_RANGE": "Ungültige Textauswahl",
"PART_OF_SPEECH_ADJECTIVE": "Adjektiv",
"PART_OF_SPEECH_ADVERB": "Adverb",
"PART_OF_SPEECH_AUXILIARY": "Auxiliarverb",
"PART_OF_SPEECH_CONJUNCTION": "Konjunktion",
"PART_OF_SPEECH_INTERJECTION": "Interjektion",
"PART_OF_SPEECH_NOUN": "Substantiv",
"PART_OF_SPEECH_NUMERAL": "Zahlwort",
"PART_OF_SPEECH_OTHER": "Andere",
"PART_OF_SPEECH_PARTICLE": "Partikel",
"PART_OF_SPEECH_PREPOSITION": "Präposition",
"PART_OF_SPEECH_PRONOUN": "Pronomen",
"PART_OF_SPEECH_PROPER_NOUN": "Eigenname",
"PART_OF_SPEECH_PUNCTUATION": "Interpunktion",
"PART_OF_SPEECH_SYMBOL": "Symbol",
"PART_OF_SPEECH_VERB": "Verb",
"PDF": "PDF",
"PHENOMENON_DEPENDENCY": "Dependenz",
"PHENOMENON_PART_OF_SPEECH": "Wortart",
......
......@@ -23,7 +23,21 @@
"INSTRUCTIONS": "Instructions",
"INSTRUCTIONS_FILL_THE_GAP": "Assign the words from the pool to the correct gaps!",
"INVALID_TEXT_RANGE": "Invalid text range",
"PART_OF_SPEECH_ADJECTIVE": "Adjective",
"PART_OF_SPEECH_ADVERB": "Adverb",
"PART_OF_SPEECH_AUXILIARY": "Auxiliary verb",
"PART_OF_SPEECH_CONJUNCTION": "Conjunction",
"PART_OF_SPEECH_INTERJECTION": "Interjection",
"PART_OF_SPEECH_NOUN": "Noun",
"PART_OF_SPEECH_NUMERAL": "Numeral",
"PART_OF_SPEECH_OTHER": "Other",
"PART_OF_SPEECH_PARTICLE": "Particle",
"PART_OF_SPEECH_PREPOSITION": "Preposition",
"PART_OF_SPEECH_PRONOUN": "Pronoun",
"PART_OF_SPEECH_PROPER_NOUN": "Proper Noun",
"PART_OF_SPEECH_PUNCTUATION": "Punctuation",
"PART_OF_SPEECH_SYMBOL": "Symbol",
"PART_OF_SPEECH_VERB": "Verb",
"PDF": "PDF",
"PHENOMENON_DEPENDENCY": "Dependency",
"PHENOMENON_PART_OF_SPEECH": "Part of speech",
......
......@@ -8,11 +8,56 @@ export enum ExerciseType {
export enum Phenomenon {
pos = <any>"pos",
dependency = <any>"dependency"
// dependency = <any>"dependency"
}
export enum PhenomenonTranslations {
pos = <any>"PHENOMENON_PART_OF_SPEECH",
dependency = <any>"PHENOMENON_DEPENDENCY"
}
export enum Dependency {
nominalSubject = <any>"nominalSubject",
}
export enum DependencyTranslations {
nominalSubject = <any>"DEPENDENCY_NOMINAL_SUBJECT",
}
export enum PartOfSpeech {
conjunction = <any>"conjunction"
adjective = <any>"adjective",
adverb = <any>"adverb",
auxiliary = <any>"auxiliary",
conjunction = <any>"conjunction",
interjection = <any>"interjection",
noun = <any>"noun",
numeral = <any>"numeral",
other = <any>"other",
particle = <any>"particle",
preposition = <any>"preposition",
pronoun = <any>"pronoun",
properNoun = <any>"properNoun",
punctuation = <any>"punctuation",
symbol = <any>"symbol",
verb = <any>"verb",
}
export enum PartOfSpeechTranslations {
adjective = <any>"PART_OF_SPEECH_ADJECTIVE",
adverb = <any>"PART_OF_SPEECH_ADVERB",
auxiliary = <any>"PART_OF_SPEECH_AUXILIARY",
interjection = <any>"PART_OF_SPEECH_INTERJECTION",
conjunction = <any>"PART_OF_SPEECH_CONJUNCTION",
noun = <any>"PART_OF_SPEECH_NOUN",
numeral = <any>"PART_OF_SPEECH_NUMERAL",
other = <any>"PART_OF_SPEECH_OTHER",
particle = <any>"PART_OF_SPEECH_PARTICLE",
preposition = <any>"PART_OF_SPEECH_PREPOSITION",
pronoun = <any>"PART_OF_SPEECH_PRONOUN",
properNoun = <any>"PART_OF_SPEECH_PROPER_NOUN",
punctuation = <any>"PART_OF_SPEECH_PUNCTUATION",
symbol = <any>"PART_OF_SPEECH_SYMBOL",
verb = <any>"PART_OF_SPEECH_VERB",
}
export enum FileType {
......
......@@ -144,6 +144,7 @@ export class CorpusDetailPage {
let urnLastPart: string = relevantCitationIndices.map(x => x.toString()).join(".");
let fullUrn: string = this.corpusProvider.currentCorpus.source_urn + (urnLastPart ? ":" + urnLastPart : "");
this.corpusProvider.getCTSvalidReff(fullUrn).subscribe((result: string | object) => {
// TODO: change the mapping, comparison etc. so we can handle citations that are not numeric
let newCitations: Citation[] = [];
if (typeof result === "object") {
// this is a custom corpus
......
......@@ -5,6 +5,8 @@ import {HttpClient} from "@angular/common/http";
import {ExerciseProvider} from "../../providers/exercise/exercise";
import {CorpusProvider} from "../../providers/corpus/corpus";
import {TranslateService} from "@ngx-translate/core";
import {PartOfSpeech, PartOfSpeechTranslations, Phenomenon} from "../../models/enum";
import {HelperProvider} from "../../providers/helper/helper";
@Component({
selector: 'page-home',
......@@ -17,7 +19,8 @@ export class HomePage {
public http: HttpClient,
public exerciseProvider: ExerciseProvider,
public corpusProvider: CorpusProvider,
public translate: TranslateService) {
public translate: TranslateService,
public helperProvider: HelperProvider) {
}
goToAuthorPage() {
......@@ -25,7 +28,12 @@ export class HomePage {
}
test() {
let a = [1].concat([2]);
for (let key of Object.keys(PartOfSpeech)) { // Object.keys(PartOfSpeech) this.helperProvider.getStringEnumKeys(PartOfSpeech)
let a = PartOfSpeech[key];
let b = 0;
}
let c = PartOfSpeechTranslations;
let e = Object.keys(c);
let d = 0;
}
}
......@@ -43,10 +43,12 @@ export class PreviewPage {
private getExerciseData() {
let formData = new FormData();
let aql: string = this.exerciseProvider.exercise.query.phenomenon + "=" + this.exerciseProvider.exercise.query.value;
// TODO: change the corpus title to something meaningful, e.g. concatenate user ID and wanted exercise title
formData.append("title", this.exerciseProvider.createGuid());
formData.append("text", this.corpusProvider.currentText);
formData.append("type", this.exerciseFillTheGapString);
formData.append("aql", aql);
formData.append("instructions", this.instructionsFillTheGapString);
formData.append("correct_feedback", this.exerciseProvider.exercise.feedback.correct);
formData.append("partially_correct_feedback", this.exerciseProvider.exercise.feedback.partiallyCorrect);
......
......@@ -33,17 +33,21 @@
<ion-label>
{{ 'QUERY_PHENOMENON' | translate }}
</ion-label>
<ion-select [(ngModel)]="exerciseProvider.exercise.query.phenomenon" name="queryPhenomenon">
<ion-option value="{{Phenomenon.pos}}">{{ 'PHENOMENON_PART_OF_SPEECH' | translate }}</ion-option>
<!--<ion-option value="{{Phenomenon.dependency}}">{{ 'PHENOMENON_DEPENDENCY' | translate }}</ion-option>-->
<ion-select [(ngModel)]="exerciseProvider.exercise.query.phenomenon" name="queryPhenomenon" (ionChange)="adjustQueryValue()">
<ion-option *ngFor="let key of ObjectKeys(Phenomenon)" [value]=key>{{ PhenomenonTranslations[key] |
translate }}
</ion-option>
</ion-select>
</ion-item>
<ion-item *ngIf="exerciseProvider.exercise.query.phenomenon === Phenomenon.pos">
<ion-item>
<ion-label>
{{ 'QUERY_VALUE' | translate }}
</ion-label>
<ion-select [(ngModel)]="exerciseProvider.exercise.query.value" name="queryValue">
<ion-option value="{{PartOfSpeech.conjunction}}">{{ 'PART_OF_SPEECH_CONJUNCTION' | translate }}
<ion-option
*ngFor="let key of ObjectKeys(phenomenonMap[exerciseProvider.exercise.query.phenomenon][0])"
[value]=key>{{
phenomenonMap[exerciseProvider.exercise.query.phenomenon][1][key] | translate }}
</ion-option>
</ion-select>
</ion-item>
......
page-show-text {
-webkit-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}
import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams, ToastController} from 'ionic-angular';
import {CorpusProvider} from "../../providers/corpus/corpus";
import {ExerciseType, PartOfSpeech, Phenomenon} from "../../models/enum";
import {
Dependency, DependencyTranslations,
ExerciseType,
PartOfSpeech,
PartOfSpeechTranslations,
Phenomenon,
PhenomenonTranslations
} from "../../models/enum";
import {ExerciseProvider} from "../../providers/exercise/exercise";
import {PreviewPage} from "../preview/preview";
import {TranslateService} from "@ngx-translate/core";
import {ConfigMC} from "../../config";
import {HelperProvider} from "../../providers/helper/helper";
/**
* Generated class for the ShowTextPage page.
......@@ -22,15 +30,22 @@ import {ConfigMC} from "../../config";
export class ShowTextPage {
public ExerciseType = ExerciseType;
public Phenomenon = Phenomenon;
public PhenomenonTranslations = PhenomenonTranslations;
public PartOfSpeech = PartOfSpeech;
public PartOfSpeechTranslations = PartOfSpeechTranslations;
public currentText: string = "";
private textTooLongString: string;
public textTooLongString: string;
public ObjectKeys = Object.keys;
public phenomenonMap: object = {};
constructor(public navCtrl: NavController, public navParams: NavParams,
public corpusProvider: CorpusProvider,
public exerciseProvider: ExerciseProvider,
public toastCtrl: ToastController,
public translateService: TranslateService) {
// map the different phenomena to their respective Enum for processing and display/translation
this.phenomenonMap[Phenomenon.pos] = [PartOfSpeech, PartOfSpeechTranslations];
this.phenomenonMap[Phenomenon.dependency] = [Dependency, DependencyTranslations];
this.corpusProvider.getCTStextPassage(this.corpusProvider.currentUrn).subscribe((data: object) => {
this.corpusProvider.currentText = data["text"];
});
......@@ -53,4 +68,14 @@ export class ShowTextPage {
this.navCtrl.push(PreviewPage).then();
}
}
adjustQueryValue() {
switch (this.exerciseProvider.exercise.query.phenomenon){
case Phenomenon.pos:
this.exerciseProvider.exercise.query.value = PartOfSpeech.conjunction;
break;
case Phenomenon.dependency:
this.exerciseProvider.exercise.query.value = Dependency
}
}
}
......@@ -30,7 +30,6 @@ export class CorpusProvider {
public currentTextRange: TextRange = new TextRange({start: [0, 0, 0], end: [0, 0, 0]});
public currentLastUrnPart: string = "";
public currentCitations: Citation[] = [];
public previousCorpus: CorpusMC;
constructor(public translate: TranslateService,
public http: HttpClient) {
......
import {HttpClient} from '@angular/common/http';
import {Injectable} from '@angular/core';
/*
Generated class for the HelperProvider provider.
See https://angular.io/guide/dependency-injection for more info on providers
and Angular DI.
*/
@Injectable()
export class HelperProvider {
constructor(public http: HttpClient) {
}
}
......@@ -6,7 +6,7 @@
"experimentalDecorators": true,
"lib": [
"dom",
"es7" // es2015
"es2017" // es7 es2015
],
"module": "es2015",
"moduleResolution": "node",
......
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