Commit ed9b013a authored by Konstantin Schulz's avatar Konstantin Schulz
Browse files

added the Dependency and Lemma phenomena

parent c324607d
......@@ -3,6 +3,36 @@
"AUTHOR_SEARCH": "Autor suchen...",
"AUTHOR_SELECT": "Autor auswählen",
"CALLIDUS_PROJECT": "CALLIDUS-Projekt",
"DEPENDENCY_ADJECTIVAL_CLAUSE": "Attributsatz",
"DEPENDENCY_ADJECTIVAL_MODIFIER": "Adjektivische Ergänzung",
"DEPENDENCY_ADVERBIAL_CLAUSE_MODIFIER": "Adverbialsatz",
"DEPENDENCY_ADVERBIAL_MODIFIER": "Adverbiale Ergänzung",
"DEPENDENCY_APPOSITIONAL_MODIFIER": "Apposition",
"DEPENDENCY_AUXILIARY": "Auxiliar",
"DEPENDENCY_CASE_MARKING": "Kasusmarker",
"DEPENDENCY_CLASSIFIER": "Zähleinheitswort",
"DEPENDENCY_CLAUSAL_COMPLEMENT": "Satzwertige Ergänzung",
"DEPENDENCY_CONJUNCT": "Konjunkt",
"DEPENDENCY_COORDINATING_CONJUNCTION": "Koordinierende Konjuktion",
"DEPENDENCY_COPULA": "Kopula",
"DEPENDENCY_DETERMINER": "Determinativ",
"DEPENDENCY_DISCOURSE_ELEMENT": "Diskurselement",
"DEPENDENCY_DISLOCATED": "Versetztes Element",
"DEPENDENCY_EXPLETIVE": "Füllwort",
"DEPENDENCY_GOES_WITH": "Zusammengehörig",
"DEPENDENCY_LIST": "Auflistung",
"DEPENDENCY_MARKER": "Subjunktion",
"DEPENDENCY_MULTIWORD_EXPRESSION": "Mehrwortausdruck",
"DEPENDENCY_NOMINAL_MODIFIER": "Nominale Ergänzung",
"DEPENDENCY_NUMERIC_MODIFIER": "Numerale Ergänzung",
"DEPENDENCY_OBJECT": "Objekt",
"DEPENDENCY_OBLIQUE_NOMINAL": "Oblique Nominalphrase",
"DEPENDENCY_ORPHAN": "Ellipse",
"DEPENDENCY_PARATAXIS": "Parataxe",
"DEPENDENCY_PUNCTUATION": "Zeichensetzung",
"DEPENDENCY_ROOT": "Wurzel",
"DEPENDENCY_SUBJECT": "Subjekt",
"DEPENDENCY_VOCATIVE": "Vokativ",
"EMAIL": "E-Mail",
"END": "Ende",
"EXERCISE_DOWNLOAD_NEXT_STEPS": "Nächste Schritte:",
......@@ -52,6 +82,7 @@
"PREVIEW": "Vorschau",
"QUERY_PHENOMENON": "Phänomen",
"QUERY_VALUE": "Suche",
"QUERY_VALUE_EMPTY": "Keine Suchanfrage ausgewählt",
"SHOW": "Anzeigen",
"START": "Anfang",
"TEST": "Test",
......
......@@ -3,6 +3,36 @@
"AUTHOR_SEARCH": "Search author...",
"AUTHOR_SELECT": "Select author",
"CALLIDUS_PROJECT": "CALLIDUS Project",
"DEPENDENCY_ADJECTIVAL_CLAUSE": "Adjectival Clause",
"DEPENDENCY_ADJECTIVAL_MODIFIER": "Adjectival Clause",
"DEPENDENCY_ADVERBIAL_CLAUSE_MODIFIER": "Adverbial Clause",
"DEPENDENCY_ADVERBIAL_MODIFIER": "Adverbial Modifier",
"DEPENDENCY_APPOSITIONAL_MODIFIER": "Apposition",
"DEPENDENCY_AUXILIARY": "Auxiliary",
"DEPENDENCY_CASE_MARKING": "Case Marker",
"DEPENDENCY_CLASSIFIER": "Counting Classifier",
"DEPENDENCY_CLAUSAL_COMPLEMENT": "Clausal Complement",
"DEPENDENCY_CONJUNCT": "Conjunct",
"DEPENDENCY_COORDINATING_CONJUNCTION": "Coordinating Conjunction",
"DEPENDENCY_COPULA": "Copula",
"DEPENDENCY_DETERMINER": "Determiner",
"DEPENDENCY_DISCOURSE_ELEMENT": "Discourse Element",
"DEPENDENCY_DISLOCATED": "Dislocated Element",
"DEPENDENCY_EXPLETIVE": "Expletive Nominal",
"DEPENDENCY_GOES_WITH": "Goes with",
"DEPENDENCY_LIST": "Auflistung",
"DEPENDENCY_MARKER": "Marker",
"DEPENDENCY_MULTIWORD_EXPRESSION": "Multiword Expression",
"DEPENDENCY_NOMINAL_MODIFIER": "Nominal Modifier",
"DEPENDENCY_NUMERIC_MODIFIER": "Numeral Modifier",
"DEPENDENCY_OBJECT": "Object",
"DEPENDENCY_OBLIQUE_NOMINAL": "Oblique Nominal",
"DEPENDENCY_ORPHAN": "Ellipsis",
"DEPENDENCY_PARATAXIS": "Parataxis",
"DEPENDENCY_PUNCTUATION": "Punctuation",
"DEPENDENCY_ROOT": "Root",
"DEPENDENCY_SUBJECT": "Subject",
"DEPENDENCY_VOCATIVE": "Vocative",
"EMAIL": "E-Mail",
"END": "End",
"EXERCISE_DOWNLOAD_NEXT_STEPS": "Next steps:",
......@@ -52,6 +82,7 @@
"PREVIEW": "Preview",
"QUERY_PHENOMENON": "Phenomenon",
"QUERY_VALUE": "Search",
"QUERY_VALUE_EMPTY": "Query value is empty",
"SHOW": "Show",
"START": "Start",
"TEST": "Test",
......
......@@ -20,24 +20,82 @@ export enum MoodleExerciseType {
export enum Phenomenon {
dependency = <any>"dependency",
lemma = <any>"lemma",
pos = <any>"pos",
partOfSpeech = <any>"partOfSpeech",
}
export enum PhenomenonTranslations {
export enum PhenomenonTranslation {
dependency = <any>"PHENOMENON_DEPENDENCY",
lemma = <any>"PHENOMENON_LEMMA",
pos = <any>"PHENOMENON_PART_OF_SPEECH",
partOfSpeech = <any>"PHENOMENON_PART_OF_SPEECH",
}
export enum Dependency {
nominalSubject = <any>"nominalSubject",
export enum DependencyValue {
adjectivalClause = <any>"adjectivalClause",
adjectivalModifier = <any>"adjectivalModifier",
adverbialClauseModifier = <any>"adverbialClauseModifier",
adverbialModifier = <any>"adverbialModifier",
appositionalModifier = <any>"appositionalModifier",
auxiliary = <any>"auxiliary",
caseMarking = <any>"caseMarking",
classifier = <any>"classifier",
clausalComplement = <any>"clausalComplement",
conjunct = <any>"conjunct",
coordinatingConjunction = <any>"coordinatingConjunction",
copula = <any>"copula",
determiner = <any>"determiner",
discourseElement = <any>"discourseElement",
dislocated = <any>"dislocated",
expletive = <any>"expletive",
goesWith = <any>"goesWith",
list = <any>"list",
marker = <any>"marker",
multiwordExpression = <any>"multiwordExpression",
nominalModifier = <any>"nominalModifier",
numericModifier = <any>"numericModifier",
object = <any>"object",
oblique = <any>"oblique",
orphan = <any>"orphan",
parataxis = <any>"parataxis",
root = <any>"root",
punctuation = <any>"punctuation",
subject = <any>"subject",
vocative = <any>"vocative",
}
export enum DependencyTranslations {
nominalSubject = <any>"DEPENDENCY_NOMINAL_SUBJECT",
export enum DependencyTranslation {
adjectivalClause = <any>"DEPENDENCY_ADJECTIVAL_CLAUSE",
adjectivalModifier = <any>"DEPENDENCY_ADJECTIVAL_MODIFIER",
adverbialClauseModifier = <any>"DEPENDENCY_ADVERBIAL_CLAUSE_MODIFIER",
adverbialModifier = <any>"DEPENDENCY_ADVERBIAL_MODIFIER",
appositionalModifier = <any>"DEPENDENCY_APPOSITIONAL_MODIFIER",
auxiliary = <any>"DEPENDENCY_AUXILIARY",
caseMarking = <any>"DEPENDENCY_CASE_MARKING",
classifier = <any>"DEPENDENCY_CLASSIFIER",
clausalComplement = <any>"DEPENDENCY_CLAUSAL_COMPLEMENT",
conjunct = <any>"DEPENDENCY_CONJUNCT",
coordinatingConjunction = <any>"DEPENDENCY_COORDINATING_CONJUNCTION",
copula = <any>"DEPENDENCY_COPULA",
determiner = <any>"DEPENDENCY_DETERMINER",
discourseElement = <any>"DEPENDENCY_DISCOURSE_ELEMENT",
dislocated = <any>"DEPENDENCY_DISLOCATED",
expletive = <any>"DEPENDENCY_EXPLETIVE",
goesWith = <any>"DEPENDENCY_GOES_WITH",
list = <any>"DEPENDENCY_LIST",
marker = <any>"DEPENDENCY_MARKER",
multiwordExpression = <any>"DEPENDENCY_MULTIWORD_EXPRESSION",
nominalModifier = <any>"DEPENDENCY_NOMINAL_MODIFIER",
numericModifier = <any>"DEPENDENCY_NUMERIC_MODIFIER",
object = <any>"DEPENDENCY_OBJECT",
oblique = <any>"DEPENDENCY_OBLIQUE_NOMINAL",
orphan = <any>"DEPENDENCY_ORPHAN",
parataxis = <any>"DEPENDENCY_PARATAXIS",
punctuation = <any>"DEPENDENCY_PUNCTUATION",
root = <any>"DEPENDENCY_ROOT",
subject = <any>"DEPENDENCY_SUBJECT",
vocative = <any>"DEPENDENCY_VOCATIVE",
}
export enum PartOfSpeech {
export enum PartOfSpeechValue {
adjective = <any>"adjective",
adverb = <any>"adverb",
auxiliary = <any>"auxiliary",
......@@ -55,7 +113,7 @@ export enum PartOfSpeech {
verb = <any>"verb",
}
export enum PartOfSpeechTranslations {
export enum PartOfSpeechTranslation {
adjective = <any>"PART_OF_SPEECH_ADJECTIVE",
adverb = <any>"PART_OF_SPEECH_ADVERB",
auxiliary = <any>"PART_OF_SPEECH_AUXILIARY",
......
import {Dependency, PartOfSpeech, Phenomenon} from "./enum";
import {DependencyValue, PartOfSpeechValue, Phenomenon} from "./enum";
export class QueryMC {
public phenomenon: Phenomenon;
public value: PartOfSpeech | Dependency;
public value: DependencyValue | PartOfSpeechValue | string;
constructor(init?:Partial<QueryMC>) {
Object.assign(this, init);
}
......
......@@ -181,7 +181,7 @@ export class CorpusDetailPage {
this.corpusProvider.currentCorpus.citations[relevantCitationIndices[0]].subcitations[relevantCitationIndices[1]].subcitations[citation.value] = citation;
}
});
if (targetCitationLevel === this.corpusProvider.currentCorpus.citation_level_1) {
if (targetCitationLevel === this.corpusProvider.currentCorpus.citation_level_1){
this.initReffDisplay();
}
});
......
......@@ -6,6 +6,7 @@ import {ExerciseProvider} from "../../providers/exercise/exercise";
import {TranslateService} from "@ngx-translate/core";
import {FeedbackPage} from "../feedback/feedback";
import {CorpusProvider} from "../../providers/corpus/corpus";
import {Phenomenon} from "../../models/enum";
@Component({
selector: 'page-home',
......@@ -28,6 +29,7 @@ export class HomePage {
}
test() {
let d = 1;
let a = Object.values(Phenomenon);
let b = 0;
}
}
......@@ -43,13 +43,13 @@ export class PreviewPage {
private getExerciseData() {
this.translateService.get(this.exerciseProvider.exercise.typeTranslation.toString()).subscribe((ett: string) => {
let formData = new FormData();
let aql: string = this.exerciseProvider.exercise.query.phenomenon + "=" + this.exerciseProvider.exercise.query.value;
let search_value: 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", MoodleExerciseType[this.exerciseProvider.exercise.type]);
formData.append("type_translation", ett);
formData.append("aql", aql);
formData.append("search_value", search_value);
formData.append("instructions", this.instructionsFillTheGapString);
formData.append("correct_feedback", this.exerciseProvider.exercise.feedback.correct);
formData.append("partially_correct_feedback", this.exerciseProvider.exercise.feedback.partiallyCorrect);
......
......@@ -29,7 +29,8 @@
<ion-label>
{{ 'EXERCISE_TYPE' | translate }}
</ion-label>
<ion-select [(ngModel)]="exerciseProvider.exercise.type" name="exerciseType" (ionChange)="adjustTypeTranslation()">
<ion-select [(ngModel)]="exerciseProvider.exercise.type" name="exerciseType"
(ionChange)="adjustTypeTranslation()">
<ion-option *ngFor="let key of ObjectKeys(ExerciseType)" [value]=key>{{ ExerciseTypeTranslation[key]
| translate }}
</ion-option>
......@@ -41,8 +42,8 @@
</ion-label>
<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 *ngFor="let phenomenon of ObjectKeys(Phenomenon)" [value]=phenomenon>{{
PhenomenonTranslation[phenomenon] | translate }}
</ion-option>
</ion-select>
</ion-item>
......@@ -50,11 +51,11 @@
<ion-label>
{{ 'QUERY_VALUE' | translate }}
</ion-label>
<ion-select [(ngModel)]="exerciseProvider.exercise.query.value" name="queryValue">
<ion-select *ngIf="exerciseProvider.exercise.query.phenomenon !== Phenomenon.lemma; else lemma"
[(ngModel)]="exerciseProvider.exercise.query.value" name="queryValue">
<ion-option
*ngFor="let key of ObjectKeys(phenomenonMap[exerciseProvider.exercise.query.phenomenon][0])"
[value]=key>{{
phenomenonMap[exerciseProvider.exercise.query.phenomenon][1][key] | translate }}
*ngFor="let key of getSortedQueryValues()" [value]=key>{{
exerciseProvider.phenomenonMap[exerciseProvider.exercise.query.phenomenon][0][key] }}
</ion-option>
</ion-select>
</ion-item>
......@@ -88,4 +89,9 @@
<ng-template #loading>
<ion-spinner></ion-spinner>
</ng-template>
<ng-template #lemma>
<div item-end style="width: 100px">
<ion-input [(ngModel)]="exerciseProvider.exercise.query.value" placeholder="Lemma"></ion-input>
</div>
</ng-template>
</ion-content>
......@@ -2,12 +2,10 @@ import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams, ToastController} from 'ionic-angular';
import {CorpusProvider} from "../../providers/corpus/corpus";
import {
Dependency, DependencyTranslations,
ExerciseType, ExerciseTypeTranslation,
PartOfSpeech,
PartOfSpeechTranslations,
PartOfSpeechTranslation,
Phenomenon,
PhenomenonTranslations
PhenomenonTranslation
} from "../../models/enum";
import {ExerciseProvider} from "../../providers/exercise/exercise";
import {PreviewPage} from "../preview/preview";
......@@ -31,29 +29,25 @@ export class ShowTextPage {
public ExerciseType = ExerciseType;
public ExerciseTypeTranslation = ExerciseTypeTranslation;
public Phenomenon = Phenomenon;
public PhenomenonTranslations = PhenomenonTranslations;
public PartOfSpeech = PartOfSpeech;
public PartOfSpeechTranslations = PartOfSpeechTranslations;
public PhenomenonTranslation = PhenomenonTranslation;
public currentText: string = "";
public textTooLongString: string;
public ObjectKeys = Object.keys;
public phenomenonMap: object = {};
public FeedbackPage = FeedbackPage;
public emptyQueryValueString: string;
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"];
});
this.translateService.get("TEXT_TOO_LONG").subscribe((value) => {
this.textTooLongString = value + HelperProvider.config["maxTextLength"];
});
this.translateService.get("QUERY_VALUE_EMPTY").subscribe(value => this.emptyQueryValueString = value);
}
generateExercise() {
......@@ -65,22 +59,35 @@ export class ShowTextPage {
});
toast.present().then();
}
else if (this.exerciseProvider.exercise.query.phenomenon === Phenomenon.lemma && !this.exerciseProvider.exercise.query.value) {
let toast = this.toastCtrl.create({
message: this.emptyQueryValueString,
duration: 3000,
position: 'top'
});
toast.present().then();
}
else {
this.exerciseProvider.annisResponse = null;
this.navCtrl.push(PreviewPage).then();
}
}
getSortedQueryValues() {
let targetObject: object = this.exerciseProvider.phenomenonMap[this.exerciseProvider.exercise.query.phenomenon][0];
return Object.keys(targetObject).sort((a, b) => {
return a === b ? 0 : (targetObject[a] < targetObject[b] ? -1 : 1);
});
}
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.nominalSubject;
break;
default:
break;
if (this.exerciseProvider.exercise.query.phenomenon === Phenomenon.lemma) {
this.exerciseProvider.exercise.query.value = "";
}
else {
let availableValues = Object.keys(this.exerciseProvider.phenomenonMap[this.exerciseProvider.exercise.query.phenomenon][0]);
// when the phenomenon changes, choose a (almost) random value as the default
this.exerciseProvider.exercise.query.value = availableValues[Object.keys(availableValues)[0]];
}
}
......
import {HttpClient} from '@angular/common/http';
import {Injectable} from '@angular/core';
import {ExerciseType, ExerciseTypeTranslation, PartOfSpeech, Phenomenon} from "../../models/enum";
import {
DependencyTranslation,
ExerciseType,
ExerciseTypeTranslation,
PartOfSpeechTranslation,
PartOfSpeechValue,
Phenomenon,
} from "../../models/enum";
import {Exercise} from "../../models/exercise";
import {QueryMC} from "../../models/queryMC";
import {AnnisResponse} from "../../models/annisResponse";
......@@ -19,12 +26,13 @@ export class ExerciseProvider {
type: ExerciseType.cloze,
typeTranslation: ExerciseTypeTranslation.cloze,
query: new QueryMC({
phenomenon: Phenomenon.pos,
value: PartOfSpeech.conjunction
phenomenon: Phenomenon.partOfSpeech,
value: PartOfSpeechValue.adjective,
}),
feedback: new Feedback({general: "", incorrect: "", partiallyCorrect: "", correct: ""})
});
public annisResponse: AnnisResponse;
public phenomenonMap: { [phenomenonName: string]: [{ [translateKey: string]: string }, object] } = {};
constructor(public http: HttpClient,
public translateService: TranslateService) {
......@@ -40,6 +48,19 @@ export class ExerciseProvider {
this.translateService.get("EXERCISE_FEEDBACK_GENERAL_DEFAULT").subscribe((value) => {
this.exercise.feedback.general = value;
});
// map the different phenomena to their respective Enum for processing and display/translation
this.phenomenonMap[Phenomenon.partOfSpeech] = [{}, PartOfSpeechTranslation];
this.phenomenonMap[Phenomenon.dependency] = [{}, DependencyTranslation];
Object.keys(Phenomenon).forEach((key) => {
if (key !== Phenomenon[Phenomenon.lemma]){
let translationObject: object = this.phenomenonMap[key][1];
Object.keys(translationObject).forEach((k) => {
if (k.toUpperCase() !== k) {
this.translateService.get(translationObject[k]).subscribe(v => this.phenomenonMap[key][0][k] = v);
}
});
}
});
}
createGuid() {
......
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