let s = IO.uploadedFile(file).asSpreadsheet();
machine_prefix_en= 'Machine for '
machine_prefix_de= 'Maschine für '
s.rows().forEach(row =>{
let concept = skos.createConcept({
uri: '
http:sampleuri.com/id
/'+ row['id'],
notation:
row.id })
//adding the current row to a taxon
//concept.topConceptOf= graph.namedNode('
http:sampleuri.com/conceptschema1')
graph.addTriples
try{
prefLabelwithLang(concept,machine_prefix_en+row['label en'],'en')
prefLabelwithLang(concept,machine_prefix_de+row['label de'],'de')
let conceptLangEn = graph.langString(row['concept en'],'en')
concept.add(skos.definition, conceptLangEn);
let conceptLangDe = graph.langString(row['concept de'],'de')
concept.add(skos.definition, conceptLangDe);
//first level of clasification
firstLevelTaxon(concept, row['id'])
}
catch{
console.log()
}
}//end row
)//end forEach
//working with german
function splitStringAtParentheses(input) {
// Use a regular expression to match the content between parentheses
const match = input.match(/^(.*?)\s*\(([^)]+)\)$/);
// If a match is found, return an array with both parts, otherwise return null
if (match) {
return [match[1].trim(), match[2].trim()];
} else {
return null;
}
}
function prefLabelwithLang(my_concept,my_label,my_lang){
let prefLabelLang = graph.langString(my_label,my_lang)
my_concept.add(skos.prefLabel, prefLabelLang);
}
function altLabelwithLang(my_concept,my_label,my_lang){
let altLabelLang = graph.langString(my_label,my_lang)
my_concept.add(skos.altLabel, altLabelLang);
}
function firstLevelTaxon(my_concept, id){
const taxonLevel1 =["1.17.03.01.00.00","1.17.03.02.00.00","1.17.03.03.00.00","1.17.03.04.00.00","1.17.03.05.00.00","1.17.03.06.00.00"]
if (taxonLevel1.includes(id)){
my_concept.broader = graph.namedNode('
http:sampleuri.com//1.17.03.00.00.00')
}//if not first level
else{
const idArray = id.split(".");
//evaluating the taxon
if (idArray[-1] !== '00'){
broaded_id = '
http:sampleuri.com//
1.17.03.'+idArray[3]+'.'+idArray[4]+'.00'
my_concept.broader = graph.namedNode(broaded_id)
}
}//elnd else first level
//console.log()
}//firstLevelTaxon
function prefLabelwithLang(my_concept,my_label,my_lang){
let prefLabelLang = graph.langString(my_label,my_lang)
my_concept.add(skos.prefLabel, prefLabelLang);
}
function altLabelwithLang(my_concept,my_label,my_lang){
let altLabelLang = graph.langString(my_label,my_lang)
my_concept.add(skos.altLabel, altLabelLang);
}