public class SetLabelsForNumbersBot extends Object implements EntityDocumentProcessor
The activity of the bot is logged in the file bot-log-setnumlabels-TIMESTAMP.txt. Note that this log contains all edits that would have been made, even if editing was disabled. Errors are logged to the console only.
By default, this program has the actual editing disabled (see source code), so as to avoid accidental modifications. The output will still mention changes that would be done. If you want to do real edits, please respect the bot etiquette and community guidelines.
The function of the bot is very basic, but it illustrates some important techniques:
Constructor and Description |
---|
SetLabelsForNumbersBot()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addLabelForNumbers(ItemIdValue itemIdValue)
Fetches the current online data for the given item, and adds numerical
labels if necessary.
|
void |
finish()
Finishes processing and makes sure that the log file is written.
|
protected boolean |
lacksSomeLanguage(ItemDocument itemDocument)
Returns true if the given item document lacks a label for at least one of
the languages covered.
|
protected void |
logEntityModification(EntityIdValue entityId,
String numberLabel,
ArrayList<String> languages)
Logs information about entities changed so far.
|
static void |
main(String[] args)
Main method to run the bot.
|
static void |
printDocumentation()
Prints some basic documentation about this program.
|
void |
processItemDocument(ItemDocument itemDocument)
Processes the given ItemDocument.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
processEntityRedirectDocument, processLexemeDocument, processMediaInfoDocument, processPropertyDocument
public SetLabelsForNumbersBot() throws LoginFailedException, IOException
LoginFailedException
IOException
public static void main(String[] args) throws LoginFailedException, IOException
LoginFailedException
IOException
public static void printDocumentation()
public void processItemDocument(ItemDocument itemDocument)
EntityDocumentProcessor
processItemDocument
in interface EntityDocumentProcessor
itemDocument
- the ItemDocumentpublic void finish()
protected void addLabelForNumbers(ItemIdValue itemIdValue)
itemIdValue
- the id of the document to inspectprotected boolean lacksSomeLanguage(ItemDocument itemDocument)
itemDocument
- protected void logEntityModification(EntityIdValue entityId, String numberLabel, ArrayList<String> languages)
entityId
- the id of the modified itemnumberLabel
- the label writtenlanguages
- the list of languages for which the label was setCopyright © 2014–2024 Wikidata Toolkit Developers. Generated from source code published under the Apache License 2.0. For more information, see the Wikidata Toolkit homepage