Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 130x 18x 18x 18x 18x 18x 130x 130x 130x 130x 130x 130x 130x 130x 4x 4x 4x 4x 4x 130x 130x 130x 130x 130x 130x 130x 130x 23x 23x 130x 130x 130x 130x 130x 130x 130x 130x 17x 17x 130x 130x 130x 130x 130x 130x 130x 130x 18x 18x 130x 130x 130x 130x 130x 130x 130x 130x 16x 16x 130x 130x 130x 130x 130x 130x 130x 130x 18x 18x 18x 130x 130x 130x | /**
* WikiLambda Vue editor: Wikidata utilities
* Utility functions to handle wikidata entities
*
* @copyright 2020– Abstract Wikipedia team; see AUTHORS.txt
* @license MIT
*/
'use strict';
const wikidataUtils = {
/**
* Extract Wikidata Lexeme IDs from a ZObject
*
* @param {Object} zobject
* @return {Array}
*/
extractWikidataLexemeIds: function ( zobject ) {
const str = JSON.stringify( zobject );
const regexp = /(L[1-9]\d*)/g;
const matches = [ ...str.matchAll( regexp ) ];
const allMatches = matches.map( ( groups ) => groups[ 0 ] );
return [ ...new Set( allMatches ) ];
},
/**
* Extract Wikidata Item IDs from a ZObject
*
* @param {Object} zobject
* @return {Array}
*/
extractWikidataItemIds: function ( zobject ) {
const str = JSON.stringify( zobject );
const regexp = /(Q[1-9]\d*)/g;
const matches = [ ...str.matchAll( regexp ) ];
const allMatches = matches.map( ( groups ) => groups[ 0 ] );
return [ ...new Set( allMatches ) ];
},
/**
* Whether the input string is a valid Wikidata Item ID (Qid)
*
* @param {string} str
* @return {boolean}
*/
isWikidataQid: function ( str ) {
const regexp = /^Q[1-9]\d*$/;
return regexp.test( str );
},
/**
* Whether the input string is a valid Wikidata Lexeme ID
*
* @param {string} str
* @return {boolean}
*/
isWikidataLexemeId: function ( str ) {
const regexp = /^L[1-9]\d*$/;
return regexp.test( str );
},
/**
* Whether the input string is a valid Wikidata Lexeme Form ID
*
* @param {string} str
* @return {boolean}
*/
isWikidataLexemeFormId: function ( str ) {
const regexp = /^L[1-9]\d*-F[1-9]\d*$/;
return regexp.test( str );
},
/**
* Whether the input string is a valid Wikidata Lexeme Sense ID
*
* @param {string} str
* @return {boolean}
*/
isWikidataLexemeSenseId: function ( str ) {
const regexp = /^L[1-9]\d*-S[1-9]\d*$/;
return regexp.test( str );
},
/**
* Whether the input string is a valid Wikidata Property ID
*
* @param {string} str
* @return {boolean}
*/
isWikidataPropertyId: function ( str ) {
const regexp = /^P[1-9]\d*$/;
return regexp.test( str );
}
};
module.exports = wikidataUtils;
|