idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
24,500 | protected void accountForFetchedKey ( byte [ ] key ) { fetched ++ ; if ( streamStats != null ) { streamStats . reportStreamingFetch ( operation ) ; } if ( recordsPerPartition <= 0 ) { return ; } Integer keyPartitionId = getKeyPartitionId ( key ) ; Long partitionFetch = partitionFetches . get ( keyPartitionId ) ; Utils ... | Account for key being fetched . |
24,501 | protected StreamRequestHandlerState determineRequestHandlerState ( String itemTag ) { if ( keyIterator . hasNext ( ) && ! fetchedEnoughForAllPartitions ( ) ) { return StreamRequestHandlerState . WRITING ; } else { logger . info ( "Finished fetch " + itemTag + " for store '" + storageEngine . getName ( ) + "' with parti... | Determines if still WRITING or COMPLETE . |
24,502 | protected List < Versioned < V > > resolveAndConstructVersionsToPersist ( List < Versioned < V > > valuesInStorage , List < Versioned < V > > multiPutValues ) { List < Versioned < V > > obsoleteVals = new ArrayList < Versioned < V > > ( multiPutValues . size ( ) ) ; for ( Versioned < V > value : multiPutValues ) { Iter... | Computes the final list of versions to be stored on top of what is currently being stored . Final list is valuesInStorage modified in place |
24,503 | private < T > InternalProviderImpl installInternalProvider ( Class < T > clazz , String bindingName , InternalProviderImpl < ? extends T > internalProvider , boolean isBound , boolean isTestProvider ) { if ( bindingName == null ) { if ( isBound ) { return installUnNamedProvider ( mapClassesToUnNamedBoundProviders , cla... | Installs a provider either in the scope or the pool of unbound providers . |
24,504 | protected void reset ( ) { super . reset ( ) ; mapClassesToNamedBoundProviders . clear ( ) ; mapClassesToUnNamedBoundProviders . clear ( ) ; hasTestModules = false ; installBindingForScope ( ) ; } | Resets the state of the scope . Useful for automation testing when we want to reset the scope used to install test modules . |
24,505 | public synchronized T get ( Scope scope ) { if ( instance != null ) { return instance ; } if ( providerInstance != null ) { if ( isProvidingSingletonInScope ) { instance = providerInstance . get ( ) ; providerInstance = null ; return instance ; } return providerInstance . get ( ) ; } if ( factoryClass != null && factor... | of the unbound provider ( |
24,506 | public static void closeScope ( Object name ) { ScopeNode scope = ( ScopeNode ) MAP_KEY_TO_SCOPE . remove ( name ) ; if ( scope != null ) { ScopeNode parentScope = scope . getParentScope ( ) ; if ( parentScope != null ) { parentScope . removeChild ( scope ) ; } else { ConfigurationHolder . configuration . onScopeForest... | Detach a scope from its parent this will trigger the garbage collection of this scope and it s sub - scopes if they are not referenced outside of Toothpick . |
24,507 | public static void reset ( ) { for ( Object name : Collections . list ( MAP_KEY_TO_SCOPE . keys ( ) ) ) { closeScope ( name ) ; } ConfigurationHolder . configuration . onScopeForestReset ( ) ; ScopeImpl . resetUnBoundProviders ( ) ; } | Clears all scopes . Useful for testing and not getting any leak ... |
24,508 | void notifyMwRevisionProcessors ( MwRevision mwRevision , boolean isCurrent ) { if ( mwRevision == null || mwRevision . getPageId ( ) <= 0 ) { return ; } for ( MwRevisionProcessorBroker . RevisionSubscription rs : this . revisionSubscriptions ) { if ( rs . onlyCurrentRevisions == isCurrent && ( rs . model == null || mw... | Notifies all interested subscribers of the given revision . |
24,509 | static ItemIdValueImpl fromIri ( String iri ) { int separator = iri . lastIndexOf ( '/' ) + 1 ; try { return new ItemIdValueImpl ( iri . substring ( separator ) , iri . substring ( 0 , separator ) ) ; } catch ( IllegalArgumentException e ) { throw new IllegalArgumentException ( "Invalid Wikibase entity IRI: " + iri , e... | Parses an item IRI |
24,510 | void resetCurrentRevisionData ( ) { this . revisionId = NO_REVISION_ID ; this . parentRevisionId = NO_REVISION_ID ; this . text = null ; this . comment = null ; this . format = null ; this . timeStamp = null ; this . model = null ; } | Resets all member fields that hold information about the revision that is currently being processed . |
24,511 | private static MonolingualTextValue toTerm ( MonolingualTextValue term ) { return term instanceof TermImpl ? term : new TermImpl ( term . getLanguageCode ( ) , term . getText ( ) ) ; } | We need to make sure the terms are of the right type otherwise they will not be serialized correctly . |
24,512 | private void writePropertyData ( ) { try ( PrintStream out = new PrintStream ( ExampleHelpers . openExampleFileOuputStream ( "properties.csv" ) ) ) { out . println ( "Id" + ",Label" + ",Description" + ",URL" + ",Datatype" + ",Uses in statements" + ",Items with such statements" + ",Uses in statements with qualifiers" + ... | Writes the data collected about properties to a file . |
24,513 | private void writeClassData ( ) { try ( PrintStream out = new PrintStream ( ExampleHelpers . openExampleFileOuputStream ( "classes.csv" ) ) ) { out . println ( "Id" + ",Label" + ",Description" + ",URL" + ",Image" + ",Number of direct instances" + ",Number of direct subclasses" + ",Direct superclasses" + ",All superclas... | Writes the data collected about classes to a file . |
24,514 | private void printClassRecord ( PrintStream out , ClassRecord classRecord , EntityIdValue entityIdValue ) { printTerms ( out , classRecord . itemDocument , entityIdValue , "\"" + getClassLabel ( entityIdValue ) + "\"" ) ; printImage ( out , classRecord . itemDocument ) ; out . print ( "," + classRecord . itemCount + ",... | Prints the data for a single class to the given stream . This will be a single line in CSV . |
24,515 | private void printImage ( PrintStream out , ItemDocument itemDocument ) { String imageFile = null ; if ( itemDocument != null ) { for ( StatementGroup sg : itemDocument . getStatementGroups ( ) ) { boolean isImage = "P18" . equals ( sg . getProperty ( ) . getId ( ) ) ; if ( ! isImage ) { continue ; } for ( Statement s ... | Prints the URL of a thumbnail for the given item document to the output or a default image if no image is given for the item . |
24,516 | private void printPropertyRecord ( PrintStream out , PropertyRecord propertyRecord , PropertyIdValue propertyIdValue ) { printTerms ( out , propertyRecord . propertyDocument , propertyIdValue , null ) ; String datatype = "Unknown" ; if ( propertyRecord . propertyDocument != null ) { datatype = getDatatypeLabel ( proper... | Prints the data of one property to the given output . This will be a single line in CSV . |
24,517 | private String getDatatypeLabel ( DatatypeIdValue datatype ) { if ( datatype . getIri ( ) == null ) { return "Unknown" ; } switch ( datatype . getIri ( ) ) { case DatatypeIdValue . DT_COMMONS_MEDIA : return "Commons media" ; case DatatypeIdValue . DT_GLOBE_COORDINATES : return "Globe coordinates" ; case DatatypeIdValue... | Returns an English label for a given datatype . |
24,518 | private String getPropertyLabel ( PropertyIdValue propertyIdValue ) { PropertyRecord propertyRecord = this . propertyRecords . get ( propertyIdValue ) ; if ( propertyRecord == null || propertyRecord . propertyDocument == null ) { return propertyIdValue . getId ( ) ; } else { return getLabel ( propertyIdValue , property... | Returns a string that should be used as a label for the given property . |
24,519 | private String getClassLabel ( EntityIdValue entityIdValue ) { ClassRecord classRecord = this . classRecords . get ( entityIdValue ) ; String label ; if ( classRecord == null || classRecord . itemDocument == null ) { label = entityIdValue . getId ( ) ; } else { label = getLabel ( entityIdValue , classRecord . itemDocum... | Returns a string that should be used as a label for the given item . The method also ensures that each label is used for only one class . Other classes with the same label will have their QID added for disambiguation . |
24,520 | public void writeValue ( TimeValue value , Resource resource ) throws RDFHandlerException { this . rdfWriter . writeTripleValueObject ( resource , RdfWriter . RDF_TYPE , RdfWriter . WB_TIME_VALUE ) ; this . rdfWriter . writeTripleValueObject ( resource , RdfWriter . WB_TIME , TimeValueConverter . getTimeLiteral ( value... | Write the auxiliary RDF data for encoding the given value . |
24,521 | public static void main ( String [ ] args ) throws LoginFailedException , IOException , MediaWikiApiErrorException { ExampleHelpers . configureLogging ( ) ; printDocumentation ( ) ; SetLabelsForNumbersBot bot = new SetLabelsForNumbersBot ( ) ; ExampleHelpers . processEntitiesFromWikidataDump ( bot ) ; bot . finish ( ) ... | Main method to run the bot . |
24,522 | protected void addLabelForNumbers ( ItemIdValue itemIdValue ) { String qid = itemIdValue . getId ( ) ; try { ItemDocument currentItemDocument = ( ItemDocument ) dataFetcher . getEntityDocument ( qid ) ; if ( currentItemDocument == null ) { System . out . println ( "*** " + qid + " could not be fetched. Maybe it has bee... | Fetches the current online data for the given item and adds numerical labels if necessary . |
24,523 | protected boolean lacksSomeLanguage ( ItemDocument itemDocument ) { for ( int i = 0 ; i < arabicNumeralLanguages . length ; i ++ ) { if ( ! itemDocument . getLabels ( ) . containsKey ( arabicNumeralLanguages [ i ] ) ) { return true ; } } return false ; } | Returns true if the given item document lacks a label for at least one of the languages covered . |
24,524 | public void writeFinalResults ( ) { printStatus ( ) ; try ( PrintStream out = new PrintStream ( ExampleHelpers . openExampleFileOuputStream ( "life-expectancies.csv" ) ) ) { for ( int i = 0 ; i < lifeSpans . length ; i ++ ) { if ( peopleCount [ i ] != 0 ) { out . println ( i + "," + ( double ) lifeSpans [ i ] / peopleC... | Writes the results of the processing to a file . |
24,525 | private static void createDirectory ( Path path ) throws IOException { try { Files . createDirectory ( path ) ; } catch ( FileAlreadyExistsException e ) { if ( ! Files . isDirectory ( path ) ) { throw e ; } } } | Create a directory at the given path if it does not exist yet . |
24,526 | public static FileOutputStream openResultFileOuputStream ( Path resultDirectory , String filename ) throws IOException { Path filePath = resultDirectory . resolve ( filename ) ; return new FileOutputStream ( filePath . toFile ( ) ) ; } | Opens a new FileOutputStream for a file of the given name in the given result directory . Any file of this name that exists already will be replaced . The caller is responsible for eventually closing the stream . |
24,527 | private void addSuperClasses ( Integer directSuperClass , ClassRecord subClassRecord ) { if ( subClassRecord . superClasses . contains ( directSuperClass ) ) { return ; } subClassRecord . superClasses . add ( directSuperClass ) ; ClassRecord superClassRecord = getClassRecord ( directSuperClass ) ; if ( superClassRecord... | Recursively add indirect subclasses to a class record . |
24,528 | private Integer getNumId ( String idString , boolean isUri ) { String numString ; if ( isUri ) { if ( ! idString . startsWith ( "http://www.wikidata.org/entity/" ) ) { return 0 ; } numString = idString . substring ( "http://www.wikidata.org/entity/Q" . length ( ) ) ; } else { numString = idString . substring ( 1 ) ; } ... | Extracts a numeric id from a string which can be either a Wikidata entity URI or a short entity or property id . |
24,529 | private void countCooccurringProperties ( StatementDocument statementDocument , UsageRecord usageRecord , PropertyIdValue thisPropertyIdValue ) { for ( StatementGroup sg : statementDocument . getStatementGroups ( ) ) { if ( ! sg . getProperty ( ) . equals ( thisPropertyIdValue ) ) { Integer propertyId = getNumId ( sg .... | Counts each property for which there is a statement in the given item document ignoring the property thisPropertyIdValue to avoid properties counting themselves . |
24,530 | private InputStream runSparqlQuery ( String query ) throws IOException { try { String queryString = "query=" + URLEncoder . encode ( query , "UTF-8" ) + "&format=json" ; URL url = new URL ( "https://query.wikidata.org/sparql?" + queryString ) ; HttpURLConnection connection = ( HttpURLConnection ) url . openConnection (... | Executes a given SPARQL query and returns a stream with the result in JSON format . |
24,531 | private void writePropertyData ( ) { try ( PrintStream out = new PrintStream ( openResultFileOuputStream ( resultDirectory , "properties.json" ) ) ) { out . println ( "{" ) ; int count = 0 ; for ( Entry < Integer , PropertyRecord > propertyEntry : this . propertyRecords . entrySet ( ) ) { if ( count > 0 ) { out . print... | Writes all data that was collected about properties to a json file . |
24,532 | private void writeClassData ( ) { try ( PrintStream out = new PrintStream ( openResultFileOuputStream ( resultDirectory , "classes.json" ) ) ) { out . println ( "{" ) ; for ( Entry < Integer , ClassRecord > classEntry : this . classRecords . entrySet ( ) ) { if ( classEntry . getValue ( ) . subclassCount == 0 && classE... | Writes all data that was collected about classes to a json file . |
24,533 | public static String formatTimeISO8601 ( TimeValue value ) { StringBuilder builder = new StringBuilder ( ) ; DecimalFormat yearForm = new DecimalFormat ( FORMAT_YEAR ) ; DecimalFormat timeForm = new DecimalFormat ( FORMAT_OTHER ) ; if ( value . getYear ( ) > 0 ) { builder . append ( "+" ) ; } builder . append ( yearFor... | Returns a representation of the date from the value attributes as ISO 8601 encoding . |
24,534 | public static String formatBigDecimal ( BigDecimal number ) { if ( number . signum ( ) != - 1 ) { return "+" + number . toString ( ) ; } else { return number . toString ( ) ; } } | Returns a signed string representation of the given number . |
24,535 | private static DumpContentType guessDumpContentType ( String fileName ) { String lcDumpName = fileName . toLowerCase ( ) ; if ( lcDumpName . contains ( ".json.gz" ) ) { return DumpContentType . JSON ; } else if ( lcDumpName . contains ( ".json.bz2" ) ) { return DumpContentType . JSON ; } else if ( lcDumpName . contains... | Guess the type of the given dump from its filename . |
24,536 | private static String guessDumpDate ( String fileName ) { Pattern p = Pattern . compile ( "([0-9]{8})" ) ; Matcher m = p . matcher ( fileName ) ; if ( m . find ( ) ) { return m . group ( 1 ) ; } else { logger . info ( "Could not guess date of the dump file \"" + fileName + "\". Defaulting to YYYYMMDD." ) ; return "YYYY... | Guess the date of the dump from the given dump file name . |
24,537 | public void add ( StatementRank rank , Resource subject ) { if ( this . bestRank == rank ) { subjects . add ( subject ) ; } else if ( bestRank == StatementRank . NORMAL && rank == StatementRank . PREFERRED ) { subjects . clear ( ) ; bestRank = StatementRank . PREFERRED ; subjects . add ( subject ) ; } } | Adds a Statement . |
24,538 | public void writeAuxiliaryTriples ( ) throws RDFHandlerException { for ( PropertyRestriction pr : this . someValuesQueue ) { writeSomeValueRestriction ( pr . propertyUri , pr . rangeUri , pr . subject ) ; } this . someValuesQueue . clear ( ) ; this . valueRdfConverter . writeAuxiliaryTriples ( ) ; } | Writes all auxiliary triples that have been buffered recently . This includes OWL property restrictions but it also includes any auxiliary triples required by complex values that were used in snaks . |
24,539 | void writeSomeValueRestriction ( String propertyUri , String rangeUri , Resource bnode ) throws RDFHandlerException { this . rdfWriter . writeTripleValueObject ( bnode , RdfWriter . RDF_TYPE , RdfWriter . OWL_RESTRICTION ) ; this . rdfWriter . writeTripleUriObject ( bnode , RdfWriter . OWL_ON_PROPERTY , propertyUri ) ;... | Writes a buffered some - value restriction . |
24,540 | String getRangeUri ( PropertyIdValue propertyIdValue ) { String datatype = this . propertyRegister . getPropertyType ( propertyIdValue ) ; if ( datatype == null ) return null ; switch ( datatype ) { case DatatypeIdValue . DT_MONOLINGUAL_TEXT : this . rdfConversionBuffer . addDatatypeProperty ( propertyIdValue ) ; retur... | Returns the class of datatype URI that best characterizes the range of the given property based on its datatype . |
24,541 | void addSomeValuesRestriction ( Resource subject , String propertyUri , String rangeUri ) { this . someValuesQueue . add ( new PropertyRestriction ( subject , propertyUri , rangeUri ) ) ; } | Adds the given some - value restriction to the list of restrictions that should still be serialized . The given resource will be used as a subject . |
24,542 | Map < String , EntityDocument > getEntityDocumentMap ( int numOfEntities , WbGetEntitiesActionData properties ) throws MediaWikiApiErrorException , IOException { if ( numOfEntities == 0 ) { return Collections . emptyMap ( ) ; } configureProperties ( properties ) ; return this . wbGetEntitiesAction . wbGetEntities ( pro... | Creates a map of identifiers or page titles to documents retrieved via the APIs . |
24,543 | private void setRequestProps ( WbGetEntitiesActionData properties ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( "info|datatype" ) ; if ( ! this . filter . excludeAllLanguages ( ) ) { builder . append ( "|labels|aliases|descriptions" ) ; } if ( ! this . filter . excludeAllProperties ( ) ) { buil... | Sets the value for the API s props parameter based on the current settings . |
24,544 | private void setRequestLanguages ( WbGetEntitiesActionData properties ) { if ( this . filter . excludeAllLanguages ( ) || this . filter . getLanguageFilter ( ) == null ) { return ; } properties . languages = ApiConnection . implodeObjects ( this . filter . getLanguageFilter ( ) ) ; } | Sets the value for the API s languages parameter based on the current settings . |
24,545 | private void setRequestSitefilter ( WbGetEntitiesActionData properties ) { if ( this . filter . excludeAllSiteLinks ( ) || this . filter . getSiteLinkFilter ( ) == null ) { return ; } properties . sitefilter = ApiConnection . implodeObjects ( this . filter . getSiteLinkFilter ( ) ) ; } | Sets the value for the API s sitefilter parameter based on the current settings . |
24,546 | void processSiteRow ( String siteRow ) { String [ ] row = getSiteRowFields ( siteRow ) ; String filePath = "" ; String pagePath = "" ; String dataArray = row [ 8 ] . substring ( row [ 8 ] . indexOf ( '{' ) , row [ 8 ] . length ( ) - 2 ) ; Matcher matcher = Pattern . compile ( "[{;](([^;}{][^;}{]*)|[}])" ) . matcher ( d... | Processes a row of the sites table and stores the site information found therein . |
24,547 | public synchronized void start ( ) { if ( ( todoFlags & RECORD_CPUTIME ) != 0 ) { currentStartCpuTime = getThreadCpuTime ( threadId ) ; } else { currentStartCpuTime = - 1 ; } if ( ( todoFlags & RECORD_WALLTIME ) != 0 ) { currentStartWallTime = System . nanoTime ( ) ; } else { currentStartWallTime = - 1 ; } isRunning = ... | Start the timer . |
24,548 | public static void startNamedTimer ( String timerName , int todoFlags , long threadId ) { getNamedTimer ( timerName , todoFlags , threadId ) . start ( ) ; } | Start a timer of the given string name for the current thread . If no such timer exists yet then it will be newly created . |
24,549 | public static long stopNamedTimer ( String timerName , int todoFlags ) { return stopNamedTimer ( timerName , todoFlags , Thread . currentThread ( ) . getId ( ) ) ; } | Stop a timer of the given string name for the current thread . If no such timer exists - 1 will be returned . Otherwise the return value is the CPU time that was measured . |
24,550 | public static void resetNamedTimer ( String timerName , int todoFlags , long threadId ) { getNamedTimer ( timerName , todoFlags , threadId ) . reset ( ) ; } | Reset a timer of the given string name for the given thread . If no such timer exists yet then it will be newly created . |
24,551 | public static Timer getNamedTimer ( String timerName , int todoFlags ) { return getNamedTimer ( timerName , todoFlags , Thread . currentThread ( ) . getId ( ) ) ; } | Get a timer of the given string name and todos for the current thread . If no such timer exists yet then it will be newly created . |
24,552 | public static Timer getNamedTimer ( String timerName , int todoFlags , long threadId ) { Timer key = new Timer ( timerName , todoFlags , threadId ) ; registeredTimers . putIfAbsent ( key , key ) ; return registeredTimers . get ( key ) ; } | Get a timer of the given string name for the given thread . If no such timer exists yet then it will be newly created . |
24,553 | public static Timer getNamedTotalTimer ( String timerName ) { long totalCpuTime = 0 ; long totalSystemTime = 0 ; int measurements = 0 ; int timerCount = 0 ; int todoFlags = RECORD_NONE ; Timer previousTimer = null ; for ( Map . Entry < Timer , Timer > entry : registeredTimers . entrySet ( ) ) { if ( entry . getValue ( ... | Collect the total times measured by all known named timers of the given name . This is useful to add up times that were collected across separate threads . |
24,554 | public void performActions ( ) { if ( this . clientConfiguration . getActions ( ) . isEmpty ( ) ) { this . clientConfiguration . printHelp ( ) ; return ; } this . dumpProcessingController . setOfflineMode ( this . clientConfiguration . getOfflineMode ( ) ) ; if ( this . clientConfiguration . getDumpDirectoryLocation ( ... | Performs all actions that have been configured . |
24,555 | private void initializeLogging ( ) { if ( consoleAppender != null ) { return ; } consoleAppender = new ConsoleAppender ( ) ; consoleAppender . setLayout ( new PatternLayout ( LOG_PATTERN ) ) ; consoleAppender . setThreshold ( Level . INFO ) ; LevelRangeFilter filter = new LevelRangeFilter ( ) ; filter . setLevelMin ( L... | Sets up Log4J to write log messages to the console . Low - priority messages are logged to stdout while high - priority messages go to stderr . |
24,556 | public static void main ( String [ ] args ) throws ParseException , IOException { Client client = new Client ( new DumpProcessingController ( "wikidatawiki" ) , args ) ; client . performActions ( ) ; } | Launches the client with the specified parameters . |
24,557 | public void writeBasicDeclarations ( ) throws RDFHandlerException { for ( Map . Entry < String , String > uriType : Vocabulary . getKnownVocabularyTypes ( ) . entrySet ( ) ) { this . rdfWriter . writeTripleUriObject ( uriType . getKey ( ) , RdfWriter . RDF_TYPE , uriType . getValue ( ) ) ; } } | Writes OWL declarations for all basic vocabulary elements used in the dump . |
24,558 | void writeInterPropertyLinks ( PropertyDocument document ) throws RDFHandlerException { Resource subject = this . rdfWriter . getUri ( document . getEntityId ( ) . getIri ( ) ) ; this . rdfWriter . writeTripleUriObject ( subject , this . rdfWriter . getUri ( Vocabulary . WB_DIRECT_CLAIM_PROP ) , Vocabulary . getPropert... | Writes triples which conect properties with there corresponding rdf properties for statements simple statements qualifiers reference attributes and values . |
24,559 | void writeBestRankTriples ( ) { for ( Resource resource : this . rankBuffer . getBestRankedStatements ( ) ) { try { this . rdfWriter . writeTripleUriObject ( resource , RdfWriter . RDF_TYPE , RdfWriter . WB_BEST_RANK . toString ( ) ) ; } catch ( RDFHandlerException e ) { throw new RuntimeException ( e . getMessage ( ) ... | Writes triples to determine the statements with the highest rank . |
24,560 | String getUriStringForRank ( StatementRank rank ) { switch ( rank ) { case NORMAL : return Vocabulary . WB_NORMAL_RANK ; case PREFERRED : return Vocabulary . WB_PREFERRED_RANK ; case DEPRECATED : return Vocabulary . WB_DEPRECATED_RANK ; default : throw new IllegalArgumentException ( ) ; } } | Returns an URI which represents the statement rank in a triple . |
24,561 | public static String fixLanguageCodeIfDeprecated ( String wikimediaLanguageCode ) { if ( DEPRECATED_LANGUAGE_CODES . containsKey ( wikimediaLanguageCode ) ) { return DEPRECATED_LANGUAGE_CODES . get ( wikimediaLanguageCode ) ; } else { return wikimediaLanguageCode ; } } | Translate a Wikimedia language code to its preferred value if this code is deprecated or return it untouched if the string is not a known deprecated Wikimedia language code |
24,562 | public T withLabel ( String text , String languageCode ) { withLabel ( factory . getMonolingualTextValue ( text , languageCode ) ) ; return getThis ( ) ; } | Adds an additional label to the constructed document . |
24,563 | public T withDescription ( String text , String languageCode ) { withDescription ( factory . getMonolingualTextValue ( text , languageCode ) ) ; return getThis ( ) ; } | Adds an additional description to the constructed document . |
24,564 | public T withAlias ( String text , String languageCode ) { withAlias ( factory . getMonolingualTextValue ( text , languageCode ) ) ; return getThis ( ) ; } | Adds an additional alias to the constructed document . |
24,565 | public T withStatement ( Statement statement ) { PropertyIdValue pid = statement . getMainSnak ( ) . getPropertyId ( ) ; ArrayList < Statement > pidStatements = this . statements . get ( pid ) ; if ( pidStatements == null ) { pidStatements = new ArrayList < Statement > ( ) ; this . statements . put ( pid , pidStatement... | Adds an additional statement to the constructed document . |
24,566 | protected void logIncompatibleValueError ( PropertyIdValue propertyIdValue , String datatype , String valueType ) { logger . warn ( "Property " + propertyIdValue . getId ( ) + " has type \"" + datatype + "\" but a value of type " + valueType + ". Data ignored." ) ; } | Logs a message for a case where the value of a property does not fit to its declared datatype . |
24,567 | @ JsonInclude ( Include . NON_EMPTY ) @ JsonProperty ( "id" ) public String getJsonId ( ) { if ( ! EntityIdValue . SITE_LOCAL . equals ( this . siteIri ) ) { return this . entityId ; } else { return null ; } } | Returns the string id of the entity that this document refers to . Only for use by Jackson during serialization . |
24,568 | public Map < String , EntityDocument > wbGetEntities ( WbGetEntitiesActionData properties ) throws MediaWikiApiErrorException , IOException { return wbGetEntities ( properties . ids , properties . sites , properties . titles , properties . props , properties . languages , properties . sitefilter ) ; } | Creates a map of identifiers or page titles to documents retrieved via the API URL |
24,569 | public static String getStatementUri ( Statement statement ) { int i = statement . getStatementId ( ) . indexOf ( '$' ) + 1 ; return PREFIX_WIKIDATA_STATEMENT + statement . getSubject ( ) . getId ( ) + "-" + statement . getStatementId ( ) . substring ( i ) ; } | Get the URI for the given statement . |
24,570 | public static String getPropertyUri ( PropertyIdValue propertyIdValue , PropertyContext propertyContext ) { switch ( propertyContext ) { case DIRECT : return PREFIX_PROPERTY_DIRECT + propertyIdValue . getId ( ) ; case STATEMENT : return PREFIX_PROPERTY + propertyIdValue . getId ( ) ; case VALUE_SIMPLE : return PREFIX_P... | Get the URI for the given property in the given context . |
24,571 | public StatementGroup findStatementGroup ( String propertyIdValue ) { if ( this . claims . containsKey ( propertyIdValue ) ) { return new StatementGroupImpl ( this . claims . get ( propertyIdValue ) ) ; } return null ; } | Find a statement group by its property id without checking for equality with the site IRI . More efficient implementation than the default one . |
24,572 | protected static Map < String , List < Statement > > addStatementToGroups ( Statement statement , Map < String , List < Statement > > claims ) { Map < String , List < Statement > > newGroups = new HashMap < > ( claims ) ; String pid = statement . getMainSnak ( ) . getPropertyId ( ) . getId ( ) ; if ( newGroups . contai... | Adds a Statement to a given collection of statement groups . If the statement id is not null and matches that of an existing statement this statement will be replaced . |
24,573 | protected static Map < String , List < Statement > > removeStatements ( Set < String > statementIds , Map < String , List < Statement > > claims ) { Map < String , List < Statement > > newClaims = new HashMap < > ( claims . size ( ) ) ; for ( Entry < String , List < Statement > > entry : claims . entrySet ( ) ) { List ... | Removes statement ids from a collection of statement groups . |
24,574 | public static String getDatatypeIriFromJsonDatatype ( String jsonDatatype ) { switch ( jsonDatatype ) { case JSON_DT_ITEM : return DT_ITEM ; case JSON_DT_PROPERTY : return DT_PROPERTY ; case JSON_DT_GLOBE_COORDINATES : return DT_GLOBE_COORDINATES ; case JSON_DT_URL : return DT_URL ; case JSON_DT_COMMONS_MEDIA : return ... | Returns the WDTK datatype IRI for the property datatype as represented by the given JSON datatype string . |
24,575 | public static String getJsonDatatypeFromDatatypeIri ( String datatypeIri ) { switch ( datatypeIri ) { case DatatypeIdValue . DT_ITEM : return DatatypeIdImpl . JSON_DT_ITEM ; case DatatypeIdValue . DT_GLOBE_COORDINATES : return DatatypeIdImpl . JSON_DT_GLOBE_COORDINATES ; case DatatypeIdValue . DT_URL : return DatatypeI... | Returns the JSON datatype for the property datatype as represented by the given WDTK datatype IRI string . |
24,576 | protected InputStream getCompressorInputStream ( InputStream inputStream , CompressionType compressionType ) throws IOException { switch ( compressionType ) { case NONE : return inputStream ; case GZIP : return new GZIPInputStream ( inputStream ) ; case BZ2 : return new BZip2CompressorInputStream ( new BufferedInputStr... | Returns an input stream that applies the required decompression to the given input stream . |
24,577 | void createDirectory ( Path path ) throws IOException { if ( Files . exists ( path ) && Files . isDirectory ( path ) ) { return ; } if ( this . readOnly ) { throw new FileNotFoundException ( "The requested directory \"" + path . toString ( ) + "\" does not exist and we are in read-only mode, so it cannot be created." )... | Creates a directory at the given path if it does not exist yet and if the directory manager was not configured for read - only access . |
24,578 | public static String getDumpFilePostfix ( DumpContentType dumpContentType ) { if ( WmfDumpFile . POSTFIXES . containsKey ( dumpContentType ) ) { return WmfDumpFile . POSTFIXES . get ( dumpContentType ) ; } else { throw new IllegalArgumentException ( "Unsupported dump type " + dumpContentType ) ; } } | Returns the ending used by the Wikimedia - provided dumpfile names of the given type . |
24,579 | public static String getDumpFileWebDirectory ( DumpContentType dumpContentType , String projectName ) { if ( dumpContentType == DumpContentType . JSON ) { if ( "wikidatawiki" . equals ( projectName ) ) { return WmfDumpFile . DUMP_SITE_BASE_URL + WmfDumpFile . WEB_DIRECTORY . get ( dumpContentType ) + "wikidata" + "/" ;... | Returns the absolute directory on the Web site where dumpfiles of the given type can be found . |
24,580 | public static CompressionType getDumpFileCompressionType ( String fileName ) { if ( fileName . endsWith ( ".gz" ) ) { return CompressionType . GZIP ; } else if ( fileName . endsWith ( ".bz2" ) ) { return CompressionType . BZ2 ; } else { return CompressionType . NONE ; } } | Returns the compression type of this kind of dump file using file suffixes |
24,581 | public static String getDumpFileDirectoryName ( DumpContentType dumpContentType , String dateStamp ) { return dumpContentType . toString ( ) . toLowerCase ( ) + "-" + dateStamp ; } | Returns the name of the directory where the dumpfile of the given type and date should be stored . |
24,582 | public static String getDumpFileName ( DumpContentType dumpContentType , String projectName , String dateStamp ) { if ( dumpContentType == DumpContentType . JSON ) { return dateStamp + WmfDumpFile . getDumpFilePostfix ( dumpContentType ) ; } else { return projectName + "-" + dateStamp + WmfDumpFile . getDumpFilePostfix... | Returns the name under which this dump file . This is the name used online and also locally when downloading the file . |
24,583 | public static boolean isRevisionDumpFile ( DumpContentType dumpContentType ) { if ( WmfDumpFile . REVISION_DUMP . containsKey ( dumpContentType ) ) { return WmfDumpFile . REVISION_DUMP . get ( dumpContentType ) ; } else { throw new IllegalArgumentException ( "Unsupported dump type " + dumpContentType ) ; } } | Returns true if the given dump file type contains page revisions and false if it does not . Dumps that do not contain pages are for auxiliary information such as linked sites . |
24,584 | private void processDumpFileContentsRecovery ( InputStream inputStream ) throws IOException { JsonDumpFileProcessor . logger . warn ( "Entering recovery mode to parse rest of file. This might be slightly slower." ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; String line = br . r... | Process dump file data from the given input stream . The method can recover from an errors that occurred while processing an input stream which is assumed to contain the JSON serialization of a list of JSON entities with each entity serialization in one line . To recover from the previous error the first line is skippe... |
24,585 | private void reportException ( Exception e ) { logger . error ( "Failed to write JSON export: " + e . toString ( ) ) ; throw new RuntimeException ( e . toString ( ) , e ) ; } | Reports a given exception as a RuntimeException since the interface does not allow us to throw checked exceptions directly . |
24,586 | protected static String jacksonObjectToString ( Object object ) { try { return mapper . writeValueAsString ( object ) ; } catch ( JsonProcessingException e ) { logger . error ( "Failed to serialize JSON data: " + e . toString ( ) ) ; return null ; } } | Serializes the given object in JSON and returns the resulting string . In case of errors null is returned . In particular this happens if the object is not based on a Jackson - annotated class . An error is logged in this case . |
24,587 | protected static String getTimePrecisionString ( byte precision ) { switch ( precision ) { case TimeValue . PREC_SECOND : return "sec" ; case TimeValue . PREC_MINUTE : return "min" ; case TimeValue . PREC_HOUR : return "hour" ; case TimeValue . PREC_DAY : return "day" ; case TimeValue . PREC_MONTH : return "month" ; ca... | Returns a human - readable string representation of a reference to a precision that is used for a time value . |
24,588 | public JsonNode wbSetLabel ( String id , String site , String title , String newEntity , String language , String value , boolean bot , long baserevid , String summary ) throws IOException , MediaWikiApiErrorException { Validate . notNull ( language , "Language parameter cannot be null when setting a label" ) ; Map < S... | Executes the API action wbsetlabel for the given parameters . |
24,589 | public JsonNode wbSetAliases ( String id , String site , String title , String newEntity , String language , List < String > add , List < String > remove , List < String > set , boolean bot , long baserevid , String summary ) throws IOException , MediaWikiApiErrorException { Validate . notNull ( language , "Language pa... | Executes the API action wbsetaliases for the given parameters . |
24,590 | public JsonNode wbSetClaim ( String statement , boolean bot , long baserevid , String summary ) throws IOException , MediaWikiApiErrorException { Validate . notNull ( statement , "Statement parameter cannot be null when adding or changing a statement" ) ; Map < String , String > parameters = new HashMap < String , Stri... | Executes the API action wbsetclaim for the given parameters . |
24,591 | public JsonNode wbRemoveClaims ( List < String > statementIds , boolean bot , long baserevid , String summary ) throws IOException , MediaWikiApiErrorException { Validate . notNull ( statementIds , "statementIds parameter cannot be null when deleting statements" ) ; Validate . notEmpty ( statementIds , "statement ids t... | Executes the API action wbremoveclaims for the given parameters . |
24,592 | protected void fixIntegerPrecisions ( ItemIdValue itemIdValue , String propertyId ) { String qid = itemIdValue . getId ( ) ; try { ItemDocument currentItemDocument = ( ItemDocument ) dataFetcher . getEntityDocument ( qid ) ; if ( currentItemDocument == null ) { System . out . println ( "*** " + qid + " could not be fet... | Fetches the current online data for the given item and fixes the precision of integer quantities if necessary . |
24,593 | protected void markStatementsForDeletion ( StatementDocument currentDocument , List < Statement > deleteStatements ) { for ( Statement statement : deleteStatements ) { boolean found = false ; for ( StatementGroup sg : currentDocument . getStatementGroups ( ) ) { if ( ! sg . getProperty ( ) . equals ( statement . getMai... | Marks the given list of statements for deletion . It is verified that the current document actually contains the statements before doing so . This check is based on exact statement equality including qualifier order and statement id . |
24,594 | protected void markStatementsForInsertion ( StatementDocument currentDocument , List < Statement > addStatements ) { for ( Statement statement : addStatements ) { addStatement ( statement , true ) ; } for ( StatementGroup sg : currentDocument . getStatementGroups ( ) ) { if ( this . toKeep . containsKey ( sg . getPrope... | Marks a given list of statements for insertion into the current document . Inserted statements can have an id if they should update an existing statement or use an empty string as id if they should be added . The method removes duplicates and avoids unnecessary modifications by checking the current content of the given... |
24,595 | protected void addStatement ( Statement statement , boolean isNew ) { PropertyIdValue pid = statement . getMainSnak ( ) . getPropertyId ( ) ; if ( this . toKeep . containsKey ( pid ) ) { List < StatementWithUpdate > statements = this . toKeep . get ( pid ) ; for ( int i = 0 ; i < statements . size ( ) ; i ++ ) { Statem... | Adds one statement to the list of statements to be kept possibly merging it with other statements to be kept if possible . When two existing statements are merged one of them will be updated and the other will be marked for deletion . |
24,596 | protected List < Reference > mergeReferences ( List < ? extends Reference > references1 , List < ? extends Reference > references2 ) { List < Reference > result = new ArrayList < > ( ) ; for ( Reference reference : references1 ) { addBestReferenceToList ( reference , result ) ; } for ( Reference reference : references2... | Merges two lists of references eliminating duplicates in the process . |
24,597 | protected boolean equivalentClaims ( Claim claim1 , Claim claim2 ) { return claim1 . getMainSnak ( ) . equals ( claim2 . getMainSnak ( ) ) && isSameSnakSet ( claim1 . getAllQualifiers ( ) , claim2 . getAllQualifiers ( ) ) ; } | Checks if two claims are equivalent in the sense that they have the same main snak and the same qualifiers but possibly in a different order . |
24,598 | protected boolean isSameSnakSet ( Iterator < Snak > snaks1 , Iterator < Snak > snaks2 ) { ArrayList < Snak > snakList1 = new ArrayList < > ( 5 ) ; while ( snaks1 . hasNext ( ) ) { snakList1 . add ( snaks1 . next ( ) ) ; } int snakCount2 = 0 ; while ( snaks2 . hasNext ( ) ) { snakCount2 ++ ; Snak snak2 = snaks2 . next (... | Compares two sets of snaks given by iterators . The method is optimised for short lists of snaks as they are typically found in claims and references . |
24,599 | protected long getRevisionIdFromResponse ( JsonNode response ) throws JsonMappingException { if ( response == null ) { throw new JsonMappingException ( "API response is null" ) ; } JsonNode entity = null ; if ( response . has ( "entity" ) ) { entity = response . path ( "entity" ) ; } else if ( response . has ( "pageinf... | Extracts the last revision id from the JSON response returned by the API after an edit |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.