/** * Counts the given coordinates, unless the item document is filtered. * It is assumed that the coordinates are in the admissible range. * * @param xCoord * @param yCoord * @param itemDocument * @return */ public void countCoordinates(int xCoord, int yCoord, ItemDocument itemDocument) { if (this.siteFilter != null) { if (!itemDocument.getSiteLinks().containsKey(this.siteFilter)) { return; } } this.count++; this.values[xCoord][yCoord] += 1; if (this.maxValue < this.values[xCoord][yCoord]) { this.maxValue = this.values[xCoord][yCoord]; } }
/** * Counts the given coordinates, unless the item document is filtered. * It is assumed that the coordinates are in the admissible range. * * @param xCoord * @param yCoord * @param itemDocument * @return */ public void countCoordinates(int xCoord, int yCoord, ItemDocument itemDocument) { if (this.siteFilter != null) { if (!itemDocument.getSiteLinks().containsKey(this.siteFilter)) { return; } } this.count++; this.values[xCoord][yCoord] += 1; if (this.maxValue < this.values[xCoord][yCoord]) { this.maxValue = this.values[xCoord][yCoord]; } }
/** * Constructor to start the build from an existing item. * * @param initialDocument * the item to start the build from */ protected ItemDocumentBuilder(ItemDocument initialDocument) { super(initialDocument); for(SiteLink siteLink : initialDocument.getSiteLinks().values()) { withSiteLink(siteLink); } }
/** * Constructor to start the build from an existing item. * * @param initialDocument * the item to start the build from */ protected ItemDocumentBuilder(ItemDocument initialDocument) { super(initialDocument); for(SiteLink siteLink : initialDocument.getSiteLinks().values()) { withSiteLink(siteLink); } }
/** * Counts a single pair of coordinates in all datasets. * * @param xCoord * @param yCoord * @param itemDocument */ private void countCoordinates(int xCoord, int yCoord, ItemDocument itemDocument) { for (String siteKey : itemDocument.getSiteLinks().keySet()) { Integer count = this.siteCounts.get(siteKey); if (count == null) { this.siteCounts.put(siteKey, 1); } else { this.siteCounts.put(siteKey, count + 1); } } for (ValueMap vm : this.valueMaps) { vm.countCoordinates(xCoord, yCoord, itemDocument); } }
/** * Counts a single pair of coordinates in all datasets. * * @param xCoord * @param yCoord * @param itemDocument */ private void countCoordinates(int xCoord, int yCoord, ItemDocument itemDocument) { for (String siteKey : itemDocument.getSiteLinks().keySet()) { Integer count = this.siteCounts.get(siteKey); if (count == null) { this.siteCounts.put(siteKey, 1); } else { this.siteCounts.put(siteKey, count + 1); } } for (ValueMap vm : this.valueMaps) { vm.countCoordinates(xCoord, yCoord, itemDocument); } }
/** * Returns a hash code for the given object. * * @see java.lang.Object#hashCode() * @param o * the object to create a hash for * @return the hash code of the object */ public static int hashCode(ItemDocument o) { int result; result = hashCodeForTermedDocument(o); result = prime * result + o.getStatementGroups().hashCode(); result = prime * result + o.getSiteLinks().hashCode(); return result; }
/** * Returns a hash code for the given object. * * @see java.lang.Object#hashCode() * @param o * the object to create a hash for * @return the hash code of the object */ public static int hashCode(ItemDocument o) { int result; result = hashCodeForTermedDocument(o); result = prime * result + o.getStatementGroups().hashCode(); result = prime * result + o.getSiteLinks().hashCode(); return result; }
/** * Returns true if the parameters are two {@link ItemDocument} objects with * exactly the same data. It does not matter if they are different * implementations of the interface as long as their content is the same. * * @param o1 * the first object to compare * @param o2 * the second object to compare * @return true if both objects are equal */ public static boolean equalsItemDocument(ItemDocument o1, Object o2) { if (o2 == o1) { return true; } if (!(o2 instanceof ItemDocument)) { return false; } ItemDocument other = (ItemDocument) o2; // Note: item id already compared by equalsTermedDocument() return equalsTermedDocument(o1, other) && o1.getSiteLinks().equals(other.getSiteLinks()) && o1.getStatementGroups().equals(other.getStatementGroups()); }
/** * Returns true if the parameters are two {@link ItemDocument} objects with * exactly the same data. It does not matter if they are different * implementations of the interface as long as their content is the same. * * @param o1 * the first object to compare * @param o2 * the second object to compare * @return true if both objects are equal */ public static boolean equalsItemDocument(ItemDocument o1, Object o2) { if (o2 == o1) { return true; } if (!(o2 instanceof ItemDocument)) { return false; } ItemDocument other = (ItemDocument) o2; // Note: item id already compared by equalsTermedDocument() return equalsTermedDocument(o1, other) && o1.getSiteLinks().equals(other.getSiteLinks()) && o1.getStatementGroups().equals(other.getStatementGroups()); }
/** * Returns a human-readable string representation of the given object. * * @see java.lang.Object#toString() * @param o * the object to represent as string * @return a string representation of the object */ public static String toString(ItemDocument o) { StringBuilder sb = new StringBuilder(); sb.append("==ItemDocument ").append(o.getEntityId().getIri()); sb.append(" (r").append(o.getRevisionId()).append(") "); sb.append("==").append(toStringForTermedDocument(o)); sb.append(toStringForStatementDocument(o)); sb.append("* Site links: "); boolean first = true; SortedSet<String> siteKeys = new TreeSet<>(o.getSiteLinks() .keySet()); for (String key : siteKeys) { if (first) { first = false; } else { sb.append("; "); } sb.append(toString(o.getSiteLinks().get(key))); } return sb.toString(); }
/** * Returns a human-readable string representation of the given object. * * @see java.lang.Object#toString() * @param o * the object to represent as string * @return a string representation of the object */ public static String toString(ItemDocument o) { StringBuilder sb = new StringBuilder(); sb.append("==ItemDocument ").append(o.getEntityId().getIri()); sb.append(" (r").append(o.getRevisionId()).append(") "); sb.append("==").append(toStringForTermedDocument(o)); sb.append(toStringForStatementDocument(o)); sb.append("* Site links: "); boolean first = true; SortedSet<String> siteKeys = new TreeSet<>(o.getSiteLinks() .keySet()); for (String key : siteKeys) { if (first) { first = false; } else { sb.append("; "); } sb.append(toString(o.getSiteLinks().get(key))); } return sb.toString(); }
@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); } }
@Override public void processItemDocument(ItemDocument itemDocument) { // Count items: this.itemStatistics.count++; countTerms(this.itemStatistics, itemDocument); countStatements(this.itemStatistics, itemDocument); // Count site links: this.countSiteLinks += itemDocument.getSiteLinks().size(); for (SiteLink siteLink : itemDocument.getSiteLinks().values()) { countKey(this.siteLinkStatistics, siteLink.getSiteKey(), 1); } // Print a report every 10000 items: if (this.itemStatistics.count % 10000 == 0) { printStatus(); } }
@Override public void processItemDocument(ItemDocument itemDocument) { // Count items: this.itemStatistics.count++; countTerms(this.itemStatistics, itemDocument); countStatements(this.itemStatistics, itemDocument); // Count site links: this.countSiteLinks += itemDocument.getSiteLinks().size(); for (SiteLink siteLink : itemDocument.getSiteLinks().values()) { countKey(this.siteLinkStatistics, siteLink.getSiteKey(), 1); } // Print a report every 10000 items: if (this.itemStatistics.count % 10000 == 0) { printStatus(); } }
public ItemDocument filter(ItemDocument item) { return dataObjectFactory.getItemDocument( item.getEntityId(), filterMonoLingualTextValues(item.getLabels().values()), filterMonoLingualTextValues(item.getDescriptions().values()), filterMonoLingualTextValues(flatten(item.getAliases().values())), filterStatementGroups(item.getStatementGroups()), filterSiteLinks(item.getSiteLinks()), item.getRevisionId() ); }
public ItemDocument filter(ItemDocument item) { return dataObjectFactory.getItemDocument( item.getEntityId(), filterMonoLingualTextValues(item.getLabels().values()), filterMonoLingualTextValues(item.getDescriptions().values()), filterMonoLingualTextValues(flatten(item.getAliases().values())), filterStatementGroups(item.getStatementGroups()), filterSiteLinks(item.getSiteLinks()), item.getRevisionId() ); }
/** * Copies an {@link ItemDocument}. * * @param object * object to copy * @return copied object */ public ItemDocument copy(ItemDocument object) { return dataObjectFactory.getItemDocument( copy(object.getEntityId()), copyMonoLingualTextValues(object.getLabels().values()), copyMonoLingualTextValues(object.getDescriptions().values()), copyAliasMap(object.getAliases()), copyStatementGroups(object.getStatementGroups()), copySiteLinks(object.getSiteLinks()), object.getRevisionId()); }
/** * Copies an {@link ItemDocument}. * * @param object * object to copy * @return copied object */ public ItemDocument copy(ItemDocument object) { return dataObjectFactory.getItemDocument( copy(object.getEntityId()), copyMonoLingualTextValues(object.getLabels().values()), copyMonoLingualTextValues(object.getDescriptions().values()), copyAliasMap(object.getAliases()), copyStatementGroups(object.getStatementGroups()), copySiteLinks(object.getSiteLinks()), object.getRevisionId()); }
public void writeItemDocument(ItemDocument document) throws RDFHandlerException { if (!hasTask(RdfSerializer.TASK_ITEMS)) { return; } String subjectUri = document.getEntityId().getIri(); // probably // construct the // URI from // Vocabulary Resource subject = this.rdfWriter.getUri(subjectUri); if ((this.tasks & (RdfSerializer.TASK_ALL_EXACT_DATA | RdfSerializer.TASK_SIMPLE_STATEMENTS)) != 0) { this.rdfWriter.writeTripleValueObject(subject, RdfWriter.RDF_TYPE, RdfWriter.WB_ITEM); } writeDocumentTerms(subject, document); if (hasTask(RdfSerializer.TASK_SIMPLE_STATEMENTS)) { writeSimpleStatements(subject, document); } if (hasTask(RdfSerializer.TASK_STATEMENTS)) { writeStatements(subject, document); } writeSiteLinks(subject, document.getSiteLinks()); this.snakRdfConverter.writeAuxiliaryTriples(); this.owlDeclarationBuffer.writePropertyDeclarations(this.rdfWriter, hasTask(RdfSerializer.TASK_STATEMENTS), hasTask(RdfSerializer.TASK_SIMPLE_STATEMENTS)); this.referenceRdfConverter.writeReferences(); }