repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
Wikidata/Wikidata-Toolkit
wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/MwRevisionImpl.java
MwRevisionImpl.resetCurrentRevisionData
void resetCurrentRevisionData() { this.revisionId = NO_REVISION_ID; // impossible as an id in MediaWiki this.parentRevisionId = NO_REVISION_ID; this.text = null; this.comment = null; this.format = null; this.timeStamp = null; this.model = null; }
java
void resetCurrentRevisionData() { this.revisionId = NO_REVISION_ID; // impossible as an id in MediaWiki this.parentRevisionId = NO_REVISION_ID; this.text = null; this.comment = null; this.format = null; this.timeStamp = null; this.model = null; }
[ "void", "resetCurrentRevisionData", "(", ")", "{", "this", ".", "revisionId", "=", "NO_REVISION_ID", ";", "// impossible as an id in MediaWiki", "this", ".", "parentRevisionId", "=", "NO_REVISION_ID", ";", "this", ".", "text", "=", "null", ";", "this", ".", "comme...
Resets all member fields that hold information about the revision that is currently being processed.
[ "Resets", "all", "member", "fields", "that", "hold", "information", "about", "the", "revision", "that", "is", "currently", "being", "processed", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/MwRevisionImpl.java#L168-L176
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/TermedStatementDocumentImpl.java
TermedStatementDocumentImpl.toTerm
private static MonolingualTextValue toTerm(MonolingualTextValue term) { return term instanceof TermImpl ? term : new TermImpl(term.getLanguageCode(), term.getText()); }
java
private static MonolingualTextValue toTerm(MonolingualTextValue term) { return term instanceof TermImpl ? term : new TermImpl(term.getLanguageCode(), term.getText()); }
[ "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.
[ "We", "need", "to", "make", "sure", "the", "terms", "are", "of", "the", "right", "type", "otherwise", "they", "will", "not", "be", "serialized", "correctly", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/TermedStatementDocumentImpl.java#L219-L221
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/ClassPropertyUsageAnalyzer.java
ClassPropertyUsageAnalyzer.writePropertyData
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 qualifier...
java
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 qualifier...
[ "private", "void", "writePropertyData", "(", ")", "{", "try", "(", "PrintStream", "out", "=", "new", "PrintStream", "(", "ExampleHelpers", ".", "openExampleFileOuputStream", "(", "\"properties.csv\"", ")", ")", ")", "{", "out", ".", "println", "(", "\"Id\"", "...
Writes the data collected about properties to a file.
[ "Writes", "the", "data", "collected", "about", "properties", "to", "a", "file", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/ClassPropertyUsageAnalyzer.java#L482-L502
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/ClassPropertyUsageAnalyzer.java
ClassPropertyUsageAnalyzer.writeClassData
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...
java
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...
[ "private", "void", "writeClassData", "(", ")", "{", "try", "(", "PrintStream", "out", "=", "new", "PrintStream", "(", "ExampleHelpers", ".", "openExampleFileOuputStream", "(", "\"classes.csv\"", ")", ")", ")", "{", "out", ".", "println", "(", "\"Id\"", "+", ...
Writes the data collected about classes to a file.
[ "Writes", "the", "data", "collected", "about", "classes", "to", "a", "file", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/ClassPropertyUsageAnalyzer.java#L507-L529
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/ClassPropertyUsageAnalyzer.java
ClassPropertyUsageAnalyzer.printClassRecord
private void printClassRecord(PrintStream out, ClassRecord classRecord, EntityIdValue entityIdValue) { printTerms(out, classRecord.itemDocument, entityIdValue, "\"" + getClassLabel(entityIdValue) + "\""); printImage(out, classRecord.itemDocument); out.print("," + classRecord.itemCount + "," + classRecord....
java
private void printClassRecord(PrintStream out, ClassRecord classRecord, EntityIdValue entityIdValue) { printTerms(out, classRecord.itemDocument, entityIdValue, "\"" + getClassLabel(entityIdValue) + "\""); printImage(out, classRecord.itemDocument); out.print("," + classRecord.itemCount + "," + classRecord....
[ "private", "void", "printClassRecord", "(", "PrintStream", "out", ",", "ClassRecord", "classRecord", ",", "EntityIdValue", "entityIdValue", ")", "{", "printTerms", "(", "out", ",", "classRecord", ".", "itemDocument", ",", "entityIdValue", ",", "\"\\\"\"", "+", "ge...
Prints the data for a single class to the given stream. This will be a single line in CSV. @param out the output to write to @param classRecord the class record to write @param entityIdValue the item id that this class record belongs to
[ "Prints", "the", "data", "for", "a", "single", "class", "to", "the", "given", "stream", ".", "This", "will", "be", "a", "single", "line", "in", "CSV", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/ClassPropertyUsageAnalyzer.java#L542-L562
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/ClassPropertyUsageAnalyzer.java
ClassPropertyUsageAnalyzer.printImage
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 : s...
java
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 : s...
[ "private", "void", "printImage", "(", "PrintStream", "out", ",", "ItemDocument", "itemDocument", ")", "{", "String", "imageFile", "=", "null", ";", "if", "(", "itemDocument", "!=", "null", ")", "{", "for", "(", "StatementGroup", "sg", ":", "itemDocument", "....
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. @param out the output to write to @param itemDocument the document that may provide the image information
[ "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", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/ClassPropertyUsageAnalyzer.java#L659-L701
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/ClassPropertyUsageAnalyzer.java
ClassPropertyUsageAnalyzer.printPropertyRecord
private void printPropertyRecord(PrintStream out, PropertyRecord propertyRecord, PropertyIdValue propertyIdValue) { printTerms(out, propertyRecord.propertyDocument, propertyIdValue, null); String datatype = "Unknown"; if (propertyRecord.propertyDocument != null) { datatype = getDatatypeLabel(propertyRecor...
java
private void printPropertyRecord(PrintStream out, PropertyRecord propertyRecord, PropertyIdValue propertyIdValue) { printTerms(out, propertyRecord.propertyDocument, propertyIdValue, null); String datatype = "Unknown"; if (propertyRecord.propertyDocument != null) { datatype = getDatatypeLabel(propertyRecor...
[ "private", "void", "printPropertyRecord", "(", "PrintStream", "out", ",", "PropertyRecord", "propertyRecord", ",", "PropertyIdValue", "propertyIdValue", ")", "{", "printTerms", "(", "out", ",", "propertyRecord", ".", "propertyDocument", ",", "propertyIdValue", ",", "n...
Prints the data of one property to the given output. This will be a single line in CSV. @param out the output to write to @param propertyRecord the data to write @param propertyIdValue the property that the data refers to
[ "Prints", "the", "data", "of", "one", "property", "to", "the", "given", "output", ".", "This", "will", "be", "a", "single", "line", "in", "CSV", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/ClassPropertyUsageAnalyzer.java#L714-L744
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/ClassPropertyUsageAnalyzer.java
ClassPropertyUsageAnalyzer.getDatatypeLabel
private String getDatatypeLabel(DatatypeIdValue datatype) { if (datatype.getIri() == null) { // TODO should be redundant once the // JSON parsing works return "Unknown"; } switch (datatype.getIri()) { case DatatypeIdValue.DT_COMMONS_MEDIA: return "Commons media"; case DatatypeIdValue.DT_GLOB...
java
private String getDatatypeLabel(DatatypeIdValue datatype) { if (datatype.getIri() == null) { // TODO should be redundant once the // JSON parsing works return "Unknown"; } switch (datatype.getIri()) { case DatatypeIdValue.DT_COMMONS_MEDIA: return "Commons media"; case DatatypeIdValue.DT_GLOB...
[ "private", "String", "getDatatypeLabel", "(", "DatatypeIdValue", "datatype", ")", "{", "if", "(", "datatype", ".", "getIri", "(", ")", "==", "null", ")", "{", "// TODO should be redundant once the", "// JSON parsing works", "return", "\"Unknown\"", ";", "}", "switch...
Returns an English label for a given datatype. @param datatype the datatype to label @return the label
[ "Returns", "an", "English", "label", "for", "a", "given", "datatype", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/ClassPropertyUsageAnalyzer.java#L753-L785
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/ClassPropertyUsageAnalyzer.java
ClassPropertyUsageAnalyzer.getPropertyLabel
private String getPropertyLabel(PropertyIdValue propertyIdValue) { PropertyRecord propertyRecord = this.propertyRecords .get(propertyIdValue); if (propertyRecord == null || propertyRecord.propertyDocument == null) { return propertyIdValue.getId(); } else { return getLabel(propertyIdValue, propertyRecord...
java
private String getPropertyLabel(PropertyIdValue propertyIdValue) { PropertyRecord propertyRecord = this.propertyRecords .get(propertyIdValue); if (propertyRecord == null || propertyRecord.propertyDocument == null) { return propertyIdValue.getId(); } else { return getLabel(propertyIdValue, propertyRecord...
[ "private", "String", "getPropertyLabel", "(", "PropertyIdValue", "propertyIdValue", ")", "{", "PropertyRecord", "propertyRecord", "=", "this", ".", "propertyRecords", ".", "get", "(", "propertyIdValue", ")", ";", "if", "(", "propertyRecord", "==", "null", "||", "p...
Returns a string that should be used as a label for the given property. @param propertyIdValue the property to label @return the label
[ "Returns", "a", "string", "that", "should", "be", "used", "as", "a", "label", "for", "the", "given", "property", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/ClassPropertyUsageAnalyzer.java#L853-L861
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/ClassPropertyUsageAnalyzer.java
ClassPropertyUsageAnalyzer.getClassLabel
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.itemDocument); } ...
java
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.itemDocument); } ...
[ "private", "String", "getClassLabel", "(", "EntityIdValue", "entityIdValue", ")", "{", "ClassRecord", "classRecord", "=", "this", ".", "classRecords", ".", "get", "(", "entityIdValue", ")", ";", "String", "label", ";", "if", "(", "classRecord", "==", "null", "...
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. @param entityIdValue the item to label @return the label
[ "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", ...
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/ClassPropertyUsageAnalyzer.java#L872-L890
train
Wikidata/Wikidata-Toolkit
wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/values/TimeValueConverter.java
TimeValueConverter.writeValue
@Override 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, thi...
java
@Override 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, thi...
[ "@", "Override", "public", "void", "writeValue", "(", "TimeValue", "value", ",", "Resource", "resource", ")", "throws", "RDFHandlerException", "{", "this", ".", "rdfWriter", ".", "writeTripleValueObject", "(", "resource", ",", "RdfWriter", ".", "RDF_TYPE", ",", ...
Write the auxiliary RDF data for encoding the given value. @param value the value to write @param resource the (subject) URI to use to represent this value in RDF @throws RDFHandlerException
[ "Write", "the", "auxiliary", "RDF", "data", "for", "encoding", "the", "given", "value", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/values/TimeValueConverter.java#L78-L95
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/bots/SetLabelsForNumbersBot.java
SetLabelsForNumbersBot.main
public static void main(String[] args) throws LoginFailedException, IOException, MediaWikiApiErrorException { ExampleHelpers.configureLogging(); printDocumentation(); SetLabelsForNumbersBot bot = new SetLabelsForNumbersBot(); ExampleHelpers.processEntitiesFromWikidataDump(bot); bot.finish(); System.out...
java
public static void main(String[] args) throws LoginFailedException, IOException, MediaWikiApiErrorException { ExampleHelpers.configureLogging(); printDocumentation(); SetLabelsForNumbersBot bot = new SetLabelsForNumbersBot(); ExampleHelpers.processEntitiesFromWikidataDump(bot); bot.finish(); System.out...
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "LoginFailedException", ",", "IOException", ",", "MediaWikiApiErrorException", "{", "ExampleHelpers", ".", "configureLogging", "(", ")", ";", "printDocumentation", "(", ")", ";", ...
Main method to run the bot. @param args @throws LoginFailedException @throws IOException @throws MediaWikiApiErrorException
[ "Main", "method", "to", "run", "the", "bot", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/bots/SetLabelsForNumbersBot.java#L134-L144
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/bots/SetLabelsForNumbersBot.java
SetLabelsForNumbersBot.addLabelForNumbers
protected void addLabelForNumbers(ItemIdValue itemIdValue) { String qid = itemIdValue.getId(); try { // Fetch the online version of the item to make sure we edit the // current version: ItemDocument currentItemDocument = (ItemDocument) dataFetcher .getEntityDocument(qid); if (currentItemDocument ...
java
protected void addLabelForNumbers(ItemIdValue itemIdValue) { String qid = itemIdValue.getId(); try { // Fetch the online version of the item to make sure we edit the // current version: ItemDocument currentItemDocument = (ItemDocument) dataFetcher .getEntityDocument(qid); if (currentItemDocument ...
[ "protected", "void", "addLabelForNumbers", "(", "ItemIdValue", "itemIdValue", ")", "{", "String", "qid", "=", "itemIdValue", ".", "getId", "(", ")", ";", "try", "{", "// Fetch the online version of the item to make sure we edit the", "// current version:", "ItemDocument", ...
Fetches the current online data for the given item, and adds numerical labels if necessary. @param itemIdValue the id of the document to inspect
[ "Fetches", "the", "current", "online", "data", "for", "the", "given", "item", "and", "adds", "numerical", "labels", "if", "necessary", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/bots/SetLabelsForNumbersBot.java#L220-L294
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/bots/SetLabelsForNumbersBot.java
SetLabelsForNumbersBot.lacksSomeLanguage
protected boolean lacksSomeLanguage(ItemDocument itemDocument) { for (int i = 0; i < arabicNumeralLanguages.length; i++) { if (!itemDocument.getLabels() .containsKey(arabicNumeralLanguages[i])) { return true; } } return false; }
java
protected boolean lacksSomeLanguage(ItemDocument itemDocument) { for (int i = 0; i < arabicNumeralLanguages.length; i++) { if (!itemDocument.getLabels() .containsKey(arabicNumeralLanguages[i])) { return true; } } return false; }
[ "protected", "boolean", "lacksSomeLanguage", "(", "ItemDocument", "itemDocument", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "arabicNumeralLanguages", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "itemDocument", ".", "getLabels"...
Returns true if the given item document lacks a label for at least one of the languages covered. @param itemDocument @return true if some label is missing
[ "Returns", "true", "if", "the", "given", "item", "document", "lacks", "a", "label", "for", "at", "least", "one", "of", "the", "languages", "covered", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/bots/SetLabelsForNumbersBot.java#L303-L311
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/LifeExpectancyProcessor.java
LifeExpectancyProcessor.writeFinalResults
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] / people...
java
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] / people...
[ "public", "void", "writeFinalResults", "(", ")", "{", "printStatus", "(", ")", ";", "try", "(", "PrintStream", "out", "=", "new", "PrintStream", "(", "ExampleHelpers", ".", "openExampleFileOuputStream", "(", "\"life-expectancies.csv\"", ")", ")", ")", "{", "for"...
Writes the results of the processing to a file.
[ "Writes", "the", "results", "of", "the", "processing", "to", "a", "file", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/LifeExpectancyProcessor.java#L94-L110
train
Wikidata/Wikidata-Toolkit
wdtk-client/src/main/java/org/wikidata/wdtk/client/SchemaUsageAnalyzer.java
SchemaUsageAnalyzer.createDirectory
private static void createDirectory(Path path) throws IOException { try { Files.createDirectory(path); } catch (FileAlreadyExistsException e) { if (!Files.isDirectory(path)) { throw e; } } }
java
private static void createDirectory(Path path) throws IOException { try { Files.createDirectory(path); } catch (FileAlreadyExistsException e) { if (!Files.isDirectory(path)) { throw e; } } }
[ "private", "static", "void", "createDirectory", "(", "Path", "path", ")", "throws", "IOException", "{", "try", "{", "Files", ".", "createDirectory", "(", "path", ")", ";", "}", "catch", "(", "FileAlreadyExistsException", "e", ")", "{", "if", "(", "!", "Fil...
Create a directory at the given path if it does not exist yet. @param path the path to the directory @throws IOException if it was not possible to create a directory at the given path
[ "Create", "a", "directory", "at", "the", "given", "path", "if", "it", "does", "not", "exist", "yet", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-client/src/main/java/org/wikidata/wdtk/client/SchemaUsageAnalyzer.java#L392-L400
train
Wikidata/Wikidata-Toolkit
wdtk-client/src/main/java/org/wikidata/wdtk/client/SchemaUsageAnalyzer.java
SchemaUsageAnalyzer.openResultFileOuputStream
public static FileOutputStream openResultFileOuputStream( Path resultDirectory, String filename) throws IOException { Path filePath = resultDirectory.resolve(filename); return new FileOutputStream(filePath.toFile()); }
java
public static FileOutputStream openResultFileOuputStream( Path resultDirectory, String filename) throws IOException { Path filePath = resultDirectory.resolve(filename); return new FileOutputStream(filePath.toFile()); }
[ "public", "static", "FileOutputStream", "openResultFileOuputStream", "(", "Path", "resultDirectory", ",", "String", "filename", ")", "throws", "IOException", "{", "Path", "filePath", "=", "resultDirectory", ".", "resolve", "(", "filename", ")", ";", "return", "new",...
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. @param resultDirectory the path to the result directory @param filename the name of the file to write to @ret...
[ "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", ...
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-client/src/main/java/org/wikidata/wdtk/client/SchemaUsageAnalyzer.java#L415-L419
train
Wikidata/Wikidata-Toolkit
wdtk-client/src/main/java/org/wikidata/wdtk/client/SchemaUsageAnalyzer.java
SchemaUsageAnalyzer.addSuperClasses
private void addSuperClasses(Integer directSuperClass, ClassRecord subClassRecord) { if (subClassRecord.superClasses.contains(directSuperClass)) { return; } subClassRecord.superClasses.add(directSuperClass); ClassRecord superClassRecord = getClassRecord(directSuperClass); if (superClassRecord == null) {...
java
private void addSuperClasses(Integer directSuperClass, ClassRecord subClassRecord) { if (subClassRecord.superClasses.contains(directSuperClass)) { return; } subClassRecord.superClasses.add(directSuperClass); ClassRecord superClassRecord = getClassRecord(directSuperClass); if (superClassRecord == null) {...
[ "private", "void", "addSuperClasses", "(", "Integer", "directSuperClass", ",", "ClassRecord", "subClassRecord", ")", "{", "if", "(", "subClassRecord", ".", "superClasses", ".", "contains", "(", "directSuperClass", ")", ")", "{", "return", ";", "}", "subClassRecord...
Recursively add indirect subclasses to a class record. @param directSuperClass the superclass to add (together with its own superclasses) @param subClassRecord the subclass to add to
[ "Recursively", "add", "indirect", "subclasses", "to", "a", "class", "record", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-client/src/main/java/org/wikidata/wdtk/client/SchemaUsageAnalyzer.java#L681-L695
train
Wikidata/Wikidata-Toolkit
wdtk-client/src/main/java/org/wikidata/wdtk/client/SchemaUsageAnalyzer.java
SchemaUsageAnalyzer.getNumId
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); } ...
java
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); } ...
[ "private", "Integer", "getNumId", "(", "String", "idString", ",", "boolean", "isUri", ")", "{", "String", "numString", ";", "if", "(", "isUri", ")", "{", "if", "(", "!", "idString", ".", "startsWith", "(", "\"http://www.wikidata.org/entity/\"", ")", ")", "{"...
Extracts a numeric id from a string, which can be either a Wikidata entity URI or a short entity or property id. @param idString @param isUri @return numeric id, or 0 if there was an error
[ "Extracts", "a", "numeric", "id", "from", "a", "string", "which", "can", "be", "either", "a", "Wikidata", "entity", "URI", "or", "a", "short", "entity", "or", "property", "id", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-client/src/main/java/org/wikidata/wdtk/client/SchemaUsageAnalyzer.java#L705-L717
train
Wikidata/Wikidata-Toolkit
wdtk-client/src/main/java/org/wikidata/wdtk/client/SchemaUsageAnalyzer.java
SchemaUsageAnalyzer.countCooccurringProperties
private void countCooccurringProperties( StatementDocument statementDocument, UsageRecord usageRecord, PropertyIdValue thisPropertyIdValue) { for (StatementGroup sg : statementDocument.getStatementGroups()) { if (!sg.getProperty().equals(thisPropertyIdValue)) { Integer propertyId = getNumId(sg.getPropert...
java
private void countCooccurringProperties( StatementDocument statementDocument, UsageRecord usageRecord, PropertyIdValue thisPropertyIdValue) { for (StatementGroup sg : statementDocument.getStatementGroups()) { if (!sg.getProperty().equals(thisPropertyIdValue)) { Integer propertyId = getNumId(sg.getPropert...
[ "private", "void", "countCooccurringProperties", "(", "StatementDocument", "statementDocument", ",", "UsageRecord", "usageRecord", ",", "PropertyIdValue", "thisPropertyIdValue", ")", "{", "for", "(", "StatementGroup", "sg", ":", "statementDocument", ".", "getStatementGroups...
Counts each property for which there is a statement in the given item document, ignoring the property thisPropertyIdValue to avoid properties counting themselves. @param statementDocument @param usageRecord @param thisPropertyIdValue
[ "Counts", "each", "property", "for", "which", "there", "is", "a", "statement", "in", "the", "given", "item", "document", "ignoring", "the", "property", "thisPropertyIdValue", "to", "avoid", "properties", "counting", "themselves", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-client/src/main/java/org/wikidata/wdtk/client/SchemaUsageAnalyzer.java#L763-L777
train
Wikidata/Wikidata-Toolkit
wdtk-client/src/main/java/org/wikidata/wdtk/client/SchemaUsageAnalyzer.java
SchemaUsageAnalyzer.runSparqlQuery
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 .openCon...
java
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 .openCon...
[ "private", "InputStream", "runSparqlQuery", "(", "String", "query", ")", "throws", "IOException", "{", "try", "{", "String", "queryString", "=", "\"query=\"", "+", "URLEncoder", ".", "encode", "(", "query", ",", "\"UTF-8\"", ")", "+", "\"&format=json\"", ";", ...
Executes a given SPARQL query and returns a stream with the result in JSON format. @param query @return @throws IOException
[ "Executes", "a", "given", "SPARQL", "query", "and", "returns", "a", "stream", "with", "the", "result", "in", "JSON", "format", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-client/src/main/java/org/wikidata/wdtk/client/SchemaUsageAnalyzer.java#L787-L801
train
Wikidata/Wikidata-Toolkit
wdtk-client/src/main/java/org/wikidata/wdtk/client/SchemaUsageAnalyzer.java
SchemaUsageAnalyzer.writePropertyData
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.println...
java
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.println...
[ "private", "void", "writePropertyData", "(", ")", "{", "try", "(", "PrintStream", "out", "=", "new", "PrintStream", "(", "openResultFileOuputStream", "(", "resultDirectory", ",", "\"properties.json\"", ")", ")", ")", "{", "out", ".", "println", "(", "\"{\"", "...
Writes all data that was collected about properties to a json file.
[ "Writes", "all", "data", "that", "was", "collected", "about", "properties", "to", "a", "json", "file", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-client/src/main/java/org/wikidata/wdtk/client/SchemaUsageAnalyzer.java#L816-L838
train
Wikidata/Wikidata-Toolkit
wdtk-client/src/main/java/org/wikidata/wdtk/client/SchemaUsageAnalyzer.java
SchemaUsageAnalyzer.writeClassData
private void writeClassData() { try (PrintStream out = new PrintStream(openResultFileOuputStream( resultDirectory, "classes.json"))) { out.println("{"); // Add direct subclass information: for (Entry<Integer, ClassRecord> classEntry : this.classRecords .entrySet()) { if (classEntry.getValue().s...
java
private void writeClassData() { try (PrintStream out = new PrintStream(openResultFileOuputStream( resultDirectory, "classes.json"))) { out.println("{"); // Add direct subclass information: for (Entry<Integer, ClassRecord> classEntry : this.classRecords .entrySet()) { if (classEntry.getValue().s...
[ "private", "void", "writeClassData", "(", ")", "{", "try", "(", "PrintStream", "out", "=", "new", "PrintStream", "(", "openResultFileOuputStream", "(", "resultDirectory", ",", "\"classes.json\"", ")", ")", ")", "{", "out", ".", "println", "(", "\"{\"", ")", ...
Writes all data that was collected about classes to a json file.
[ "Writes", "all", "data", "that", "was", "collected", "about", "classes", "to", "a", "json", "file", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-client/src/main/java/org/wikidata/wdtk/client/SchemaUsageAnalyzer.java#L861-L908
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/DataFormatter.java
DataFormatter.formatTimeISO8601
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(yearForm.format(value....
java
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(yearForm.format(value....
[ "public", "static", "String", "formatTimeISO8601", "(", "TimeValue", "value", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "DecimalFormat", "yearForm", "=", "new", "DecimalFormat", "(", "FORMAT_YEAR", ")", ";", "DecimalFormat",...
Returns a representation of the date from the value attributes as ISO 8601 encoding. @param value @return ISO 8601 value (String)
[ "Returns", "a", "representation", "of", "the", "date", "from", "the", "value", "attributes", "as", "ISO", "8601", "encoding", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/DataFormatter.java#L47-L67
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/DataFormatter.java
DataFormatter.formatBigDecimal
public static String formatBigDecimal(BigDecimal number) { if (number.signum() != -1) { return "+" + number.toString(); } else { return number.toString(); } }
java
public static String formatBigDecimal(BigDecimal number) { if (number.signum() != -1) { return "+" + number.toString(); } else { return number.toString(); } }
[ "public", "static", "String", "formatBigDecimal", "(", "BigDecimal", "number", ")", "{", "if", "(", "number", ".", "signum", "(", ")", "!=", "-", "1", ")", "{", "return", "\"+\"", "+", "number", ".", "toString", "(", ")", ";", "}", "else", "{", "retu...
Returns a signed string representation of the given number. @param number @return String for BigDecimal value
[ "Returns", "a", "signed", "string", "representation", "of", "the", "given", "number", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/DataFormatter.java#L75-L81
train
Wikidata/Wikidata-Toolkit
wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/MwLocalDumpFile.java
MwLocalDumpFile.guessDumpContentType
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(".sql.gz")) { ...
java
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(".sql.gz")) { ...
[ "private", "static", "DumpContentType", "guessDumpContentType", "(", "String", "fileName", ")", "{", "String", "lcDumpName", "=", "fileName", ".", "toLowerCase", "(", ")", ";", "if", "(", "lcDumpName", ".", "contains", "(", "\".json.gz\"", ")", ")", "{", "retu...
Guess the type of the given dump from its filename. @param fileName @return dump type, defaulting to JSON if no type was found
[ "Guess", "the", "type", "of", "the", "given", "dump", "from", "its", "filename", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/MwLocalDumpFile.java#L229-L250
train
Wikidata/Wikidata-Toolkit
wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/MwLocalDumpFile.java
MwLocalDumpFile.guessDumpDate
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 "YYYYMMDD"; }...
java
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 "YYYYMMDD"; }...
[ "private", "static", "String", "guessDumpDate", "(", "String", "fileName", ")", "{", "Pattern", "p", "=", "Pattern", ".", "compile", "(", "\"([0-9]{8})\"", ")", ";", "Matcher", "m", "=", "p", ".", "matcher", "(", "fileName", ")", ";", "if", "(", "m", "...
Guess the date of the dump from the given dump file name. @param fileName @return 8-digit date stamp or YYYYMMDD if none was found
[ "Guess", "the", "date", "of", "the", "dump", "from", "the", "given", "dump", "file", "name", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/MwLocalDumpFile.java#L258-L269
train
Wikidata/Wikidata-Toolkit
wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/RankBuffer.java
RankBuffer.add
public void add(StatementRank rank, Resource subject) { if (this.bestRank == rank) { subjects.add(subject); } else if(bestRank == StatementRank.NORMAL && rank == StatementRank.PREFERRED) { //We found a preferred statement subjects.clear(); bestRank = StatementRank.PREFERRED; subjects.add(subject); ...
java
public void add(StatementRank rank, Resource subject) { if (this.bestRank == rank) { subjects.add(subject); } else if(bestRank == StatementRank.NORMAL && rank == StatementRank.PREFERRED) { //We found a preferred statement subjects.clear(); bestRank = StatementRank.PREFERRED; subjects.add(subject); ...
[ "public", "void", "add", "(", "StatementRank", "rank", ",", "Resource", "subject", ")", "{", "if", "(", "this", ".", "bestRank", "==", "rank", ")", "{", "subjects", ".", "add", "(", "subject", ")", ";", "}", "else", "if", "(", "bestRank", "==", "Stat...
Adds a Statement. @param rank rank of the statement @param subject rdf resource that refers to the statement
[ "Adds", "a", "Statement", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/RankBuffer.java#L67-L76
train
Wikidata/Wikidata-Toolkit
wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/SnakRdfConverter.java
SnakRdfConverter.writeAuxiliaryTriples
public void writeAuxiliaryTriples() throws RDFHandlerException { for (PropertyRestriction pr : this.someValuesQueue) { writeSomeValueRestriction(pr.propertyUri, pr.rangeUri, pr.subject); } this.someValuesQueue.clear(); this.valueRdfConverter.writeAuxiliaryTriples(); }
java
public void writeAuxiliaryTriples() throws RDFHandlerException { for (PropertyRestriction pr : this.someValuesQueue) { writeSomeValueRestriction(pr.propertyUri, pr.rangeUri, pr.subject); } this.someValuesQueue.clear(); this.valueRdfConverter.writeAuxiliaryTriples(); }
[ "public", "void", "writeAuxiliaryTriples", "(", ")", "throws", "RDFHandlerException", "{", "for", "(", "PropertyRestriction", "pr", ":", "this", ".", "someValuesQueue", ")", "{", "writeSomeValueRestriction", "(", "pr", ".", "propertyUri", ",", "pr", ".", "rangeUri...
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. @throws RDFHandlerException if there was a problem writing the RDF triples
[ "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", "w...
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/SnakRdfConverter.java#L231-L238
train
Wikidata/Wikidata-Toolkit
wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/SnakRdfConverter.java
SnakRdfConverter.writeSomeValueRestriction
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); this.rdfWrite...
java
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); this.rdfWrite...
[ "void", "writeSomeValueRestriction", "(", "String", "propertyUri", ",", "String", "rangeUri", ",", "Resource", "bnode", ")", "throws", "RDFHandlerException", "{", "this", ".", "rdfWriter", ".", "writeTripleValueObject", "(", "bnode", ",", "RdfWriter", ".", "RDF_TYPE...
Writes a buffered some-value restriction. @param propertyUri URI of the property to which the restriction applies @param rangeUri URI of the class or datatype to which the restriction applies @param bnode blank node representing the restriction @throws RDFHandlerException if there was a problem writing the RDF triples
[ "Writes", "a", "buffered", "some", "-", "value", "restriction", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/SnakRdfConverter.java#L252-L260
train
Wikidata/Wikidata-Toolkit
wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/SnakRdfConverter.java
SnakRdfConverter.getRangeUri
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); return V...
java
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); return V...
[ "String", "getRangeUri", "(", "PropertyIdValue", "propertyIdValue", ")", "{", "String", "datatype", "=", "this", ".", "propertyRegister", ".", "getPropertyType", "(", "propertyIdValue", ")", ";", "if", "(", "datatype", "==", "null", ")", "return", "null", ";", ...
Returns the class of datatype URI that best characterizes the range of the given property based on its datatype. @param propertyIdValue the property for which to get a range @return the range URI or null if the datatype could not be identified.
[ "Returns", "the", "class", "of", "datatype", "URI", "that", "best", "characterizes", "the", "range", "of", "the", "given", "property", "based", "on", "its", "datatype", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/SnakRdfConverter.java#L270-L303
train
Wikidata/Wikidata-Toolkit
wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/SnakRdfConverter.java
SnakRdfConverter.addSomeValuesRestriction
void addSomeValuesRestriction(Resource subject, String propertyUri, String rangeUri) { this.someValuesQueue.add(new PropertyRestriction(subject, propertyUri, rangeUri)); }
java
void addSomeValuesRestriction(Resource subject, String propertyUri, String rangeUri) { this.someValuesQueue.add(new PropertyRestriction(subject, propertyUri, rangeUri)); }
[ "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. @param subject @param propertyUri @param 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", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/SnakRdfConverter.java#L313-L317
train
Wikidata/Wikidata-Toolkit
wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WikibaseDataFetcher.java
WikibaseDataFetcher.getEntityDocumentMap
Map<String, EntityDocument> getEntityDocumentMap(int numOfEntities, WbGetEntitiesActionData properties) throws MediaWikiApiErrorException, IOException { if (numOfEntities == 0) { return Collections.emptyMap(); } configureProperties(properties); return this.wbGetEntitiesAction.wbGetEntities(properties);...
java
Map<String, EntityDocument> getEntityDocumentMap(int numOfEntities, WbGetEntitiesActionData properties) throws MediaWikiApiErrorException, IOException { if (numOfEntities == 0) { return Collections.emptyMap(); } configureProperties(properties); return this.wbGetEntitiesAction.wbGetEntities(properties);...
[ "Map", "<", "String", ",", "EntityDocument", ">", "getEntityDocumentMap", "(", "int", "numOfEntities", ",", "WbGetEntitiesActionData", "properties", ")", "throws", "MediaWikiApiErrorException", ",", "IOException", "{", "if", "(", "numOfEntities", "==", "0", ")", "{"...
Creates a map of identifiers or page titles to documents retrieved via the APIs. @param numOfEntities number of entities that should be retrieved @param properties WbGetEntitiesProperties object that includes all relevant parameters for the wbgetentities action @return map of document identifiers or titles to document...
[ "Creates", "a", "map", "of", "identifiers", "or", "page", "titles", "to", "documents", "retrieved", "via", "the", "APIs", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WikibaseDataFetcher.java#L297-L305
train
Wikidata/Wikidata-Toolkit
wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WikibaseDataFetcher.java
WikibaseDataFetcher.setRequestProps
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()) { builder.append("|claims"...
java
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()) { builder.append("|claims"...
[ "private", "void", "setRequestProps", "(", "WbGetEntitiesActionData", "properties", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "builder", ".", "append", "(", "\"info|datatype\"", ")", ";", "if", "(", "!", "this", ".", "fi...
Sets the value for the API's "props" parameter based on the current settings. @param properties current setting of parameters
[ "Sets", "the", "value", "for", "the", "API", "s", "props", "parameter", "based", "on", "the", "current", "settings", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WikibaseDataFetcher.java#L364-L378
train
Wikidata/Wikidata-Toolkit
wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WikibaseDataFetcher.java
WikibaseDataFetcher.setRequestLanguages
private void setRequestLanguages(WbGetEntitiesActionData properties) { if (this.filter.excludeAllLanguages() || this.filter.getLanguageFilter() == null) { return; } properties.languages = ApiConnection.implodeObjects(this.filter .getLanguageFilter()); }
java
private void setRequestLanguages(WbGetEntitiesActionData properties) { if (this.filter.excludeAllLanguages() || this.filter.getLanguageFilter() == null) { return; } properties.languages = ApiConnection.implodeObjects(this.filter .getLanguageFilter()); }
[ "private", "void", "setRequestLanguages", "(", "WbGetEntitiesActionData", "properties", ")", "{", "if", "(", "this", ".", "filter", ".", "excludeAllLanguages", "(", ")", "||", "this", ".", "filter", ".", "getLanguageFilter", "(", ")", "==", "null", ")", "{", ...
Sets the value for the API's "languages" parameter based on the current settings. @param properties current setting of parameters
[ "Sets", "the", "value", "for", "the", "API", "s", "languages", "parameter", "based", "on", "the", "current", "settings", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WikibaseDataFetcher.java#L387-L394
train
Wikidata/Wikidata-Toolkit
wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WikibaseDataFetcher.java
WikibaseDataFetcher.setRequestSitefilter
private void setRequestSitefilter(WbGetEntitiesActionData properties) { if (this.filter.excludeAllSiteLinks() || this.filter.getSiteLinkFilter() == null) { return; } properties.sitefilter = ApiConnection.implodeObjects(this.filter .getSiteLinkFilter()); }
java
private void setRequestSitefilter(WbGetEntitiesActionData properties) { if (this.filter.excludeAllSiteLinks() || this.filter.getSiteLinkFilter() == null) { return; } properties.sitefilter = ApiConnection.implodeObjects(this.filter .getSiteLinkFilter()); }
[ "private", "void", "setRequestSitefilter", "(", "WbGetEntitiesActionData", "properties", ")", "{", "if", "(", "this", ".", "filter", ".", "excludeAllSiteLinks", "(", ")", "||", "this", ".", "filter", ".", "getSiteLinkFilter", "(", ")", "==", "null", ")", "{", ...
Sets the value for the API's "sitefilter" parameter based on the current settings. @param properties current setting of parameters
[ "Sets", "the", "value", "for", "the", "API", "s", "sitefilter", "parameter", "based", "on", "the", "current", "settings", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WikibaseDataFetcher.java#L403-L410
train
Wikidata/Wikidata-Toolkit
wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/MwSitesDumpFileProcessor.java
MwSitesDumpFileProcessor.processSiteRow
void processSiteRow(String siteRow) { String[] row = getSiteRowFields(siteRow); String filePath = ""; String pagePath = ""; String dataArray = row[8].substring(row[8].indexOf('{'), row[8].length() - 2); // Explanation for the regular expression below: // "'{' or ';'" followed by either // "NOT: ';'...
java
void processSiteRow(String siteRow) { String[] row = getSiteRowFields(siteRow); String filePath = ""; String pagePath = ""; String dataArray = row[8].substring(row[8].indexOf('{'), row[8].length() - 2); // Explanation for the regular expression below: // "'{' or ';'" followed by either // "NOT: ';'...
[ "void", "processSiteRow", "(", "String", "siteRow", ")", "{", "String", "[", "]", "row", "=", "getSiteRowFields", "(", "siteRow", ")", ";", "String", "filePath", "=", "\"\"", ";", "String", "pagePath", "=", "\"\"", ";", "String", "dataArray", "=", "row", ...
Processes a row of the sites table and stores the site information found therein. @param siteRow string serialisation of a sites table row as found in the SQL dump
[ "Processes", "a", "row", "of", "the", "sites", "table", "and", "stores", "the", "site", "information", "found", "therein", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/MwSitesDumpFileProcessor.java#L99-L157
train
Wikidata/Wikidata-Toolkit
wdtk-util/src/main/java/org/wikidata/wdtk/util/Timer.java
Timer.start
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...
java
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...
[ "public", "synchronized", "void", "start", "(", ")", "{", "if", "(", "(", "todoFlags", "&", "RECORD_CPUTIME", ")", "!=", "0", ")", "{", "currentStartCpuTime", "=", "getThreadCpuTime", "(", "threadId", ")", ";", "}", "else", "{", "currentStartCpuTime", "=", ...
Start the timer.
[ "Start", "the", "timer", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-util/src/main/java/org/wikidata/wdtk/util/Timer.java#L200-L212
train
Wikidata/Wikidata-Toolkit
wdtk-util/src/main/java/org/wikidata/wdtk/util/Timer.java
Timer.startNamedTimer
public static void startNamedTimer(String timerName, int todoFlags, long threadId) { getNamedTimer(timerName, todoFlags, threadId).start(); }
java
public static void startNamedTimer(String timerName, int todoFlags, long threadId) { getNamedTimer(timerName, todoFlags, threadId).start(); }
[ "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. @param timerName the name of the timer @param todoFlags @param threadId of the thread to track, or 0 if only system clock should be tracked
[ "Start", "a", "timer", "of", "the", "given", "string", "name", "for", "the", "current", "thread", ".", "If", "no", "such", "timer", "exists", "yet", "then", "it", "will", "be", "newly", "created", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-util/src/main/java/org/wikidata/wdtk/util/Timer.java#L375-L378
train
Wikidata/Wikidata-Toolkit
wdtk-util/src/main/java/org/wikidata/wdtk/util/Timer.java
Timer.stopNamedTimer
public static long stopNamedTimer(String timerName, int todoFlags) { return stopNamedTimer(timerName, todoFlags, Thread.currentThread() .getId()); }
java
public static long stopNamedTimer(String timerName, int todoFlags) { return stopNamedTimer(timerName, todoFlags, Thread.currentThread() .getId()); }
[ "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. @param timerName the name of the timer @param todoFlags @return CPU time if timer existed and was running, and -1 otherwise
[ "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", "th...
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-util/src/main/java/org/wikidata/wdtk/util/Timer.java#L404-L407
train
Wikidata/Wikidata-Toolkit
wdtk-util/src/main/java/org/wikidata/wdtk/util/Timer.java
Timer.resetNamedTimer
public static void resetNamedTimer(String timerName, int todoFlags, long threadId) { getNamedTimer(timerName, todoFlags, threadId).reset(); }
java
public static void resetNamedTimer(String timerName, int todoFlags, long threadId) { getNamedTimer(timerName, todoFlags, threadId).reset(); }
[ "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. @param timerName the name of the timer @param todoFlags @param threadId of the thread to track, or 0 if only system clock should be tracked
[ "Reset", "a", "timer", "of", "the", "given", "string", "name", "for", "the", "given", "thread", ".", "If", "no", "such", "timer", "exists", "yet", "then", "it", "will", "be", "newly", "created", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-util/src/main/java/org/wikidata/wdtk/util/Timer.java#L466-L469
train
Wikidata/Wikidata-Toolkit
wdtk-util/src/main/java/org/wikidata/wdtk/util/Timer.java
Timer.getNamedTimer
public static Timer getNamedTimer(String timerName, int todoFlags) { return getNamedTimer(timerName, todoFlags, Thread.currentThread() .getId()); }
java
public static Timer getNamedTimer(String timerName, int todoFlags) { return getNamedTimer(timerName, todoFlags, Thread.currentThread() .getId()); }
[ "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. @param timerName the name of the timer @param todoFlags @return timer
[ "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", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-util/src/main/java/org/wikidata/wdtk/util/Timer.java#L494-L497
train
Wikidata/Wikidata-Toolkit
wdtk-util/src/main/java/org/wikidata/wdtk/util/Timer.java
Timer.getNamedTimer
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); }
java
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); }
[ "public", "static", "Timer", "getNamedTimer", "(", "String", "timerName", ",", "int", "todoFlags", ",", "long", "threadId", ")", "{", "Timer", "key", "=", "new", "Timer", "(", "timerName", ",", "todoFlags", ",", "threadId", ")", ";", "registeredTimers", ".",...
Get a timer of the given string name for the given thread. If no such timer exists yet, then it will be newly created. @param timerName the name of the timer @param todoFlags @param threadId of the thread to track, or 0 if only system clock should be tracked @return timer
[ "Get", "a", "timer", "of", "the", "given", "string", "name", "for", "the", "given", "thread", ".", "If", "no", "such", "timer", "exists", "yet", "then", "it", "will", "be", "newly", "created", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-util/src/main/java/org/wikidata/wdtk/util/Timer.java#L511-L516
train
Wikidata/Wikidata-Toolkit
wdtk-util/src/main/java/org/wikidata/wdtk/util/Timer.java
Timer.getNamedTotalTimer
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().name.e...
java
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().name.e...
[ "public", "static", "Timer", "getNamedTotalTimer", "(", "String", "timerName", ")", "{", "long", "totalCpuTime", "=", "0", ";", "long", "totalSystemTime", "=", "0", ";", "int", "measurements", "=", "0", ";", "int", "timerCount", "=", "0", ";", "int", "todo...
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. @param timerName @return timer
[ "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", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-util/src/main/java/org/wikidata/wdtk/util/Timer.java#L526-L555
train
Wikidata/Wikidata-Toolkit
wdtk-client/src/main/java/org/wikidata/wdtk/client/Client.java
Client.performActions
public void performActions() { if (this.clientConfiguration.getActions().isEmpty()) { this.clientConfiguration.printHelp(); return; } this.dumpProcessingController.setOfflineMode(this.clientConfiguration .getOfflineMode()); if (this.clientConfiguration.getDumpDirectoryLocation() != null) { try { ...
java
public void performActions() { if (this.clientConfiguration.getActions().isEmpty()) { this.clientConfiguration.printHelp(); return; } this.dumpProcessingController.setOfflineMode(this.clientConfiguration .getOfflineMode()); if (this.clientConfiguration.getDumpDirectoryLocation() != null) { try { ...
[ "public", "void", "performActions", "(", ")", "{", "if", "(", "this", ".", "clientConfiguration", ".", "getActions", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "this", ".", "clientConfiguration", ".", "printHelp", "(", ")", ";", "return", ";", "}", ...
Performs all actions that have been configured.
[ "Performs", "all", "actions", "that", "have", "been", "configured", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-client/src/main/java/org/wikidata/wdtk/client/Client.java#L91-L179
train
Wikidata/Wikidata-Toolkit
wdtk-client/src/main/java/org/wikidata/wdtk/client/Client.java
Client.initializeLogging
private void initializeLogging() { // Since logging is static, make sure this is done only once even if // multiple clients are created (e.g., during tests) if (consoleAppender != null) { return; } consoleAppender = new ConsoleAppender(); consoleAppender.setLayout(new PatternLayout(LOG_PATTERN)); cons...
java
private void initializeLogging() { // Since logging is static, make sure this is done only once even if // multiple clients are created (e.g., during tests) if (consoleAppender != null) { return; } consoleAppender = new ConsoleAppender(); consoleAppender.setLayout(new PatternLayout(LOG_PATTERN)); cons...
[ "private", "void", "initializeLogging", "(", ")", "{", "// Since logging is static, make sure this is done only once even if", "// multiple clients are created (e.g., during tests)", "if", "(", "consoleAppender", "!=", "null", ")", "{", "return", ";", "}", "consoleAppender", "=...
Sets up Log4J to write log messages to the console. Low-priority messages are logged to stdout while high-priority messages go to stderr.
[ "Sets", "up", "Log4J", "to", "write", "log", "messages", "to", "the", "console", ".", "Low", "-", "priority", "messages", "are", "logged", "to", "stdout", "while", "high", "-", "priority", "messages", "go", "to", "stderr", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-client/src/main/java/org/wikidata/wdtk/client/Client.java#L196-L219
train
Wikidata/Wikidata-Toolkit
wdtk-client/src/main/java/org/wikidata/wdtk/client/Client.java
Client.main
public static void main(String[] args) throws ParseException, IOException { Client client = new Client( new DumpProcessingController("wikidatawiki"), args); client.performActions(); }
java
public static void main(String[] args) throws ParseException, IOException { Client client = new Client( new DumpProcessingController("wikidatawiki"), args); client.performActions(); }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "ParseException", ",", "IOException", "{", "Client", "client", "=", "new", "Client", "(", "new", "DumpProcessingController", "(", "\"wikidatawiki\"", ")", ",", "args", ")", "...
Launches the client with the specified parameters. @param args command line parameters @throws ParseException @throws IOException
[ "Launches", "the", "client", "with", "the", "specified", "parameters", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-client/src/main/java/org/wikidata/wdtk/client/Client.java#L292-L296
train
Wikidata/Wikidata-Toolkit
wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/RdfConverter.java
RdfConverter.writeBasicDeclarations
public void writeBasicDeclarations() throws RDFHandlerException { for (Map.Entry<String, String> uriType : Vocabulary .getKnownVocabularyTypes().entrySet()) { this.rdfWriter.writeTripleUriObject(uriType.getKey(), RdfWriter.RDF_TYPE, uriType.getValue()); } }
java
public void writeBasicDeclarations() throws RDFHandlerException { for (Map.Entry<String, String> uriType : Vocabulary .getKnownVocabularyTypes().entrySet()) { this.rdfWriter.writeTripleUriObject(uriType.getKey(), RdfWriter.RDF_TYPE, uriType.getValue()); } }
[ "public", "void", "writeBasicDeclarations", "(", ")", "throws", "RDFHandlerException", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "uriType", ":", "Vocabulary", ".", "getKnownVocabularyTypes", "(", ")", ".", "entrySet", "(", ")", ...
Writes OWL declarations for all basic vocabulary elements used in the dump. @throws RDFHandlerException
[ "Writes", "OWL", "declarations", "for", "all", "basic", "vocabulary", "elements", "used", "in", "the", "dump", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/RdfConverter.java#L102-L108
train
Wikidata/Wikidata-Toolkit
wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/RdfConverter.java
RdfConverter.writeInterPropertyLinks
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 .getPropertyUri(document.ge...
java
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 .getPropertyUri(document.ge...
[ "void", "writeInterPropertyLinks", "(", "PropertyDocument", "document", ")", "throws", "RDFHandlerException", "{", "Resource", "subject", "=", "this", ".", "rdfWriter", ".", "getUri", "(", "document", ".", "getEntityId", "(", ")", ".", "getIri", "(", ")", ")", ...
Writes triples which conect properties with there corresponding rdf properties for statements, simple statements, qualifiers, reference attributes and values. @param document @throws RDFHandlerException
[ "Writes", "triples", "which", "conect", "properties", "with", "there", "corresponding", "rdf", "properties", "for", "statements", "simple", "statements", "qualifiers", "reference", "attributes", "and", "values", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/RdfConverter.java#L213-L265
train
Wikidata/Wikidata-Toolkit
wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/RdfConverter.java
RdfConverter.writeBestRankTriples
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(), e); } } ...
java
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(), e); } } ...
[ "void", "writeBestRankTriples", "(", ")", "{", "for", "(", "Resource", "resource", ":", "this", ".", "rankBuffer", ".", "getBestRankedStatements", "(", ")", ")", "{", "try", "{", "this", ".", "rdfWriter", ".", "writeTripleUriObject", "(", "resource", ",", "R...
Writes triples to determine the statements with the highest rank.
[ "Writes", "triples", "to", "determine", "the", "statements", "with", "the", "highest", "rank", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/RdfConverter.java#L351-L361
train
Wikidata/Wikidata-Toolkit
wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/RdfConverter.java
RdfConverter.getUriStringForRank
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(); } }
java
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(); } }
[ "String", "getUriStringForRank", "(", "StatementRank", "rank", ")", "{", "switch", "(", "rank", ")", "{", "case", "NORMAL", ":", "return", "Vocabulary", ".", "WB_NORMAL_RANK", ";", "case", "PREFERRED", ":", "return", "Vocabulary", ".", "WB_PREFERRED_RANK", ";", ...
Returns an URI which represents the statement rank in a triple. @param rank @return
[ "Returns", "an", "URI", "which", "represents", "the", "statement", "rank", "in", "a", "triple", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/RdfConverter.java#L494-L505
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/interfaces/WikimediaLanguageCodes.java
WikimediaLanguageCodes.fixLanguageCodeIfDeprecated
public static String fixLanguageCodeIfDeprecated(String wikimediaLanguageCode) { if (DEPRECATED_LANGUAGE_CODES.containsKey(wikimediaLanguageCode)) { return DEPRECATED_LANGUAGE_CODES.get(wikimediaLanguageCode); } else { return wikimediaLanguageCode; } }
java
public static String fixLanguageCodeIfDeprecated(String wikimediaLanguageCode) { if (DEPRECATED_LANGUAGE_CODES.containsKey(wikimediaLanguageCode)) { return DEPRECATED_LANGUAGE_CODES.get(wikimediaLanguageCode); } else { return wikimediaLanguageCode; } }
[ "public", "static", "String", "fixLanguageCodeIfDeprecated", "(", "String", "wikimediaLanguageCode", ")", "{", "if", "(", "DEPRECATED_LANGUAGE_CODES", ".", "containsKey", "(", "wikimediaLanguageCode", ")", ")", "{", "return", "DEPRECATED_LANGUAGE_CODES", ".", "get", "("...
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 @param wikimediaLanguageCode the language code as used by Wikimedia @return the preferred language code corresponding to the original language co...
[ "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" ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/interfaces/WikimediaLanguageCodes.java#L618-L624
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/EntityDocumentBuilder.java
EntityDocumentBuilder.withLabel
public T withLabel(String text, String languageCode) { withLabel(factory.getMonolingualTextValue(text, languageCode)); return getThis(); }
java
public T withLabel(String text, String languageCode) { withLabel(factory.getMonolingualTextValue(text, languageCode)); return getThis(); }
[ "public", "T", "withLabel", "(", "String", "text", ",", "String", "languageCode", ")", "{", "withLabel", "(", "factory", ".", "getMonolingualTextValue", "(", "text", ",", "languageCode", ")", ")", ";", "return", "getThis", "(", ")", ";", "}" ]
Adds an additional label to the constructed document. @param text the text of the label @param languageCode the language code of the label @return builder object to continue construction
[ "Adds", "an", "additional", "label", "to", "the", "constructed", "document", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/EntityDocumentBuilder.java#L123-L126
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/EntityDocumentBuilder.java
EntityDocumentBuilder.withDescription
public T withDescription(String text, String languageCode) { withDescription(factory.getMonolingualTextValue(text, languageCode)); return getThis(); }
java
public T withDescription(String text, String languageCode) { withDescription(factory.getMonolingualTextValue(text, languageCode)); return getThis(); }
[ "public", "T", "withDescription", "(", "String", "text", ",", "String", "languageCode", ")", "{", "withDescription", "(", "factory", ".", "getMonolingualTextValue", "(", "text", ",", "languageCode", ")", ")", ";", "return", "getThis", "(", ")", ";", "}" ]
Adds an additional description to the constructed document. @param text the text of the description @param languageCode the language code of the description @return builder object to continue construction
[ "Adds", "an", "additional", "description", "to", "the", "constructed", "document", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/EntityDocumentBuilder.java#L149-L152
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/EntityDocumentBuilder.java
EntityDocumentBuilder.withAlias
public T withAlias(String text, String languageCode) { withAlias(factory.getMonolingualTextValue(text, languageCode)); return getThis(); }
java
public T withAlias(String text, String languageCode) { withAlias(factory.getMonolingualTextValue(text, languageCode)); return getThis(); }
[ "public", "T", "withAlias", "(", "String", "text", ",", "String", "languageCode", ")", "{", "withAlias", "(", "factory", ".", "getMonolingualTextValue", "(", "text", ",", "languageCode", ")", ")", ";", "return", "getThis", "(", ")", ";", "}" ]
Adds an additional alias to the constructed document. @param text the text of the alias @param languageCode the language code of the alias @return builder object to continue construction
[ "Adds", "an", "additional", "alias", "to", "the", "constructed", "document", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/EntityDocumentBuilder.java#L175-L178
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/EntityDocumentBuilder.java
EntityDocumentBuilder.withStatement
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, pidStatements); } pidStateme...
java
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, pidStatements); } pidStateme...
[ "public", "T", "withStatement", "(", "Statement", "statement", ")", "{", "PropertyIdValue", "pid", "=", "statement", ".", "getMainSnak", "(", ")", ".", "getPropertyId", "(", ")", ";", "ArrayList", "<", "Statement", ">", "pidStatements", "=", "this", ".", "st...
Adds an additional statement to the constructed document. @param statement the additional statement @return builder object to continue construction
[ "Adds", "an", "additional", "statement", "to", "the", "constructed", "document", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/EntityDocumentBuilder.java#L187-L198
train
Wikidata/Wikidata-Toolkit
wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/values/AbstractValueConverter.java
AbstractValueConverter.logIncompatibleValueError
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."); }
java
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."); }
[ "protected", "void", "logIncompatibleValueError", "(", "PropertyIdValue", "propertyIdValue", ",", "String", "datatype", ",", "String", "valueType", ")", "{", "logger", ".", "warn", "(", "\"Property \"", "+", "propertyIdValue", ".", "getId", "(", ")", "+", "\" has ...
Logs a message for a case where the value of a property does not fit to its declared datatype. @param propertyIdValue the property that was used @param datatype the declared type of the property @param valueType a string to denote the type of value
[ "Logs", "a", "message", "for", "a", "case", "where", "the", "value", "of", "a", "property", "does", "not", "fit", "to", "its", "declared", "datatype", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/values/AbstractValueConverter.java#L64-L69
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/EntityDocumentImpl.java
EntityDocumentImpl.getJsonId
@JsonInclude(Include.NON_EMPTY) @JsonProperty("id") public String getJsonId() { if (!EntityIdValue.SITE_LOCAL.equals(this.siteIri)) { return this.entityId; } else { return null; } }
java
@JsonInclude(Include.NON_EMPTY) @JsonProperty("id") public String getJsonId() { if (!EntityIdValue.SITE_LOCAL.equals(this.siteIri)) { return this.entityId; } else { return null; } }
[ "@", "JsonInclude", "(", "Include", ".", "NON_EMPTY", ")", "@", "JsonProperty", "(", "\"id\"", ")", "public", "String", "getJsonId", "(", ")", "{", "if", "(", "!", "EntityIdValue", ".", "SITE_LOCAL", ".", "equals", "(", "this", ".", "siteIri", ")", ")", ...
Returns the string id of the entity that this document refers to. Only for use by Jackson during serialization. @return string id
[ "Returns", "the", "string", "id", "of", "the", "entity", "that", "this", "document", "refers", "to", ".", "Only", "for", "use", "by", "Jackson", "during", "serialization", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/EntityDocumentImpl.java#L135-L143
train
Wikidata/Wikidata-Toolkit
wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WbGetEntitiesAction.java
WbGetEntitiesAction.wbGetEntities
public Map<String, EntityDocument> wbGetEntities( WbGetEntitiesActionData properties) throws MediaWikiApiErrorException, IOException { return wbGetEntities(properties.ids, properties.sites, properties.titles, properties.props, properties.languages, properties.sitefilter); }
java
public Map<String, EntityDocument> wbGetEntities( WbGetEntitiesActionData properties) throws MediaWikiApiErrorException, IOException { return wbGetEntities(properties.ids, properties.sites, properties.titles, properties.props, properties.languages, properties.sitefilter); }
[ "public", "Map", "<", "String", ",", "EntityDocument", ">", "wbGetEntities", "(", "WbGetEntitiesActionData", "properties", ")", "throws", "MediaWikiApiErrorException", ",", "IOException", "{", "return", "wbGetEntities", "(", "properties", ".", "ids", ",", "properties"...
Creates a map of identifiers or page titles to documents retrieved via the API URL @param properties parameter setting for wbgetentities @return map of document identifiers or titles to documents retrieved via the API URL @throws MediaWikiApiErrorException if the API returns an error @throws IOException if we encounte...
[ "Creates", "a", "map", "of", "identifiers", "or", "page", "titles", "to", "documents", "retrieved", "via", "the", "API", "URL" ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WbGetEntitiesAction.java#L98-L104
train
Wikidata/Wikidata-Toolkit
wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/Vocabulary.java
Vocabulary.getStatementUri
public static String getStatementUri(Statement statement) { int i = statement.getStatementId().indexOf('$') + 1; return PREFIX_WIKIDATA_STATEMENT + statement.getSubject().getId() + "-" + statement.getStatementId().substring(i); }
java
public static String getStatementUri(Statement statement) { int i = statement.getStatementId().indexOf('$') + 1; return PREFIX_WIKIDATA_STATEMENT + statement.getSubject().getId() + "-" + statement.getStatementId().substring(i); }
[ "public", "static", "String", "getStatementUri", "(", "Statement", "statement", ")", "{", "int", "i", "=", "statement", ".", "getStatementId", "(", ")", ".", "indexOf", "(", "'", "'", ")", "+", "1", ";", "return", "PREFIX_WIKIDATA_STATEMENT", "+", "statement...
Get the URI for the given statement. @param statement the statement for which to create a URI @return the URI
[ "Get", "the", "URI", "for", "the", "given", "statement", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/Vocabulary.java#L501-L506
train
Wikidata/Wikidata-Toolkit
wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/Vocabulary.java
Vocabulary.getPropertyUri
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_...
java
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_...
[ "public", "static", "String", "getPropertyUri", "(", "PropertyIdValue", "propertyIdValue", ",", "PropertyContext", "propertyContext", ")", "{", "switch", "(", "propertyContext", ")", "{", "case", "DIRECT", ":", "return", "PREFIX_PROPERTY_DIRECT", "+", "propertyIdValue",...
Get the URI for the given property in the given context. @param propertyIdValue the property id for which to create a URI @param propertyContext the context for which the URI will be needed @return the URI
[ "Get", "the", "URI", "for", "the", "given", "property", "in", "the", "given", "context", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/Vocabulary.java#L517-L543
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/StatementDocumentImpl.java
StatementDocumentImpl.findStatementGroup
public StatementGroup findStatementGroup(String propertyIdValue) { if (this.claims.containsKey(propertyIdValue)) { return new StatementGroupImpl(this.claims.get(propertyIdValue)); } return null; }
java
public StatementGroup findStatementGroup(String propertyIdValue) { if (this.claims.containsKey(propertyIdValue)) { return new StatementGroupImpl(this.claims.get(propertyIdValue)); } return null; }
[ "public", "StatementGroup", "findStatementGroup", "(", "String", "propertyIdValue", ")", "{", "if", "(", "this", ".", "claims", ".", "containsKey", "(", "propertyIdValue", ")", ")", "{", "return", "new", "StatementGroupImpl", "(", "this", ".", "claims", ".", "...
Find a statement group by its property id, without checking for equality with the site IRI. More efficient implementation than the default one.
[ "Find", "a", "statement", "group", "by", "its", "property", "id", "without", "checking", "for", "equality", "with", "the", "site", "IRI", ".", "More", "efficient", "implementation", "than", "the", "default", "one", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/StatementDocumentImpl.java#L143-L148
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/StatementDocumentImpl.java
StatementDocumentImpl.addStatementToGroups
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.containsKey(pid)) { List<Statement> newGroup ...
java
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.containsKey(pid)) { List<Statement> newGroup ...
[ "protected", "static", "Map", "<", "String", ",", "List", "<", "Statement", ">", ">", "addStatementToGroups", "(", "Statement", "statement", ",", "Map", "<", "String", ",", "List", "<", "Statement", ">", ">", "claims", ")", "{", "Map", "<", "String", ","...
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. @param statement @param claims @return
[ "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", ...
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/StatementDocumentImpl.java#L179-L202
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/StatementDocumentImpl.java
StatementDocumentImpl.removeStatements
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<Statement> filteredStatements = new ArrayList...
java
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<Statement> filteredStatements = new ArrayList...
[ "protected", "static", "Map", "<", "String", ",", "List", "<", "Statement", ">", ">", "removeStatements", "(", "Set", "<", "String", ">", "statementIds", ",", "Map", "<", "String", ",", "List", "<", "Statement", ">", ">", "claims", ")", "{", "Map", "<"...
Removes statement ids from a collection of statement groups. @param statementIds @param claims @return
[ "Removes", "statement", "ids", "from", "a", "collection", "of", "statement", "groups", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/StatementDocumentImpl.java#L210-L225
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/DatatypeIdImpl.java
DatatypeIdImpl.getDatatypeIriFromJsonDatatype
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_MEDI...
java
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_MEDI...
[ "public", "static", "String", "getDatatypeIriFromJsonDatatype", "(", "String", "jsonDatatype", ")", "{", "switch", "(", "jsonDatatype", ")", "{", "case", "JSON_DT_ITEM", ":", "return", "DT_ITEM", ";", "case", "JSON_DT_PROPERTY", ":", "return", "DT_PROPERTY", ";", ...
Returns the WDTK datatype IRI for the property datatype as represented by the given JSON datatype string. @param jsonDatatype the JSON datatype string; case-sensitive @throws IllegalArgumentException if the given datatype string is not known
[ "Returns", "the", "WDTK", "datatype", "IRI", "for", "the", "property", "datatype", "as", "represented", "by", "the", "given", "JSON", "datatype", "string", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/DatatypeIdImpl.java#L123-L154
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/DatatypeIdImpl.java
DatatypeIdImpl.getJsonDatatypeFromDatatypeIri
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 Dataty...
java
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 Dataty...
[ "public", "static", "String", "getJsonDatatypeFromDatatypeIri", "(", "String", "datatypeIri", ")", "{", "switch", "(", "datatypeIri", ")", "{", "case", "DatatypeIdValue", ".", "DT_ITEM", ":", "return", "DatatypeIdImpl", ".", "JSON_DT_ITEM", ";", "case", "DatatypeIdV...
Returns the JSON datatype for the property datatype as represented by the given WDTK datatype IRI string. @param datatypeIri the WDTK datatype IRI string; case-sensitive @throws IllegalArgumentException if the given datatype string is not known
[ "Returns", "the", "JSON", "datatype", "for", "the", "property", "datatype", "as", "represented", "by", "the", "given", "WDTK", "datatype", "IRI", "string", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/DatatypeIdImpl.java#L165-L204
train
Wikidata/Wikidata-Toolkit
wdtk-util/src/main/java/org/wikidata/wdtk/util/DirectoryManagerImpl.java
DirectoryManagerImpl.getCompressorInputStream
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 BufferedInpu...
java
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 BufferedInpu...
[ "protected", "InputStream", "getCompressorInputStream", "(", "InputStream", "inputStream", ",", "CompressionType", "compressionType", ")", "throws", "IOException", "{", "switch", "(", "compressionType", ")", "{", "case", "NONE", ":", "return", "inputStream", ";", "cas...
Returns an input stream that applies the required decompression to the given input stream. @param inputStream the input stream with the (possibly compressed) data @param compressionType the kind of compression @return an input stream with decompressed data @throws IOException if there was a problem creating the decomp...
[ "Returns", "an", "input", "stream", "that", "applies", "the", "required", "decompression", "to", "the", "given", "input", "stream", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-util/src/main/java/org/wikidata/wdtk/util/DirectoryManagerImpl.java#L191-L205
train
Wikidata/Wikidata-Toolkit
wdtk-util/src/main/java/org/wikidata/wdtk/util/DirectoryManagerImpl.java
DirectoryManagerImpl.createDirectory
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 crea...
java
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 crea...
[ "void", "createDirectory", "(", "Path", "path", ")", "throws", "IOException", "{", "if", "(", "Files", ".", "exists", "(", "path", ")", "&&", "Files", ".", "isDirectory", "(", "path", ")", ")", "{", "return", ";", "}", "if", "(", "this", ".", "readOn...
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. @param path @throws IOException if it was not possible to create a directory at the given path
[ "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", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-util/src/main/java/org/wikidata/wdtk/util/DirectoryManagerImpl.java#L230-L243
train
Wikidata/Wikidata-Toolkit
wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/wmf/WmfDumpFile.java
WmfDumpFile.getDumpFilePostfix
public static String getDumpFilePostfix(DumpContentType dumpContentType) { if (WmfDumpFile.POSTFIXES.containsKey(dumpContentType)) { return WmfDumpFile.POSTFIXES.get(dumpContentType); } else { throw new IllegalArgumentException("Unsupported dump type " + dumpContentType); } }
java
public static String getDumpFilePostfix(DumpContentType dumpContentType) { if (WmfDumpFile.POSTFIXES.containsKey(dumpContentType)) { return WmfDumpFile.POSTFIXES.get(dumpContentType); } else { throw new IllegalArgumentException("Unsupported dump type " + dumpContentType); } }
[ "public", "static", "String", "getDumpFilePostfix", "(", "DumpContentType", "dumpContentType", ")", "{", "if", "(", "WmfDumpFile", ".", "POSTFIXES", ".", "containsKey", "(", "dumpContentType", ")", ")", "{", "return", "WmfDumpFile", ".", "POSTFIXES", ".", "get", ...
Returns the ending used by the Wikimedia-provided dumpfile names of the given type. @param dumpContentType the type of dump @return postfix of the dumpfile name @throws IllegalArgumentException if the given dump file type is not known
[ "Returns", "the", "ending", "used", "by", "the", "Wikimedia", "-", "provided", "dumpfile", "names", "of", "the", "given", "type", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/wmf/WmfDumpFile.java#L150-L157
train
Wikidata/Wikidata-Toolkit
wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/wmf/WmfDumpFile.java
WmfDumpFile.getDumpFileWebDirectory
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" + "/";...
java
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" + "/";...
[ "public", "static", "String", "getDumpFileWebDirectory", "(", "DumpContentType", "dumpContentType", ",", "String", "projectName", ")", "{", "if", "(", "dumpContentType", "==", "DumpContentType", ".", "JSON", ")", "{", "if", "(", "\"wikidatawiki\"", ".", "equals", ...
Returns the absolute directory on the Web site where dumpfiles of the given type can be found. @param dumpContentType the type of dump @return relative web directory for the current dumpfiles @throws IllegalArgumentException if the given dump file type is not known
[ "Returns", "the", "absolute", "directory", "on", "the", "Web", "site", "where", "dumpfiles", "of", "the", "given", "type", "can", "be", "found", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/wmf/WmfDumpFile.java#L169-L190
train
Wikidata/Wikidata-Toolkit
wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/wmf/WmfDumpFile.java
WmfDumpFile.getDumpFileCompressionType
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; } }
java
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; } }
[ "public", "static", "CompressionType", "getDumpFileCompressionType", "(", "String", "fileName", ")", "{", "if", "(", "fileName", ".", "endsWith", "(", "\".gz\"", ")", ")", "{", "return", "CompressionType", ".", "GZIP", ";", "}", "else", "if", "(", "fileName", ...
Returns the compression type of this kind of dump file using file suffixes @param fileName the name of the file @return compression type @throws IllegalArgumentException if the given dump file type is not known
[ "Returns", "the", "compression", "type", "of", "this", "kind", "of", "dump", "file", "using", "file", "suffixes" ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/wmf/WmfDumpFile.java#L200-L208
train
Wikidata/Wikidata-Toolkit
wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/wmf/WmfDumpFile.java
WmfDumpFile.getDumpFileDirectoryName
public static String getDumpFileDirectoryName( DumpContentType dumpContentType, String dateStamp) { return dumpContentType.toString().toLowerCase() + "-" + dateStamp; }
java
public static String getDumpFileDirectoryName( DumpContentType dumpContentType, String dateStamp) { return dumpContentType.toString().toLowerCase() + "-" + dateStamp; }
[ "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. @param dumpContentType the type of the dump @param dateStamp the date of the dump in format YYYYMMDD @return the local directory name for the dumpfile
[ "Returns", "the", "name", "of", "the", "directory", "where", "the", "dumpfile", "of", "the", "given", "type", "and", "date", "should", "be", "stored", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/wmf/WmfDumpFile.java#L220-L223
train
Wikidata/Wikidata-Toolkit
wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/wmf/WmfDumpFile.java
WmfDumpFile.getDumpFileName
public static String getDumpFileName(DumpContentType dumpContentType, String projectName, String dateStamp) { if (dumpContentType == DumpContentType.JSON) { return dateStamp + WmfDumpFile.getDumpFilePostfix(dumpContentType); } else { return projectName + "-" + dateStamp + WmfDumpFile.getDumpFilePostfi...
java
public static String getDumpFileName(DumpContentType dumpContentType, String projectName, String dateStamp) { if (dumpContentType == DumpContentType.JSON) { return dateStamp + WmfDumpFile.getDumpFilePostfix(dumpContentType); } else { return projectName + "-" + dateStamp + WmfDumpFile.getDumpFilePostfi...
[ "public", "static", "String", "getDumpFileName", "(", "DumpContentType", "dumpContentType", ",", "String", "projectName", ",", "String", "dateStamp", ")", "{", "if", "(", "dumpContentType", "==", "DumpContentType", ".", "JSON", ")", "{", "return", "dateStamp", "+"...
Returns the name under which this dump file. This is the name used online and also locally when downloading the file. @param dumpContentType the type of the dump @param projectName the project name, e.g. "wikidatawiki" @param dateStamp the date of the dump in format YYYYMMDD @return file name string
[ "Returns", "the", "name", "under", "which", "this", "dump", "file", ".", "This", "is", "the", "name", "used", "online", "and", "also", "locally", "when", "downloading", "the", "file", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/wmf/WmfDumpFile.java#L253-L261
train
Wikidata/Wikidata-Toolkit
wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/wmf/WmfDumpFile.java
WmfDumpFile.isRevisionDumpFile
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); } }
java
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); } }
[ "public", "static", "boolean", "isRevisionDumpFile", "(", "DumpContentType", "dumpContentType", ")", "{", "if", "(", "WmfDumpFile", ".", "REVISION_DUMP", ".", "containsKey", "(", "dumpContentType", ")", ")", "{", "return", "WmfDumpFile", ".", "REVISION_DUMP", ".", ...
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. @param dumpContentType the type of dump @return true if the dumpfile contains revisions @throws IllegalArgumentException if the given dump file ...
[ "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", "lin...
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/wmf/WmfDumpFile.java#L274-L281
train
Wikidata/Wikidata-Toolkit
wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/JsonDumpFileProcessor.java
JsonDumpFileProcessor.processDumpFileContentsRecovery
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....
java
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....
[ "private", "void", "processDumpFileContentsRecovery", "(", "InputStream", "inputStream", ")", "throws", "IOException", "{", "JsonDumpFileProcessor", ".", "logger", ".", "warn", "(", "\"Entering recovery mode to parse rest of file. This might be slightly slower.\"", ")", ";", "B...
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 skipp...
[ "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"...
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-dumpfiles/src/main/java/org/wikidata/wdtk/dumpfiles/JsonDumpFileProcessor.java#L148-L188
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/JsonSerializer.java
JsonSerializer.reportException
private void reportException(Exception e) { logger.error("Failed to write JSON export: " + e.toString()); throw new RuntimeException(e.toString(), e); }
java
private void reportException(Exception e) { logger.error("Failed to write JSON export: " + e.toString()); throw new RuntimeException(e.toString(), e); }
[ "private", "void", "reportException", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "\"Failed to write JSON export: \"", "+", "e", ".", "toString", "(", ")", ")", ";", "throw", "new", "RuntimeException", "(", "e", ".", "toString", "(", ")", ...
Reports a given exception as a RuntimeException, since the interface does not allow us to throw checked exceptions directly. @param e the exception to report @throws RuntimeException in all cases
[ "Reports", "a", "given", "exception", "as", "a", "RuntimeException", "since", "the", "interface", "does", "not", "allow", "us", "to", "throw", "checked", "exceptions", "directly", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/JsonSerializer.java#L140-L143
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/JsonSerializer.java
JsonSerializer.jacksonObjectToString
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; } }
java
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; } }
[ "protected", "static", "String", "jacksonObjectToString", "(", "Object", "object", ")", "{", "try", "{", "return", "mapper", ".", "writeValueAsString", "(", "object", ")", ";", "}", "catch", "(", "JsonProcessingException", "e", ")", "{", "logger", ".", "error"...
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. @param object object to serialize @return JSON serialization or 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"...
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/JsonSerializer.java#L209-L216
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/ToString.java
ToString.getTimePrecisionString
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"; ...
java
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"; ...
[ "protected", "static", "String", "getTimePrecisionString", "(", "byte", "precision", ")", "{", "switch", "(", "precision", ")", "{", "case", "TimeValue", ".", "PREC_SECOND", ":", "return", "\"sec\"", ";", "case", "TimeValue", ".", "PREC_MINUTE", ":", "return", ...
Returns a human-readable string representation of a reference to a precision that is used for a time value. @param precision the numeric precision @return a string representation of the precision
[ "Returns", "a", "human", "-", "readable", "string", "representation", "of", "a", "reference", "to", "a", "precision", "that", "is", "used", "for", "a", "time", "value", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/ToString.java#L630-L665
train
Wikidata/Wikidata-Toolkit
wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WbEditingAction.java
WbEditingAction.wbSetLabel
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<...
java
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<...
[ "public", "JsonNode", "wbSetLabel", "(", "String", "id", ",", "String", "site", ",", "String", "title", ",", "String", "newEntity", ",", "String", "language", ",", "String", "value", ",", "boolean", "bot", ",", "long", "baserevid", ",", "String", "summary", ...
Executes the API action "wbsetlabel" for the given parameters. @param id the id of the entity to be edited; if used, the site and title parameters must be null @param site when selecting an entity by title, the site key for the title, e.g., "enwiki"; if used, title must also be given but id must be null @param title st...
[ "Executes", "the", "API", "action", "wbsetlabel", "for", "the", "given", "parameters", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WbEditingAction.java#L345-L361
train
Wikidata/Wikidata-Toolkit
wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WbEditingAction.java
WbEditingAction.wbSetAliases
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 parameter ...
java
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 parameter ...
[ "public", "JsonNode", "wbSetAliases", "(", "String", "id", ",", "String", "site", ",", "String", "title", ",", "String", "newEntity", ",", "String", "language", ",", "List", "<", "String", ">", "add", ",", "List", "<", "String", ">", "remove", ",", "List...
Executes the API action "wbsetaliases" for the given parameters. @param id the id of the entity to be edited; if used, the site and title parameters must be null @param site when selecting an entity by title, the site key for the title, e.g., "enwiki"; if used, title must also be given but id must be null @param title...
[ "Executes", "the", "API", "action", "wbsetaliases", "for", "the", "given", "parameters", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WbEditingAction.java#L482-L508
train
Wikidata/Wikidata-Toolkit
wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WbEditingAction.java
WbEditingAction.wbSetClaim
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, Str...
java
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, Str...
[ "public", "JsonNode", "wbSetClaim", "(", "String", "statement", ",", "boolean", "bot", ",", "long", "baserevid", ",", "String", "summary", ")", "throws", "IOException", ",", "MediaWikiApiErrorException", "{", "Validate", ".", "notNull", "(", "statement", ",", "\...
Executes the API action "wbsetclaim" for the given parameters. @param statement the JSON serialization of claim to add or delete. @param bot if true, edits will be flagged as "bot edits" provided that the logged in user is in the bot group; for regular users, the flag will just be ignored @param baserevid the revision...
[ "Executes", "the", "API", "action", "wbsetclaim", "for", "the", "given", "parameters", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WbEditingAction.java#L540-L551
train
Wikidata/Wikidata-Toolkit
wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WbEditingAction.java
WbEditingAction.wbRemoveClaims
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 to ...
java
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 to ...
[ "public", "JsonNode", "wbRemoveClaims", "(", "List", "<", "String", ">", "statementIds", ",", "boolean", "bot", ",", "long", "baserevid", ",", "String", "summary", ")", "throws", "IOException", ",", "MediaWikiApiErrorException", "{", "Validate", ".", "notNull", ...
Executes the API action "wbremoveclaims" for the given parameters. @param statementIds the statement ids to delete @param bot if true, edits will be flagged as "bot edits" provided that the logged in user is in the bot group; for regular users, the flag will just be ignored @param baserevid the revision of the data th...
[ "Executes", "the", "API", "action", "wbremoveclaims", "for", "the", "given", "parameters", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/WbEditingAction.java#L583-L597
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/bots/FixIntegerQuantityPrecisionsBot.java
FixIntegerQuantityPrecisionsBot.fixIntegerPrecisions
protected void fixIntegerPrecisions(ItemIdValue itemIdValue, String propertyId) { String qid = itemIdValue.getId(); try { // Fetch the online version of the item to make sure we edit the // current version: ItemDocument currentItemDocument = (ItemDocument) dataFetcher .getEntityDocument(qid); ...
java
protected void fixIntegerPrecisions(ItemIdValue itemIdValue, String propertyId) { String qid = itemIdValue.getId(); try { // Fetch the online version of the item to make sure we edit the // current version: ItemDocument currentItemDocument = (ItemDocument) dataFetcher .getEntityDocument(qid); ...
[ "protected", "void", "fixIntegerPrecisions", "(", "ItemIdValue", "itemIdValue", ",", "String", "propertyId", ")", "{", "String", "qid", "=", "itemIdValue", ".", "getId", "(", ")", ";", "try", "{", "// Fetch the online version of the item to make sure we edit the", "// c...
Fetches the current online data for the given item, and fixes the precision of integer quantities if necessary. @param itemIdValue the id of the document to inspect @param propertyId id of the property to consider
[ "Fetches", "the", "current", "online", "data", "for", "the", "given", "item", "and", "fixes", "the", "precision", "of", "integer", "quantities", "if", "necessary", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/bots/FixIntegerQuantityPrecisionsBot.java#L282-L345
train
Wikidata/Wikidata-Toolkit
wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/StatementUpdate.java
StatementUpdate.markStatementsForDeletion
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.getMainSnak().getPr...
java
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.getMainSnak().getPr...
[ "protected", "void", "markStatementsForDeletion", "(", "StatementDocument", "currentDocument", ",", "List", "<", "Statement", ">", "deleteStatements", ")", "{", "for", "(", "Statement", "statement", ":", "deleteStatements", ")", "{", "boolean", "found", "=", "false"...
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. @param currentDocument the document with the current statements @param deleteStatement...
[ "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...
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/StatementUpdate.java#L307-L346
train
Wikidata/Wikidata-Toolkit
wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/StatementUpdate.java
StatementUpdate.markStatementsForInsertion
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.getProperty())) { ...
java
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.getProperty())) { ...
[ "protected", "void", "markStatementsForInsertion", "(", "StatementDocument", "currentDocument", ",", "List", "<", "Statement", ">", "addStatements", ")", "{", "for", "(", "Statement", "statement", ":", "addStatements", ")", "{", "addStatement", "(", "statement", ","...
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 ...
[ "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"...
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/StatementUpdate.java#L361-L376
train
Wikidata/Wikidata-Toolkit
wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/StatementUpdate.java
StatementUpdate.addStatement
protected void addStatement(Statement statement, boolean isNew) { PropertyIdValue pid = statement.getMainSnak().getPropertyId(); // This code maintains the following properties: // (1) the toKeep structure does not contain two statements with the // same statement id // (2) the toKeep structure does not cont...
java
protected void addStatement(Statement statement, boolean isNew) { PropertyIdValue pid = statement.getMainSnak().getPropertyId(); // This code maintains the following properties: // (1) the toKeep structure does not contain two statements with the // same statement id // (2) the toKeep structure does not cont...
[ "protected", "void", "addStatement", "(", "Statement", "statement", ",", "boolean", "isNew", ")", "{", "PropertyIdValue", "pid", "=", "statement", ".", "getMainSnak", "(", ")", ".", "getPropertyId", "(", ")", ";", "// This code maintains the following properties:", ...
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. @param statement statement to add @param isNew if true, the statement should be mark...
[ "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", ...
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/StatementUpdate.java#L391-L451
train
Wikidata/Wikidata-Toolkit
wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/StatementUpdate.java
StatementUpdate.mergeReferences
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) { addB...
java
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) { addB...
[ "protected", "List", "<", "Reference", ">", "mergeReferences", "(", "List", "<", "?", "extends", "Reference", ">", "references1", ",", "List", "<", "?", "extends", "Reference", ">", "references2", ")", "{", "List", "<", "Reference", ">", "result", "=", "ne...
Merges two lists of references, eliminating duplicates in the process. @param references1 @param references2 @return merged list
[ "Merges", "two", "lists", "of", "references", "eliminating", "duplicates", "in", "the", "process", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/StatementUpdate.java#L503-L514
train
Wikidata/Wikidata-Toolkit
wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/StatementUpdate.java
StatementUpdate.equivalentClaims
protected boolean equivalentClaims(Claim claim1, Claim claim2) { return claim1.getMainSnak().equals(claim2.getMainSnak()) && isSameSnakSet(claim1.getAllQualifiers(), claim2.getAllQualifiers()); }
java
protected boolean equivalentClaims(Claim claim1, Claim claim2) { return claim1.getMainSnak().equals(claim2.getMainSnak()) && isSameSnakSet(claim1.getAllQualifiers(), claim2.getAllQualifiers()); }
[ "protected", "boolean", "equivalentClaims", "(", "Claim", "claim1", ",", "Claim", "claim2", ")", "{", "return", "claim1", ".", "getMainSnak", "(", ")", ".", "equals", "(", "claim2", ".", "getMainSnak", "(", ")", ")", "&&", "isSameSnakSet", "(", "claim1", "...
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. @param claim1 @param claim2 @return true if claims are equivalent
[ "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", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/StatementUpdate.java#L535-L539
train
Wikidata/Wikidata-Toolkit
wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/StatementUpdate.java
StatementUpdate.isSameSnakSet
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(); boolean found = false...
java
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(); boolean found = false...
[ "protected", "boolean", "isSameSnakSet", "(", "Iterator", "<", "Snak", ">", "snaks1", ",", "Iterator", "<", "Snak", ">", "snaks2", ")", "{", "ArrayList", "<", "Snak", ">", "snakList1", "=", "new", "ArrayList", "<>", "(", "5", ")", ";", "while", "(", "s...
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. @param snaks1 @param snaks2 @return true if the lists are equal
[ "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", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/StatementUpdate.java#L550-L574
train
Wikidata/Wikidata-Toolkit
wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/StatementUpdate.java
StatementUpdate.getRevisionIdFromResponse
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("pageinfo")) { entit...
java
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("pageinfo")) { entit...
[ "protected", "long", "getRevisionIdFromResponse", "(", "JsonNode", "response", ")", "throws", "JsonMappingException", "{", "if", "(", "response", "==", "null", ")", "{", "throw", "new", "JsonMappingException", "(", "\"API response is null\"", ")", ";", "}", "JsonNod...
Extracts the last revision id from the JSON response returned by the API after an edit @param response the response as returned by Mediawiki @return the new revision id of the edited entity @throws JsonMappingException
[ "Extracts", "the", "last", "revision", "id", "from", "the", "JSON", "response", "returned", "by", "the", "API", "after", "an", "edit" ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/StatementUpdate.java#L594-L608
train
Wikidata/Wikidata-Toolkit
wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/StatementUpdate.java
StatementUpdate.getDatamodelObjectFromResponse
protected <T> T getDatamodelObjectFromResponse(JsonNode response, List<String> path, Class<T> targetClass) throws JsonProcessingException { if(response == null) { throw new JsonMappingException("The API response is null"); } JsonNode currentNode = response; for(String field : path) { if (!currentNode.has(...
java
protected <T> T getDatamodelObjectFromResponse(JsonNode response, List<String> path, Class<T> targetClass) throws JsonProcessingException { if(response == null) { throw new JsonMappingException("The API response is null"); } JsonNode currentNode = response; for(String field : path) { if (!currentNode.has(...
[ "protected", "<", "T", ">", "T", "getDatamodelObjectFromResponse", "(", "JsonNode", "response", ",", "List", "<", "String", ">", "path", ",", "Class", "<", "T", ">", "targetClass", ")", "throws", "JsonProcessingException", "{", "if", "(", "response", "==", "...
Extracts a particular data model instance from a JSON response returned by MediaWiki. The location is described by a list of successive fields to use, from the root to the target object. @param response the API response as returned by MediaWiki @param path a list of fields from the root to the target object @return th...
[ "Extracts", "a", "particular", "data", "model", "instance", "from", "a", "JSON", "response", "returned", "by", "MediaWiki", ".", "The", "location", "is", "described", "by", "a", "list", "of", "successive", "fields", "to", "use", "from", "the", "root", "to", ...
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-wikibaseapi/src/main/java/org/wikidata/wdtk/wikibaseapi/StatementUpdate.java#L623-L635
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/EditOnlineDataExample.java
EditOnlineDataExample.findSomeStringProperties
public static void findSomeStringProperties(ApiConnection connection) throws MediaWikiApiErrorException, IOException { WikibaseDataFetcher wbdf = new WikibaseDataFetcher(connection, siteIri); wbdf.getFilter().excludeAllProperties(); wbdf.getFilter().setLanguageFilter(Collections.singleton("en")); ArrayList<...
java
public static void findSomeStringProperties(ApiConnection connection) throws MediaWikiApiErrorException, IOException { WikibaseDataFetcher wbdf = new WikibaseDataFetcher(connection, siteIri); wbdf.getFilter().excludeAllProperties(); wbdf.getFilter().setLanguageFilter(Collections.singleton("en")); ArrayList<...
[ "public", "static", "void", "findSomeStringProperties", "(", "ApiConnection", "connection", ")", "throws", "MediaWikiApiErrorException", ",", "IOException", "{", "WikibaseDataFetcher", "wbdf", "=", "new", "WikibaseDataFetcher", "(", "connection", ",", "siteIri", ")", ";...
Finds properties of datatype string on test.wikidata.org. Since the test site changes all the time, we cannot hardcode a specific property here. Instead, we just look through all properties starting from P1 to find the first few properties of type string that have an English label. These properties are used for testing...
[ "Finds", "properties", "of", "datatype", "string", "on", "test", ".", "wikidata", ".", "org", ".", "Since", "the", "test", "site", "changes", "all", "the", "time", "we", "cannot", "hardcode", "a", "specific", "property", "here", ".", "Instead", "we", "just...
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/EditOnlineDataExample.java#L231-L269
train
Wikidata/Wikidata-Toolkit
wdtk-storage/src/main/java/org/wikidata/wdtk/storage/datastructures/FindPositionArray.java
FindPositionArray.findPosition
public long findPosition(long nOccurrence) { updateCount(); if (nOccurrence <= 0) { return RankedBitVector.NOT_FOUND; } int findPos = (int) (nOccurrence / this.blockSize); if (findPos < this.positionArray.length) { long pos0 = this.positionArray[findPos]; long leftOccurrences = nOccurrence - (findPos...
java
public long findPosition(long nOccurrence) { updateCount(); if (nOccurrence <= 0) { return RankedBitVector.NOT_FOUND; } int findPos = (int) (nOccurrence / this.blockSize); if (findPos < this.positionArray.length) { long pos0 = this.positionArray[findPos]; long leftOccurrences = nOccurrence - (findPos...
[ "public", "long", "findPosition", "(", "long", "nOccurrence", ")", "{", "updateCount", "(", ")", ";", "if", "(", "nOccurrence", "<=", "0", ")", "{", "return", "RankedBitVector", ".", "NOT_FOUND", ";", "}", "int", "findPos", "=", "(", "int", ")", "(", "...
Returns the position for a given number of occurrences or NOT_FOUND if this value is not found. @param nOccurrence number of occurrences @return the position for a given number of occurrences or NOT_FOUND if this value is not found
[ "Returns", "the", "position", "for", "a", "given", "number", "of", "occurrences", "or", "NOT_FOUND", "if", "this", "value", "is", "not", "found", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-storage/src/main/java/org/wikidata/wdtk/storage/datastructures/FindPositionArray.java#L148-L170
train
Wikidata/Wikidata-Toolkit
wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/OwlDeclarationBuffer.java
OwlDeclarationBuffer.writeNoValueRestriction
void writeNoValueRestriction(RdfWriter rdfWriter, String propertyUri, String rangeUri, String subject) throws RDFHandlerException { Resource bnodeSome = rdfWriter.getFreshBNode(); rdfWriter.writeTripleValueObject(subject, RdfWriter.RDF_TYPE, RdfWriter.OWL_CLASS); rdfWriter.writeTripleValueObject(subject, ...
java
void writeNoValueRestriction(RdfWriter rdfWriter, String propertyUri, String rangeUri, String subject) throws RDFHandlerException { Resource bnodeSome = rdfWriter.getFreshBNode(); rdfWriter.writeTripleValueObject(subject, RdfWriter.RDF_TYPE, RdfWriter.OWL_CLASS); rdfWriter.writeTripleValueObject(subject, ...
[ "void", "writeNoValueRestriction", "(", "RdfWriter", "rdfWriter", ",", "String", "propertyUri", ",", "String", "rangeUri", ",", "String", "subject", ")", "throws", "RDFHandlerException", "{", "Resource", "bnodeSome", "=", "rdfWriter", ".", "getFreshBNode", "(", ")",...
Writes no-value restriction. @param rdfWriter the writer to write the restrictions to @param propertyUri URI of the property to which the restriction applies @param rangeUri URI of the class or datatype to which the restriction applies @param subject node representing the restriction @throws RDFHandlerException if the...
[ "Writes", "no", "-", "value", "restriction", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/OwlDeclarationBuffer.java#L264-L278
train
Wikidata/Wikidata-Toolkit
wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/StatementBuilder.java
StatementBuilder.withQualifierValue
public StatementBuilder withQualifierValue(PropertyIdValue propertyIdValue, Value value) { withQualifier(factory.getValueSnak(propertyIdValue, value)); return getThis(); }
java
public StatementBuilder withQualifierValue(PropertyIdValue propertyIdValue, Value value) { withQualifier(factory.getValueSnak(propertyIdValue, value)); return getThis(); }
[ "public", "StatementBuilder", "withQualifierValue", "(", "PropertyIdValue", "propertyIdValue", ",", "Value", "value", ")", "{", "withQualifier", "(", "factory", ".", "getValueSnak", "(", "propertyIdValue", ",", "value", ")", ")", ";", "return", "getThis", "(", ")"...
Adds a qualifier with the given property and value to the constructed statement. @param propertyIdValue the property of the qualifier @param value the value of the qualifier @return builder object to continue construction
[ "Adds", "a", "qualifier", "with", "the", "given", "property", "and", "value", "to", "the", "constructed", "statement", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/helpers/StatementBuilder.java#L153-L157
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/EntityStatisticsProcessor.java
EntityStatisticsProcessor.countStatements
protected void countStatements(UsageStatistics usageStatistics, StatementDocument statementDocument) { // Count Statement data: for (StatementGroup sg : statementDocument.getStatementGroups()) { // Count Statements: usageStatistics.countStatements += sg.size(); // Count uses of properties in Statements...
java
protected void countStatements(UsageStatistics usageStatistics, StatementDocument statementDocument) { // Count Statement data: for (StatementGroup sg : statementDocument.getStatementGroups()) { // Count Statements: usageStatistics.countStatements += sg.size(); // Count uses of properties in Statements...
[ "protected", "void", "countStatements", "(", "UsageStatistics", "usageStatistics", ",", "StatementDocument", "statementDocument", ")", "{", "// Count Statement data:", "for", "(", "StatementGroup", "sg", ":", "statementDocument", ".", "getStatementGroups", "(", ")", ")", ...
Count the statements and property uses of an item or property document. @param usageStatistics statistics object to store counters in @param statementDocument document to count the statements of
[ "Count", "the", "statements", "and", "property", "uses", "of", "an", "item", "or", "property", "document", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/EntityStatisticsProcessor.java#L178-L200
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/EntityStatisticsProcessor.java
EntityStatisticsProcessor.writeFinalResults
private void writeFinalResults() { // Print a final report: printStatus(); // Store property counts in files: writePropertyStatisticsToFile(this.itemStatistics, "item-property-counts.csv"); writePropertyStatisticsToFile(this.propertyStatistics, "property-property-counts.csv"); // Store site link s...
java
private void writeFinalResults() { // Print a final report: printStatus(); // Store property counts in files: writePropertyStatisticsToFile(this.itemStatistics, "item-property-counts.csv"); writePropertyStatisticsToFile(this.propertyStatistics, "property-property-counts.csv"); // Store site link s...
[ "private", "void", "writeFinalResults", "(", ")", "{", "// Print a final report:", "printStatus", "(", ")", ";", "// Store property counts in files:", "writePropertyStatisticsToFile", "(", "this", ".", "itemStatistics", ",", "\"item-property-counts.csv\"", ")", ";", "writeP...
Prints and stores final result of the processing. This should be called after finishing the processing of a dump. It will print the statistics gathered during processing and it will write a CSV file with usage counts for every property.
[ "Prints", "and", "stores", "final", "result", "of", "the", "processing", ".", "This", "should", "be", "called", "after", "finishing", "the", "processing", "of", "a", "dump", ".", "It", "will", "print", "the", "statistics", "gathered", "during", "processing", ...
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/EntityStatisticsProcessor.java#L227-L255
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/EntityStatisticsProcessor.java
EntityStatisticsProcessor.writePropertyStatisticsToFile
private void writePropertyStatisticsToFile(UsageStatistics usageStatistics, String fileName) { try (PrintStream out = new PrintStream( ExampleHelpers.openExampleFileOuputStream(fileName))) { out.println("Property id,in statements,in qualifiers,in references,total"); for (Entry<PropertyIdValue, Integer>...
java
private void writePropertyStatisticsToFile(UsageStatistics usageStatistics, String fileName) { try (PrintStream out = new PrintStream( ExampleHelpers.openExampleFileOuputStream(fileName))) { out.println("Property id,in statements,in qualifiers,in references,total"); for (Entry<PropertyIdValue, Integer>...
[ "private", "void", "writePropertyStatisticsToFile", "(", "UsageStatistics", "usageStatistics", ",", "String", "fileName", ")", "{", "try", "(", "PrintStream", "out", "=", "new", "PrintStream", "(", "ExampleHelpers", ".", "openExampleFileOuputStream", "(", "fileName", ...
Stores the gathered usage statistics about property uses to a CSV file. @param usageStatistics the statistics to store @param fileName the name of the file to use
[ "Stores", "the", "gathered", "usage", "statistics", "about", "property", "uses", "to", "a", "CSV", "file", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/EntityStatisticsProcessor.java#L265-L285
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/EntityStatisticsProcessor.java
EntityStatisticsProcessor.writeTermStatisticsToFile
private void writeTermStatisticsToFile(UsageStatistics usageStatistics, String fileName) { // Make sure all keys are present in label count map: for (String key : usageStatistics.aliasCounts.keySet()) { countKey(usageStatistics.labelCounts, key, 0); } for (String key : usageStatistics.descriptionCounts.k...
java
private void writeTermStatisticsToFile(UsageStatistics usageStatistics, String fileName) { // Make sure all keys are present in label count map: for (String key : usageStatistics.aliasCounts.keySet()) { countKey(usageStatistics.labelCounts, key, 0); } for (String key : usageStatistics.descriptionCounts.k...
[ "private", "void", "writeTermStatisticsToFile", "(", "UsageStatistics", "usageStatistics", ",", "String", "fileName", ")", "{", "// Make sure all keys are present in label count map:", "for", "(", "String", "key", ":", "usageStatistics", ".", "aliasCounts", ".", "keySet", ...
Stores the gathered usage statistics about term uses by language to a CSV file. @param usageStatistics the statistics to store @param fileName the name of the file to use
[ "Stores", "the", "gathered", "usage", "statistics", "about", "term", "uses", "by", "language", "to", "a", "CSV", "file", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/EntityStatisticsProcessor.java#L296-L324
train
Wikidata/Wikidata-Toolkit
wdtk-examples/src/main/java/org/wikidata/wdtk/examples/EntityStatisticsProcessor.java
EntityStatisticsProcessor.printStatistics
private void printStatistics(UsageStatistics usageStatistics, String entityLabel) { System.out.println("Processed " + usageStatistics.count + " " + entityLabel + ":"); System.out.println(" * Labels: " + usageStatistics.countLabels + ", descriptions: " + usageStatistics.countDescriptions + ", aliases:...
java
private void printStatistics(UsageStatistics usageStatistics, String entityLabel) { System.out.println("Processed " + usageStatistics.count + " " + entityLabel + ":"); System.out.println(" * Labels: " + usageStatistics.countLabels + ", descriptions: " + usageStatistics.countDescriptions + ", aliases:...
[ "private", "void", "printStatistics", "(", "UsageStatistics", "usageStatistics", ",", "String", "entityLabel", ")", "{", "System", ".", "out", ".", "println", "(", "\"Processed \"", "+", "usageStatistics", ".", "count", "+", "\" \"", "+", "entityLabel", "+", "\"...
Prints a report about the statistics stored in the given data object. @param usageStatistics the statistics object to print @param entityLabel the label to use to refer to this kind of entities ("items" or "properties")
[ "Prints", "a", "report", "about", "the", "statistics", "stored", "in", "the", "given", "data", "object", "." ]
7732851dda47e1febff406fba27bfec023f4786e
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-examples/src/main/java/org/wikidata/wdtk/examples/EntityStatisticsProcessor.java#L346-L356
train