| ; | |
| Object.defineProperty(exports, "__esModule", { | |
| value: true | |
| }); | |
| exports.default = exports.parse = exports.parseEntities = parseEntities; | |
| exports.parseAsync = exports.parseEntitiesAsync = parseEntitiesAsync; | |
| exports.parseEntity = parseEntity; | |
| var _core = require("@citation-js/core"); | |
| var response = _interopRequireWildcard(require("./response.js")); | |
| var _prop = require("./prop.js"); | |
| var _props = _interopRequireDefault(require("./props.json")); | |
| var _customProps = _interopRequireDefault(require("./customProps.json")); | |
| var _ignoredProps = _interopRequireDefault(require("./ignoredProps.json")); | |
| function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } | |
| function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | |
| function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | |
| function resolve(parts, { | |
| claims | |
| }) { | |
| const [prop, qualifier] = parts[0].split('#'); | |
| if (!claims[prop] || !claims[prop].length) { | |
| return; | |
| } | |
| if (parts.length === 1) { | |
| if (qualifier) { | |
| if (claims[prop][0].qualifiers[qualifier]) { | |
| return claims[prop][0].qualifiers[qualifier].map(value => ({ | |
| value | |
| })); | |
| } | |
| return; | |
| } | |
| return claims[prop]; | |
| } | |
| return resolve(parts.slice(1), claims[prop][0].value); | |
| } | |
| function resolveProp(prop_, entity, unknown) { | |
| const parts = prop_.split('.'); | |
| unknown.delete(parts[0]); | |
| return resolve(parts, entity); | |
| } | |
| function prepareValue(statement, entity, unknown) { | |
| if (typeof statement !== 'object') { | |
| const value = resolveProp(statement, entity, unknown); | |
| return value && value[0].value; | |
| } | |
| const values = [].concat(...statement.props.map(prop => resolveProp(prop, entity, unknown)).filter(Boolean)); | |
| if (statement.values === 'all') { | |
| return values[0] && values; | |
| } else { | |
| return values[0] && values[0].value; | |
| } | |
| } | |
| function parseEntity(entity) { | |
| const data = { | |
| id: entity.id, | |
| custom: { | |
| QID: entity.id | |
| }, | |
| source: 'Wikidata' | |
| }; | |
| const unknown = new Set(Object.keys(entity.claims)); | |
| for (const prop in _props.default) { | |
| const input = prepareValue(_props.default[prop], entity, unknown); | |
| if (input) { | |
| const output = (0, _prop.parseProp)(prop, input, entity); | |
| if (output) { | |
| data[prop] = output; | |
| } | |
| } | |
| } | |
| for (const prop in _customProps.default) { | |
| const input = prepareValue(_customProps.default[prop], entity, unknown); | |
| if (input) { | |
| const output = (0, _prop.parseProp)(prop, input, entity); | |
| if (output) { | |
| data.custom[prop] = output; | |
| } | |
| } | |
| } | |
| for (const prop of unknown) { | |
| if (prop in _ignoredProps.default) { | |
| continue; | |
| } | |
| _core.logger.unmapped('[plugin-wikidata]', 'property', prop); | |
| } | |
| if (!data.title) { | |
| data.title = (0, _prop.getLabel)(entity); | |
| } | |
| if (data.type.slice(0, 6) === 'review') { | |
| delete data.keyword; | |
| } else { | |
| delete data['reviewed-title']; | |
| delete data['reviewed-author']; | |
| } | |
| if (data.recipient) { | |
| data.type = 'personal_communication'; | |
| } | |
| if (data['event-title']) { | |
| data.type = 'paper-conference'; | |
| } | |
| if (typeof data['part-number'] === 'number') { | |
| delete data['part-title']; | |
| } else if (typeof data['part-title'] === 'string') { | |
| delete data['part-number']; | |
| } | |
| if (data.type !== 'chapter' && data['chapter-number']) { | |
| delete data['chapter-number']; | |
| } | |
| if (data['original-author'] && !data.author) { | |
| data.author = data['original-author']; | |
| } | |
| return data; | |
| } | |
| async function parseEntitiesAsync({ | |
| entities | |
| }) { | |
| return (await response.parseAsync(entities)).map(parseEntity); | |
| } | |
| function parseEntities({ | |
| entities | |
| }) { | |
| return response.parse(entities).map(parseEntity); | |
| } |
Xet Storage Details
- Size:
- 4.37 kB
- Xet hash:
- f7b060ed646e4444834df20d13135daee7bf0b9dd7790df96ea2af05ee5218c5
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.