[Library | new-theme]: parsingFunctions.class.ts: Added method "checkAndAddEoscSubject()" which is called for all subjects (classified or not) and sets eosc subjects when the label is found in "eoscSubjects".
This commit is contained in:
parent
0f747829f0
commit
b0c9ee3736
|
@ -578,6 +578,8 @@ export class ParsingFunctions {
|
|||
let fos: string[];
|
||||
let sdg: string[];
|
||||
|
||||
let setOfEoscSubjects: Set<string> = new Set();
|
||||
|
||||
let subject;
|
||||
let length = Array.isArray(_subjects) ? _subjects.length : 1;
|
||||
|
||||
|
@ -599,50 +601,79 @@ export class ParsingFunctions {
|
|||
if (classifiedSubjects == undefined) {
|
||||
classifiedSubjects = new Map<string, string[]>();
|
||||
}
|
||||
|
||||
// TODO: remove this when data are ok!
|
||||
if(subject.classname == 'eosc') {
|
||||
subject.classname = 'EOSC';
|
||||
}
|
||||
|
||||
if (!classifiedSubjects.has(subject.classname)) {
|
||||
classifiedSubjects.set(subject.classname, new Array<string>());
|
||||
}
|
||||
|
||||
let content: string = subject.content+"";
|
||||
let found: boolean = false;
|
||||
// looping through our declared array
|
||||
this.eoscSubjects.forEach(item => {
|
||||
if(content && content == item.label) {
|
||||
found = true;
|
||||
this.eoscSubjectsFound.push(item);
|
||||
classifiedSubjects.get(subject.classname).push(item.value);
|
||||
}
|
||||
});
|
||||
if(!found) {
|
||||
let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, classifiedSubjects, subject, content);
|
||||
let found: boolean = checkAndAddEoscSubjectResp["found"];
|
||||
if(found) {
|
||||
setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"];
|
||||
classifiedSubjects = checkAndAddEoscSubjectResp["classifiedSubjects"];
|
||||
} else {
|
||||
if (!classifiedSubjects.has(subject.classname)) {
|
||||
classifiedSubjects.set(subject.classname, new Array<string>());
|
||||
}
|
||||
classifiedSubjects.get(subject.classname).push(content);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (subject.classid == "keyword") {
|
||||
let content: string = subject.content+"";
|
||||
if (subjects == undefined) {
|
||||
subjects = new Array<string>();
|
||||
}
|
||||
subjects.push(content);
|
||||
let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, classifiedSubjects, subject, content);
|
||||
let found: boolean = checkAndAddEoscSubjectResp["found"];
|
||||
if(found) {
|
||||
setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"];
|
||||
classifiedSubjects = checkAndAddEoscSubjectResp["classifiedSubjects"];
|
||||
} else {
|
||||
if (subjects == undefined) {
|
||||
subjects = new Array<string>();
|
||||
}
|
||||
subjects.push(content);
|
||||
}
|
||||
} else {
|
||||
let content: string = subject.content+"";
|
||||
let classname: string = subject.classname + "";
|
||||
if (subjects == undefined) {
|
||||
subjects = new Array<string>();
|
||||
}
|
||||
subjects.push(content);
|
||||
let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, classifiedSubjects, subject, content);
|
||||
let found: boolean = checkAndAddEoscSubjectResp["found"];
|
||||
if(found) {
|
||||
setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"];
|
||||
classifiedSubjects = checkAndAddEoscSubjectResp["classifiedSubjects"];
|
||||
} else {
|
||||
let classname: string = subject.classname + "";
|
||||
if (subjects == undefined) {
|
||||
subjects = new Array<string>();
|
||||
}
|
||||
subjects.push(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return [subjects, otherSubjects, classifiedSubjects, fos, sdg, this.eoscSubjectsFound];
|
||||
}
|
||||
|
||||
checkAndAddEoscSubject(setOfEoscSubjects: Set<string>, classifiedSubjects, subject, content) {
|
||||
let found: boolean = false;
|
||||
|
||||
if(!setOfEoscSubjects.has(content)) {
|
||||
// looping through our declared array
|
||||
this.eoscSubjects.forEach(item => {
|
||||
if (content && content == item.label) {
|
||||
if (classifiedSubjects == undefined) {
|
||||
classifiedSubjects = new Map<string, string[]>();
|
||||
}
|
||||
|
||||
if (!classifiedSubjects.has("EOSC")) {
|
||||
classifiedSubjects.set("EOSC", new Array<string>());
|
||||
}
|
||||
|
||||
found = true;
|
||||
this.eoscSubjectsFound.push(item);
|
||||
setOfEoscSubjects.add(content);
|
||||
classifiedSubjects.get("EOSC").push(item.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
return {"found": found, "setOfEoscSubject": setOfEoscSubjects, "classifiedSubjects": classifiedSubjects};
|
||||
}
|
||||
|
||||
parseContexts(_contexts: any): Context[] {
|
||||
let contexts = new Array<Context>();
|
||||
|
|
Loading…
Reference in New Issue