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

added new feature: users can combine multiple text passages to a new one

parent d5cd808b
......@@ -2,8 +2,7 @@
"AUTHORS": "Autoren",
"AUTHOR_SEARCH": "Autor suchen...",
"AUTHOR_SELECT": "Autor auswählen",
"CORPUS_DETAIL_TITLE": "Korpus-Details",
"CORPUS_SELECT": "Korpus auswählen",
"END": "Ende",
"EXERCISE_DOWNLOAD_NEXT_STEPS": "Nächste Schritte:",
"EXERCISE_FEEDBACK": "Feedback",
"EXERCISE_FEEDBACK_CORRECT": "korrekt",
......@@ -23,7 +22,9 @@
"INSTRUCTION_LOGIN_MOODLE": "Lade die Übung mit einem Klick auf 'XML' herunter. Nun logge dich in Moodle ein und betrete den Kurs, der die Übung enthalten soll.",
"INSTRUCTIONS": "Anweisungen",
"INSTRUCTIONS_FILL_THE_GAP": "Ordne die Wörter aus dem Pool den richtigen Lücken zu!",
"INVALID_TEXT_RANGE": "Ungültige Textauswahl",
"LOCAL_STORAGE_KEY_CORPORA": "mc/corpora",
"NO_TEXT_RANGE_CHOSEN": "Bitte wähle einen Textausschnitt.",
"PART_OF_SPEECH_CONJUNCTION": "Konjunktion",
"PDF": "PDF",
"PHENOMENON_DEPENDENCY": "Dependenz",
......@@ -31,6 +32,8 @@
"PREVIEW": "Vorschau",
"QUERY_PHENOMENON": "Phänomen",
"QUERY_VALUE": "Suche",
"SHOW": "Anzeigen",
"START": "Anfang",
"TEST": "Test",
"WELCOME": "Willkommen!",
"XML": "XML"
......
export class ConfigMC {
public static backendBaseUrl: string = "http://141.20.186.246:5000";
public static backendBaseUrl: string = "http://141.20.186.246:5000"; // 141.20.186.246 localhost
public static backendApiPath: string = "/mc/api/v1.0/";
public static backendApiCorporaPath: string = "corpora";
public static backendApiExercisePath: string = "exercise";
......
import {GetValidReff} from "./getValidReff";
export class CorpusMC {
public author: string;
public cid: number;
......@@ -9,8 +7,7 @@ export class CorpusMC {
public citation_level_1: string;
public citation_level_2: string;
public citation_level_3: string;
public validReff: GetValidReff;
public subCorpora: {[urn: string] : GetValidReff};
public subCorpora: {[urn: string] : string[]};
constructor(init?:Partial<CorpusMC>) {
Object.assign(this, init);
}
......
export class TextRange {
public start: string[];
public end: string[];
constructor(init?:Partial<TextRange>) {
Object.assign(this, init);
}
}
......@@ -7,7 +7,7 @@
<ion-header>
<ion-navbar>
<ion-title>{{ 'CORPUS_SELECT' | translate }}</ion-title>
<ion-title>{{corpusProvider.currentAuthor.name}}</ion-title>
</ion-navbar>
</ion-header>
......
......@@ -7,38 +7,101 @@
<ion-header>
<ion-navbar>
<ion-title>{{ 'CORPUS_DETAIL_TITLE' | translate }}</ion-title>
<ion-title>{{corpusProvider.currentAuthor.name}}: {{corpusProvider.currentCorpus.title}}</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-list>
<ion-item *ngFor="let urn1 of corpusProvider.currentCorpus.validReff?.reply.reff.urn">
<button ion-button (click)="showFurtherReferencesOrText(urn1, 1)">
{{corpusProvider.currentCorpus.citation_level_1}}
{{urn1.replace(corpusProvider.currentCorpus.source_urn + ":", "")}}
</button>
<div *ngIf="corpusProvider.currentCorpus.subCorpora[urn1] && corpusProvider.currentCorpus.subCorpora[urn1].isVisible">
<ion-list>
<ion-item *ngFor="let urn2 of corpusProvider.currentCorpus.subCorpora[urn1].reply.reff.urn">
<button ion-button (click)="showFurtherReferencesOrText(urn2, 2)">
{{corpusProvider.currentCorpus.citation_level_2}} {{urn2.replace(urn1 + ".", "")}}
</button>
<div *ngIf="corpusProvider.currentCorpus.subCorpora[urn2] && corpusProvider.currentCorpus.subCorpora[urn2].isVisible">
<ion-list>
<ion-item-sliding
*ngFor="let urn3 of corpusProvider.currentCorpus.subCorpora[urn2].reply.reff.urn">
<button ion-item (click)="showFurtherReferencesOrText(urn3, 3)">
{{corpusProvider.currentCorpus.citation_level_3}} {{urn3.replace(urn2 + ".", "")}}
</button>
</ion-item-sliding>
</ion-list>
</div>
</ion-item>
</ion-list>
</div>
</ion-item>
</ion-list>
<ion-grid>
<ion-row>
<ion-col><h1>{{ 'START' | translate }}</h1></ion-col>
<ion-col><h1>{{ 'END' | translate }}</h1></ion-col>
</ion-row>
<ion-row *ngIf="corpusProvider.currentCorpus.subCorpora['']; else loading">
<ion-col>
<ion-label>
{{corpusProvider.currentCorpus.citation_level_1}}
</ion-label>
<ion-select [(ngModel)]="corpusProvider.currentTextRange.start[0]" name="textRangeStart0"
(ionChange)="showFurtherReferences($event.toString(), 1, true)">
<ion-option *ngFor="let urn1 of corpusProvider.currentCorpus.subCorpora['']" value="{{urn1}}">
{{urn1}}
</ion-option>
</ion-select>
</ion-col>
<ion-col>
<ion-label>
{{corpusProvider.currentCorpus.citation_level_1}}
</ion-label>
<ion-select [(ngModel)]="corpusProvider.currentTextRange.end[0]" name="textRangeEnd0"
(ionChange)="showFurtherReferences($event.toString(), 1, false)">
<ion-option *ngFor="let urn2 of corpusProvider.currentCorpus.subCorpora['']"
value="{{urn2}}">{{urn2}}
</ion-option>
</ion-select>
</ion-col>
</ion-row>
<ion-row *ngIf="corpusProvider.currentCorpus.citation_level_2 != CitationLevel[CitationLevel.default]">
<ion-col
*ngIf="corpusProvider.currentTextRange.start[0] && corpusProvider.currentCorpus.subCorpora[corpusProvider.currentTextRange.start[0]]">
<ion-label>
{{corpusProvider.currentCorpus.citation_level_2}}
</ion-label>
<ion-select [(ngModel)]="corpusProvider.currentTextRange.start[1]" name="textRangeStart1"
(ionChange)="showFurtherReferences($event.toString(), 2, true)">
<ion-option
*ngFor="let urn3 of corpusProvider.currentCorpus.subCorpora[corpusProvider.currentTextRange.start[0]]"
value="{{urn3}}">{{urn3}}
</ion-option>
</ion-select>
</ion-col>
<ion-col
*ngIf="corpusProvider.currentTextRange.end[0] && corpusProvider.currentCorpus.subCorpora[corpusProvider.currentTextRange.end[0]]">
<ion-label>
{{corpusProvider.currentCorpus.citation_level_2}}
</ion-label>
<ion-select [(ngModel)]="corpusProvider.currentTextRange.end[1]" name="textRangeEnd1"
(ionChange)="showFurtherReferences($event.toString(), 2, false)">
<ion-option
*ngFor="let urn4 of corpusProvider.currentCorpus.subCorpora[corpusProvider.currentTextRange.end[0]]"
value="{{urn4}}">{{urn4}}
</ion-option>
</ion-select>
</ion-col>
</ion-row>
<ion-row *ngIf="corpusProvider.currentCorpus.citation_level_3 != CitationLevel[CitationLevel.default]">
<ion-col
*ngIf="corpusProvider.currentTextRange.start[1] && corpusProvider.currentCorpus.subCorpora[[corpusProvider.currentTextRange.start[0], corpusProvider.currentTextRange.start[1]].join('.')]">
<ion-label>
{{corpusProvider.currentCorpus.citation_level_3}}
</ion-label>
<ion-select [(ngModel)]="corpusProvider.currentTextRange.start[2]" name="textRangeStart2">
<ion-option
*ngFor="let urn5 of corpusProvider.currentCorpus.subCorpora[corpusProvider.currentTextRange.start[0] + '.' + corpusProvider.currentTextRange.start[1]]"
value="{{urn5}}">{{urn5}}
</ion-option>
</ion-select>
</ion-col>
<ion-col
*ngIf="corpusProvider.currentTextRange.end[1] && corpusProvider.currentCorpus.subCorpora[[corpusProvider.currentTextRange.end[0], corpusProvider.currentTextRange.end[1]].join('.')]">
<ion-label>
{{corpusProvider.currentCorpus.citation_level_3}}
</ion-label>
<ion-select [(ngModel)]="corpusProvider.currentTextRange.end[2]" name="textRangeEnd2">
<ion-option
*ngFor="let urn6 of corpusProvider.currentCorpus.subCorpora[corpusProvider.currentTextRange.start[0] + '.' + corpusProvider.currentTextRange.start[1]]"
value="{{urn6}}">{{urn6}}
</ion-option>
</ion-select>
</ion-col>
</ion-row>
</ion-grid>
<button ion-button block (click)="showText()">{{ "SHOW" | translate }}</button>
<ng-template #loading>
<ion-spinner></ion-spinner>
</ng-template>
</ion-content>
import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {IonicPage, NavController, NavParams, ToastController} from 'ionic-angular';
import {CorpusProvider} from "../../providers/corpus/corpus";
import {GetValidReff} from "../../models/getValidReff";
import {CitationLevel} from "../../models/enum";
import {ShowTextPage} from "../show-text/show-text";
import {HttpErrorResponse} from "@angular/common/http";
import {TextRange} from "../../models/textRange";
import {TranslateService} from "@ngx-translate/core";
/**
* Generated class for the CorpusDetailPage page.
......@@ -19,58 +20,138 @@ import {HttpErrorResponse} from "@angular/common/http";
templateUrl: 'corpus-detail.html',
})
export class CorpusDetailPage {
public showMultiPartText: boolean = false;
private noTextRangeChosenString: string;
public CitationLevel = CitationLevel;
private invalidTextRangeString: string;
constructor(public navCtrl: NavController, public navParams: NavParams,
public corpusProvider: CorpusProvider) {
if (!this.corpusProvider.currentCorpus.validReff) {
public corpusProvider: CorpusProvider,
public toastCtrl: ToastController,
public translateService: TranslateService) {
this.corpusProvider.currentTextRange = new TextRange({
start: ["", "", ""],
end: ["", "", ""]
});
if (!this.corpusProvider.currentCorpus.subCorpora[""]) {
this.corpusProvider.getCTSvalidReff(this.corpusProvider.currentCorpus.source_urn).subscribe((resultXML: string) => {
this.corpusProvider.xml2jsParser.parseString(resultXML, (err, result) => {
let gvr: GetValidReff = this.corpusProvider.ctsJson2mc(result);
gvr.isVisible = true;
this.corpusProvider.currentCorpus.validReff = gvr;
this.corpusProvider.xml2jsParser.parseString(resultXML, (err, result: object) => {
this.addReferences(result, "");
}
);
});
}
this.translateService.get("NO_TEXT_RANGE_CHOSEN").subscribe((value) => {
this.noTextRangeChosenString = value;
});
this.translateService.get("INVALID_TEXT_RANGE").subscribe((value) => {
this.invalidTextRangeString = value;
});
}
showFurtherReferencesOrText(urn: string, currentCitationLevel: number) {
showFurtherReferences(urn: string, currentCitationLevel: number, isStart: boolean) {
if (currentCitationLevel === 1 &&
this.corpusProvider.currentCorpus.citation_level_2 !== CitationLevel[CitationLevel.default]) {
// change display for further references
this.checkFurtherReferences(urn);
if (isStart) {
this.corpusProvider.currentTextRange.start[currentCitationLevel] = "";
}
else {
this.corpusProvider.currentTextRange.end[currentCitationLevel] = "";
}
this.checkFurtherReferences(urn, isStart, false);
}
else if (currentCitationLevel === 2 &&
this.corpusProvider.currentCorpus.citation_level_3 !== CitationLevel[CitationLevel.default]) {
// change display for further references
this.checkFurtherReferences(urn);
}
else {
// go to text display
this.corpusProvider.currentUrn = urn;
this.navCtrl.push(ShowTextPage).then();
if (isStart) {
this.corpusProvider.currentTextRange.start[currentCitationLevel] = "";
}
else {
this.corpusProvider.currentTextRange.end[currentCitationLevel] = "";
}
this.checkFurtherReferences(urn, isStart, true);
}
}
private checkFurtherReferences(urn: string) {
if (urn in this.corpusProvider.currentCorpus.subCorpora) {
this.corpusProvider.currentCorpus.subCorpora[urn].isVisible = !this.corpusProvider.currentCorpus.subCorpora[urn].isVisible;
}
else {
public checkFurtherReferences(urn: string, isStart: boolean, doConcat: boolean) {
let baseUrnPart: string = isStart ? this.corpusProvider.currentTextRange.start[0] : this.corpusProvider.currentTextRange.end[0];
urn = doConcat ? (baseUrnPart + "." + urn) : urn;
if (!(urn in this.corpusProvider.currentCorpus.subCorpora)) {
// append new references and make them visible
this.corpusProvider.getCTSvalidReff(urn).subscribe((resultXML: string) => {
this.corpusProvider.xml2jsParser.parseString(resultXML, (err, result) => {
let gvr: GetValidReff = this.corpusProvider.ctsJson2mc(result);
gvr.isVisible = true;
this.corpusProvider.currentCorpus.subCorpora[urn] = gvr;
let fullUrn: string = this.corpusProvider.currentCorpus.source_urn + ":" + urn;
this.corpusProvider.getCTSvalidReff(fullUrn).subscribe((resultXML: string) => {
this.corpusProvider.xml2jsParser.parseString(resultXML, (err, result: object) => {
this.addReferences(result, urn, ".");
}
);
}, (error: HttpErrorResponse) => {
// no further references available, go to text display
this.corpusProvider.currentUrn = urn;
this.corpusProvider.currentText = "";
this.navCtrl.push(ShowTextPage).then();
});
}
// , (error: HttpErrorResponse) => {
// // no further references available, go to text display
// this.corpusProvider.currentUrn = urn;
// let urnParts = this.corpusProvider.currentUrn.split(":");
// this.corpusProvider.currentLastUrnPart = urnParts[urnParts.length - 1];
// this.corpusProvider.currentText = "";
// this.navCtrl.push(ShowTextPage).then();
// }
}
showText() {
if (!this.corpusProvider.currentTextRange.start[0]) {
let toast = this.toastCtrl.create({
message: this.noTextRangeChosenString,
duration: 3000,
position: 'top'
});
toast.present().then();
}
else {
this.adjustCurrentTextRange();
let startNumber: number = +this.corpusProvider.currentTextRange.start.join("");
let endNumber: number = +this.corpusProvider.currentTextRange.end.join("");
if (startNumber > endNumber) {
let toast = this.toastCtrl.create({
message: this.invalidTextRangeString,
duration: 3000,
position: 'top'
});
toast.present().then();
return;
}
let newUrnBase: string = this.corpusProvider.currentCorpus.source_urn + ":";
this.corpusProvider.currentUrn = newUrnBase + this.corpusProvider.currentLastUrnPart;
this.navCtrl.push(ShowTextPage).then();
}
}
private addReferences(jsonResult: object, index: string, separator: string = "") {
let gvr: GetValidReff = this.corpusProvider.ctsJson2mc(jsonResult);
gvr.isVisible = true;
let replaceString: string = this.corpusProvider.currentCorpus.source_urn + ":" + index + separator;
gvr.reply.reff.urn.forEach((value, index, array) => {
array[index] = array[index].replace(replaceString, "");
});
this.corpusProvider.currentCorpus.subCorpora[index] = gvr.reply.reff.urn;
}
private adjustCurrentTextRange() {
let newUrnStart: string = "";
let newUrnEnd: string = "";
for (let i in this.corpusProvider.currentTextRange.start) {
if (this.corpusProvider.currentTextRange.start[+i]) {
if (!this.corpusProvider.currentTextRange.end[+i]) {
this.corpusProvider.currentTextRange.end[+i] = this.corpusProvider.currentTextRange.start[+i];
}
newUrnStart += (newUrnStart ? "." : "") + this.corpusProvider.currentTextRange.start[+i];
newUrnEnd += (newUrnEnd ? "." : "") + this.corpusProvider.currentTextRange.end[+i];
}
// if (this.corpusProvider.currentTextRange.end[+i]) {
// // remove the other newUrnEnd append line above if you uncomment this one
// newUrnEnd += (newUrnEnd ? "." : "") + this.corpusProvider.currentTextRange.end[+i];
// }
}
this.corpusProvider.currentLastUrnPart = newUrnStart + "-" + newUrnEnd;
}
}
......@@ -25,5 +25,8 @@ export class HomePage {
}
test() {
let a = ["5", "6"];
let c = a.join(".");
let b = 0;
}
}
......@@ -62,7 +62,6 @@ export class PreviewPage {
});
this.exerciseProvider.annisResponse = ar;
}, (error) => {
let a = 0;
console.log(error);
});
}
......
......@@ -7,14 +7,15 @@
<ion-header>
<ion-navbar>
<ion-title>{{corpusProvider.currentCorpus.author}}: {{corpusProvider.currentCorpus.title}}</ion-title>
<ion-title>{{corpusProvider.currentCorpus.author}}: {{corpusProvider.currentCorpus.title}}
{{corpusProvider.currentLastUrnPart}}
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<h1>{{currentTitleMinor}}</h1>
<div *ngIf="corpusProvider.currentText.length > 0; else loading">
<p>{{corpusProvider.currentText}}</p>
<h2>{{ 'EXERCISE_GENERATE' | translate }}</h2>
......
......@@ -22,25 +22,10 @@ export class ShowTextPage {
public Phenomenon = Phenomenon;
public PartOfSpeech = PartOfSpeech;
public currentText: string = "";
public currentTitleMinor: string = "";
constructor(public navCtrl: NavController, public navParams: NavParams,
public corpusProvider: CorpusProvider,
public exerciseProvider: ExerciseProvider) {
let urnParts = this.corpusProvider.currentUrn.split(":");
let lastUrnPart: string = urnParts[urnParts.length - 1];
let citationLevels = lastUrnPart.split(".");
citationLevels.forEach((value, index) => {
if (index === 0) {
this.currentTitleMinor += this.corpusProvider.currentCorpus.citation_level_1 + " " + value;
}
else if (index === 1) {
this.currentTitleMinor += ", " + this.corpusProvider.currentCorpus.citation_level_2 + " " + value;
}
else {
this.currentTitleMinor += ", " + this.corpusProvider.currentCorpus.citation_level_3 + " " + value;
}
});
this.corpusProvider.getCTStextPassage(this.corpusProvider.currentUrn).subscribe((data: object) => {
this.corpusProvider.currentText = data["text"];
});
......
......@@ -9,6 +9,7 @@ import {RequestMC} from "../../models/requestMC";
import {Reply} from "../../models/reply";
import {Reff} from "../../models/reff";
import {ConfigMC} from "../../config";
import {TextRange} from "../../models/textRange";
/*
Generated class for the CorpusProvider provider.
......@@ -25,6 +26,8 @@ export class CorpusProvider {
public currentUrn: string;
public xml2jsParser: Parser;
public currentText: string = "";
public currentTextRange: TextRange = new TextRange({start: ["", "", ""], end: ["", "", ""]});
public currentLastUrnPart: string = "";
constructor(public translate: TranslateService,
public http: HttpClient) {
......@@ -102,7 +105,6 @@ export class CorpusProvider {
private processCorpora(corpusList: CorpusMC[]) {
corpusList.forEach((corpus: CorpusMC) => {
corpus.subCorpora = {};
corpus.validReff = null;
this.availableCorpora.push(corpus);
let authorIndex = this.availableAuthors.map(author => author.name).indexOf(corpus.author);
if (authorIndex > -1) {
......
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