@JsonProperty("lexicalCategory") String getJsonLexicalCategory() { return lexicalCategory.getId(); }
@JsonProperty("lexicalCategory") String getJsonLexicalCategory() { return lexicalCategory.getId(); }
@JsonProperty("language") String getJsonLanguage() { return language.getId(); }
@JsonProperty("language") String getJsonLanguage() { return language.getId(); }
@JsonProperty("grammaticalFeatures") List<String> getJsonGrammaticalFeatures() { if (grammaticalFeatures.isEmpty()) { return Collections.emptyList(); } List<String> output = new ArrayList<>(grammaticalFeatures.size()); for(ItemIdValue feature : grammaticalFeatures) { output.add(feature.getId()); } return output; }
@JsonProperty("grammaticalFeatures") List<String> getJsonGrammaticalFeatures() { if (grammaticalFeatures.isEmpty()) { return Collections.emptyList(); } List<String> output = new ArrayList<>(grammaticalFeatures.size()); for(ItemIdValue feature : grammaticalFeatures) { output.add(feature.getId()); } return output; }
@JsonProperty("badges") List<String> getBadgesString() { if (badges.isEmpty()) { return Collections.emptyList(); } List<String> output = new ArrayList<>(badges.size()); for(ItemIdValue badge : badges) { output.add(badge.getId()); } return output; }
/** * Prints the current status, time and entity count. */ public void printStatus() { System.out.println("Found " + this.itemsWithPropertyCount + " matching items after scanning " + this.itemCount + " items."); if (this.largestNumberValue != null) { System.out.println("The item with the greatest number is: " + this.largestNumberItemLabel + " (" + this.largestNumberItem.getId() + ") with number " + this.largestNumberValue); } else { System.out.println("No number with a specified value found yet."); } }
@JsonProperty("badges") List<String> getBadgesString() { if (badges.isEmpty()) { return Collections.emptyList(); } List<String> output = new ArrayList<>(badges.size()); for(ItemIdValue badge : badges) { output.add(badge.getId()); } return output; }
/** * Prints the current status, time and entity count. */ public void printStatus() { System.out.println("Found " + this.itemsWithPropertyCount + " matching items after scanning " + this.itemCount + " items."); if (this.largestNumberValue != null) { System.out.println("The item with the greatest number is: " + this.largestNumberItemLabel + " (" + this.largestNumberItem.getId() + ") with number " + this.largestNumberValue); } else { System.out.println("No number with a specified value found yet."); } }
/** * Copies an {@link ItemIdValue}. * * @param object * object to copy * @return copied object */ public ItemIdValue copy(ItemIdValue object) { return dataObjectFactory.getItemIdValue(object.getId(), object.getSiteIri()); }
/** * Copies an {@link ItemIdValue}. * * @param object * object to copy * @return copied object */ public ItemIdValue copy(ItemIdValue object) { return dataObjectFactory.getItemIdValue(object.getId(), object.getSiteIri()); }
/** * Performs a null edit on an item. This has some effects on Wikibase, * such as refreshing the labels of the referred items in the UI. * * @param itemId * the document to perform a null edit on * @throws MediaWikiApiErrorException * if the API returns errors * @throws IOException * if there are any IO errors, such as missing network connection */ public <T extends StatementDocument> void nullEdit(ItemIdValue itemId) throws IOException, MediaWikiApiErrorException { ItemDocument currentDocument = (ItemDocument) this.wikibaseDataFetcher .getEntityDocument(itemId.getId()); nullEdit(currentDocument); }
/** * Performs a null edit on an item. This has some effects on Wikibase, * such as refreshing the labels of the referred items in the UI. * * @param itemId * the document to perform a null edit on * @throws MediaWikiApiErrorException * if the API returns errors * @throws IOException * if there are any IO errors, such as missing network connection */ public <T extends StatementDocument> void nullEdit(ItemIdValue itemId) throws IOException, MediaWikiApiErrorException { ItemDocument currentDocument = (ItemDocument) this.wikibaseDataFetcher .getEntityDocument(itemId.getId()); nullEdit(currentDocument); }
.getEntityDocument(itemIdValue.getId());
@Override public void processItemDocument(ItemDocument itemDocument) { if (itemDocument.hasStatement("P1181")) { if (lacksSomeLanguage(itemDocument)) { addLabelForNumbers(itemDocument.getEntityId()); } else { System.out.println("*** Labels already complete for " + itemDocument.getEntityId().getId()); } } // else: ignore items that have no numeric value }
@Override public void processItemDocument(ItemDocument itemDocument) { if (itemDocument.hasStatement("P1181")) { if (lacksSomeLanguage(itemDocument)) { addLabelForNumbers(itemDocument.getEntityId()); } else { System.out.println("*** Labels already complete for " + itemDocument.getEntityId().getId()); } } // else: ignore items that have no numeric value }
@Override public void processItemDocument(ItemDocument itemDocument) { // Record relevant labels: Integer itemId = getNumId(itemDocument.getEntityId().getId(), false); if (this.classRecords.containsKey(itemId)) { this.classRecords.get(itemId).label = itemDocument.findLabel("en"); } countTerms(itemDocument, itemStatistics); processStatementDocument(itemDocument, itemStatistics); this.countSiteLinks += itemDocument.getSiteLinks().size(); for (SiteLink siteLink : itemDocument.getSiteLinks().values()) { countSiteLink(siteLink); } }
/** * Returns true if the given document should be included in the * serialization. * * @param itemDocument * the document to check * @return true if the document should be serialized */ private boolean includeDocument(ItemDocument itemDocument) { for (StatementGroup sg : itemDocument.getStatementGroups()) { // "P19" is "place of birth" on Wikidata if (!"P19".equals(sg.getProperty().getId())) { continue; } for (Statement s : sg) { if (s.getMainSnak() instanceof ValueSnak) { Value v = s.getValue(); // "Q1731" is "Dresden" on Wikidata if (v instanceof ItemIdValue && "Q1731".equals(((ItemIdValue) v).getId())) { return true; } } } } return false; } }
@Override public void processItemDocument(ItemDocument itemDocument) { this.itemCount++; // Find the first quantity value for this property, if any: QuantityValue quantityValue = itemDocument .findStatementQuantityValue(numberPropertyId); // If a value was found, compare it to the current maximum: if (quantityValue != null) { this.itemsWithPropertyCount++; BigDecimal numericValue = quantityValue.getNumericValue(); if (this.largestNumberValue == null || numericValue.compareTo(this.largestNumberValue) > 0) { this.largestNumberValue = numericValue; this.largestNumberItem = itemDocument.getEntityId(); MonolingualTextValue label = itemDocument.getLabels().get("en"); if (label != null) { this.largestNumberItemLabel = label.getText(); } else { this.largestNumberItemLabel = this.largestNumberItem .getId(); } } } // Print progress every 100,000 items: if (this.itemCount % 100000 == 0) { printStatus(); } }