jskos-tools
Advanced tools
Comparing version 0.2.6 to 0.2.7
[ | ||
{ | ||
"RELEVANCE": "very high", | ||
"broader": [ | ||
{ | ||
"uri": "http://www.w3.org/2004/02/skos/core#closeMatch" | ||
} | ||
], | ||
"definition": { | ||
"de": [ | ||
"gleiche Bedeutung" | ||
], | ||
"en": [ | ||
"same meaning" | ||
] | ||
}, | ||
"notation": [ | ||
"=" | ||
], | ||
"uri": "http://www.w3.org/2004/02/skos/core#exactMatch", | ||
"prefLabel": { | ||
"be-tarask": "дакладная адпаведнасьць", | ||
"ca": "equivalència exacta", | ||
"cs": "přesná shoda", | ||
"da": "exact match", | ||
"de": "exact match", | ||
"de": "exakte Übereinstimmung", | ||
"en": "exact match", | ||
"eo": "ekzakta ekvivalento", | ||
"es": "equivalencia exacta", | ||
@@ -18,2 +33,3 @@ "fi": "vastaava käsite", | ||
"hu": "pontos egyezés", | ||
"id": "sama persis", | ||
"it": "corrispondenza esatta", | ||
@@ -30,20 +46,30 @@ "mk": "точно совпаѓање", | ||
"uk": "точна відповідність", | ||
"zh": "精確匹配", | ||
"zh-hans": "精确匹配" | ||
}, | ||
"short": "exact", | ||
"uri": "http://www.w3.org/2004/02/skos/core#exactMatch" | ||
}, | ||
{ | ||
"RELEVANCE": "high", | ||
"broader": [ | ||
{ | ||
"uri": "http://www.w3.org/2004/02/skos/core#closeMatch" | ||
"uri": "http://www.w3.org/2004/02/skos/core#mappingRelation" | ||
} | ||
], | ||
"RELEVANCE": "very high", | ||
"short": "exact" | ||
}, | ||
{ | ||
"definition": { | ||
"de": [ | ||
"in etwa gleiche Bedeutung" | ||
], | ||
"en": [ | ||
"same general idea but not fully identical meaning" | ||
] | ||
}, | ||
"notation": [ | ||
"≈" | ||
], | ||
"uri": "http://www.w3.org/2004/02/skos/core#closeMatch", | ||
"prefLabel": { | ||
"be-tarask": "блізкая адпаведнасьць", | ||
"ca": "equivalència inexacta", | ||
"de": "hohe Übereinstimmung", | ||
"en": "close match", | ||
@@ -53,2 +79,3 @@ "es": "equivalencia inexacta", | ||
"it": "corrispondenza stretta", | ||
"mk": "блиско совпаѓање", | ||
"nb": "nært samsvar", | ||
@@ -60,5 +87,11 @@ "nl": "nabije match", | ||
"ru": "близкое соответствие", | ||
"sr": "блиско поклапање", | ||
"sv": "nära matchning", | ||
"zh-hans": "高度匹配" | ||
}, | ||
"short": "close", | ||
"uri": "http://www.w3.org/2004/02/skos/core#closeMatch" | ||
}, | ||
{ | ||
"RELEVANCE": "medium", | ||
"broader": [ | ||
@@ -69,14 +102,19 @@ { | ||
], | ||
"RELEVANCE": "high", | ||
"short": "close" | ||
}, | ||
{ | ||
"definition": { | ||
"de": [ | ||
"umfassendere Bedeutung" | ||
], | ||
"en": [ | ||
"broader meaning" | ||
] | ||
}, | ||
"notation": [ | ||
">" | ||
], | ||
"uri": "http://www.w3.org/2004/02/skos/core#broadMatch", | ||
"prefLabel": { | ||
"de": "allgemeinere Bedeutung", | ||
"en": "broad match", | ||
"fi": "vastaava laajempi käsite", | ||
"it": "corrispondenza generica", | ||
"mk": "пошироко совпаѓање", | ||
"nb": "bredere samsvar", | ||
@@ -90,7 +128,2 @@ "nl": "brede match", | ||
}, | ||
"broader": [ | ||
{ | ||
"uri": "http://www.w3.org/2004/02/skos/core#mappingRelation" | ||
} | ||
], | ||
"related": [ | ||
@@ -101,13 +134,28 @@ { | ||
], | ||
"RELEVANCE": "medium", | ||
"short": "broad" | ||
"short": "broad", | ||
"uri": "http://www.w3.org/2004/02/skos/core#broadMatch" | ||
}, | ||
{ | ||
"RELEVANCE": "medium", | ||
"broader": [ | ||
{ | ||
"uri": "http://www.w3.org/2004/02/skos/core#mappingRelation" | ||
} | ||
], | ||
"definition": { | ||
"de": [ | ||
"umfassendere Bedeutung" | ||
], | ||
"en": [ | ||
"more specific meaning" | ||
] | ||
}, | ||
"notation": [ | ||
"<" | ||
], | ||
"uri": "http://www.w3.org/2004/02/skos/core#narrowMatch", | ||
"prefLabel": { | ||
"de": "spezifischere Bedeutung", | ||
"en": "narrow match", | ||
"fi": "vastaava suppeampi käsite", | ||
"mk": "потесно совпаѓање", | ||
"nb": "smalere samsvar", | ||
@@ -121,7 +169,2 @@ "nl": "nauwe match", | ||
}, | ||
"broader": [ | ||
{ | ||
"uri": "http://www.w3.org/2004/02/skos/core#mappingRelation" | ||
} | ||
], | ||
"related": [ | ||
@@ -132,14 +175,29 @@ { | ||
], | ||
"RELEVANCE": "medium", | ||
"short": "narrow" | ||
"short": "narrow", | ||
"uri": "http://www.w3.org/2004/02/skos/core#narrowMatch" | ||
}, | ||
{ | ||
"RELEVANCE": "low", | ||
"broader": [ | ||
{ | ||
"uri": "http://www.w3.org/2004/02/skos/core#mappingRelation" | ||
} | ||
], | ||
"definition": { | ||
"de": [ | ||
"assoziative Verknüpfung unterschiedlicher Bedeutungen" | ||
], | ||
"en": [ | ||
"associative link between meanings" | ||
] | ||
}, | ||
"notation": [ | ||
"~" | ||
], | ||
"uri": "http://www.w3.org/2004/02/skos/core#relatedMatch", | ||
"prefLabel": { | ||
"be-tarask": "зьвязаная адпаведнасьць", | ||
"de": "verwandte Bedeutung", | ||
"en": "related match", | ||
"it": "corrispondenza correlata", | ||
"mk": "поврзано совпаѓање", | ||
"nb": "relatert samsvar", | ||
@@ -151,21 +209,31 @@ "nl": "gerelateerde match", | ||
}, | ||
"broader": [ | ||
{ | ||
"uri": "http://www.w3.org/2004/02/skos/core#mappingRelation" | ||
} | ||
], | ||
"RELEVANCE": "low", | ||
"short": "related" | ||
"short": "related", | ||
"uri": "http://www.w3.org/2004/02/skos/core#relatedMatch" | ||
}, | ||
{ | ||
"RELEVANCE": "medium", | ||
"definition": { | ||
"de": [ | ||
"unbekannter Bedeutungszusammenhang" | ||
], | ||
"en": [ | ||
"unknown type of link between meanings" | ||
] | ||
}, | ||
"notation": [ | ||
"→" | ||
], | ||
"uri": "http://www.w3.org/2004/02/skos/core#mappingRelation", | ||
"prefLabel": { | ||
"en": "mapping relation" | ||
"ca": "relació de mapatge", | ||
"de": "allgemeine Mapping-Relation", | ||
"en": "generic mapping relation", | ||
"id": "relasi pemetaan", | ||
"mk": "пресликувачки однос", | ||
"sr": "релација мапирања", | ||
"sv": "mappnings relation", | ||
"zh": "映射關係" | ||
}, | ||
"RELEVANCE": "medium", | ||
"short": "" | ||
"short": "", | ||
"uri": "http://www.w3.org/2004/02/skos/core#mappingRelation" | ||
} | ||
] | ||
] |
@@ -360,8 +360,10 @@ const _ = { | ||
let toLabel = "" | ||
let creator = "" | ||
if (language) { | ||
fromLabel = getNested(mapping, `from.memberSet.0.prefLabel.${language}`) | ||
toLabel = getNested(mapping, `to.memberSet.0.prefLabel.${language}`) | ||
creator = getNested(mapping, `creator.0.prefLabel.${language}`) | ||
} | ||
return {fromNotation, toNotation, fromLabel, toLabel, type} | ||
return {fromNotation, toNotation, fromLabel, toLabel, type, creator} | ||
} | ||
@@ -373,19 +375,14 @@ | ||
const mappingToCSV = (options = {}) => { | ||
// CSV Dialect (see https://frictionlessdata.io/specs/csv-dialect/) | ||
const delimiter = options.delimiter || "," | ||
const quoteChar = options.quoteChar || "\"" | ||
const lineTerminator = options.lineTerminator || "\n" | ||
const doubleQuote = quoteChar + quoteChar | ||
const toCSV = csvSerializer(options) | ||
const language = options.language | ||
const quote = s => quoteChar + (s === null ? "" : s.replace(quoteChar,doubleQuote)) + quoteChar | ||
return mapping => { | ||
let { fromNotation, toNotation, fromLabel, toLabel, type } | ||
let { fromNotation, toNotation, fromLabel, toLabel, type, creator } | ||
= flattenMapping(mapping, options) | ||
if (fromNotation !== "") { | ||
let fields = language | ||
? [ fromNotation, fromLabel, toNotation, toLabel, type ] | ||
? [ fromNotation, fromLabel, toNotation, toLabel, type, creator ] | ||
: [ fromNotation, toNotation, type ] | ||
return fields.map(quote).join(delimiter) + lineTerminator | ||
return toCSV(fields) | ||
} | ||
@@ -396,2 +393,18 @@ } | ||
/** | ||
* Returns a function to serialize an array as CSV row as configured. | ||
* See CSV Dialect (<https://frictionlessdata.io/specs/csv-dialect/>). | ||
* | ||
* @memberof module:jskos-tools | ||
*/ | ||
const csvSerializer = (options = {}) => { | ||
const delimiter = options.delimiter || "," | ||
const quoteChar = options.quoteChar || "\"" | ||
const lineTerminator = options.lineTerminator || "\n" | ||
const doubleQuote = quoteChar + quoteChar | ||
const quote = s => quoteChar + (s === null ? "" : s.replace(quoteChar,doubleQuote)) + quoteChar | ||
return row => row.map(quote).join(delimiter) + lineTerminator | ||
} | ||
/** | ||
* Returns a list of concepts for a mapping. | ||
@@ -398,0 +411,0 @@ * |
{ | ||
"name": "jskos-tools", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"description": "Tools for working with the JSKOS data format.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/gbv/jskos-tools", |
@@ -41,2 +41,3 @@ # JSKOS Tools | ||
- [mappingToCSV](#mappingtocsv) | ||
- [serializeCSV](#serializecsv) | ||
- [conceptsOfMapping](#conceptsofmapping) | ||
@@ -222,2 +223,4 @@ - [compareMappingsDeep](#comparemappingsdeep) | ||
The labels are taken from Wikidata (see script `bin/localize-mapping-types`). | ||
Example object: | ||
@@ -253,3 +256,3 @@ ```json | ||
#### flattenMapping | ||
Converts a mapping into a flat object with for serialization as CSV. Returns an object with fields `fromNotation`, `toNotation`, `type`, and (if option `language` has been provided) `fromLabel` and `toLabel`). | ||
Converts a mapping into a flat object with for serialization as CSV. Returns an object with fields `fromNotation`, `toNotation`, `type`, and (if option `language` has been provided) `fromLabel`, `toLabel`, and `creator`. | ||
@@ -264,4 +267,7 @@ #### mappingToCSV | ||
Concept labels are included only if configuration field `language` is set. The order of CSV fields is fromNotation, (fromLabel,) toNotation, (toLabel,) mappingType. | ||
Concept labels and creators are included only if configuration field `language` is set. The order of CSV fields is fromNotation, (fromLabel,) toNotation, (toLabel,) mappingType. | ||
#### serializeCSV | ||
Returns a function to serialize an array as CSV row as configured with [CSV Dialect](<https://frictionlessdata.io/specs/csv-dialect/>). | ||
#### conceptsOfMapping | ||
@@ -268,0 +274,0 @@ Returns an array of concepts contained in a mapping. `side` can either be `from` or `to`. If `side` is left out, concepts from both sides will be returned. `null` values will be omitted. |
@@ -272,4 +272,4 @@ const assert = require("assert") | ||
assert.equal(csv({delimiter:";", quoteChar:"'"}), "'0';'a''c';''\n") | ||
assert.equal(csv({language:"en", quoteChar:"'"}), "'0','''','a''c','0',''\n") | ||
assert.equal(csv({language:"xx", quoteChar:"'"}), "'0','','a''c','',''\n") | ||
assert.equal(csv({language:"en", quoteChar:"'"}), "'0','''','a''c','0','',''\n") | ||
assert.equal(csv({language:"xx", quoteChar:"'"}), "'0','','a''c','','',''\n") | ||
}) | ||
@@ -276,0 +276,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79138
2134
350