Commit 2578c2e4 authored by Konstantin Schulz's avatar Konstantin Schulz
Browse files

textRange, showText and vocabularyCheck / ranking now support non-numeric citations

parent b3281dc9
{
"name": "mc_frontend",
"version": "0.9.4",
"version": "0.9.5",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
......
export class Citation {
public level: string;
public isNumeric: boolean;
public label: string;
public value: number;
public level: string;
public subcitations: { [value: number]: Citation; };
public value: number;
constructor(init?: Partial<Citation>) {
Object.assign(this, init);
}
......
......@@ -82,7 +82,7 @@ export class TextRangePage {
if (relevantCitations.some(x => !x)) {
resolve();
}
const urnLastPart: string = relevantCitations.map(x => x.value.toString()).join('.');
const urnLastPart: string = relevantCitations.map(x => x.isNumeric ? x.value.toString() : x.label).join('.');
const fullUrn: string = this.corpusService.currentCorpus.source_urn + (urnLastPart ? ':' + urnLastPart : '');
HelperService.currentError = null;
HelperService.isLoading = true;
......@@ -92,10 +92,13 @@ export class TextRangePage {
const urnList: string[] = result as string[];
const replaceString: string = fullUrn + (urnLastPart ? '.' : ':');
urnList.forEach((urn) => {
const urnModified: string = urn.replace(replaceString, '');
const isNumeric: boolean = !isNaN(+urnModified);
newCitations.push(new Citation({
isNumeric,
level: targetCitationLevel,
label: urn.replace(replaceString, ''),
value: +urn.replace(replaceString, '')
label: urnModified,
value: (isNumeric ? newCitations.length + 1 : +urnModified)
}));
});
newCitations.forEach((citation) => {
......@@ -172,34 +175,43 @@ export class TextRangePage {
this.citationValuesEnd = [];
this.citationValuesStart = [];
this.addMissingCitations(citationLabelsStart, citationLabelsEnd).then(() => {
const citationValuesStart: number[] = this.citationValuesStart;
const citationValuesEnd: number[] = this.citationValuesEnd;
this.compareCitationValues().then((result: boolean) => resolve(result));
}, () => {
// if the citation system does not work, we allow the user to choose the correct citations on his own
resolve(true);
});
});
}
if (citationValuesStart[0] < citationValuesEnd[0]) {
resolve(true);
} else if (citationValuesStart[0] === citationValuesEnd[0]) {
if (citationValuesStart.length > 1) {
if (citationValuesStart[1] < citationValuesEnd[1]) {
resolve(true);
} else if (this.citationValuesStart[1] === citationValuesEnd[1]) {
if (citationValuesStart.length > 2) {
resolve(citationValuesStart[2] <= citationValuesEnd[2]);
} else {
resolve(true);
}
compareCitationValues(): Promise<boolean> {
return new Promise((resolve) => {
const citationValuesStart: number[] = this.citationValuesStart;
const citationValuesEnd: number[] = this.citationValuesEnd;
if (citationValuesStart[0] < citationValuesEnd[0]) {
resolve(true);
} else if (citationValuesStart.concat(citationValuesEnd).some(x => isNaN(x))) {
// there are non-numeric citation values involved, so we cannot easily compare them
resolve(true);
} else if (citationValuesStart[0] === citationValuesEnd[0]) {
if (citationValuesStart.length > 1) {
if (citationValuesStart[1] < citationValuesEnd[1]) {
resolve(true);
} else if (this.citationValuesStart[1] === citationValuesEnd[1]) {
if (citationValuesStart.length > 2) {
resolve(citationValuesStart[2] <= citationValuesEnd[2]);
} else {
resolve(false);
resolve(true);
}
} else {
resolve(true);
resolve(false);
}
} else {
resolve(false);
resolve(true);
}
}, () => {
// if the citation system does not work, we allow the user to choose the correct citations on his own
resolve(true);
});
} else {
resolve(false);
}
});
}
......@@ -358,7 +370,13 @@ export class TextRangePage {
return;
}
const newUrnBase: string = this.corpusService.currentCorpus.source_urn + ':';
this.corpusService.currentUrn = newUrnBase + this.citationValuesStart.join('.') + '-' + this.citationValuesEnd.join('.');
if (this.citationValuesStart.concat(this.citationValuesEnd).some(x => isNaN(x))) {
this.corpusService.currentUrn = newUrnBase +
this.corpusService.currentTextRange.start.filter(x => x).join('.') + '-' +
this.corpusService.currentTextRange.end.filter(x => x).join('.');
} else {
this.corpusService.currentUrn = newUrnBase + this.citationValuesStart.join('.') + '-' + this.citationValuesEnd.join('.');
}
HelperService.mostRecentSetup = new ApplicationState({
currentUrn: this.corpusService.currentUrn,
currentCorpus: this.corpusService.currentCorpus,
......
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