/** * Returns the string label for the given language code, or null if there is * no label for this code. This is a convenience method for accessing the * data that can be obtained via {@link #getLabels()}. * * @param languageCode * a string that represents language * @return the label string or null if it does not exists */ default String findLabel(String languageCode) { MonolingualTextValue value = this.getLabels().get(languageCode); return (value != null) ? value.getText() : null; }
/** * Returns the string label for the given language code, or null if there is * no label for this code. This is a convenience method for accessing the * data that can be obtained via {@link #getLabels()}. * * @param languageCode * a string that represents language * @return the label string or null if it does not exists */ default String findLabel(String languageCode) { MonolingualTextValue value = this.getLabels().get(languageCode); return (value != null) ? value.getText() : null; }
/** * 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 */ private static int hashCodeForTermedDocument(TermedDocument o) { int result; result = o.getAliases().hashCode(); result = prime * result + o.getDescriptions().hashCode(); result = prime * result + o.getLabels().hashCode(); result = prime * result + Long.hashCode(o.getRevisionId()); 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 */ private static int hashCodeForTermedDocument(TermedDocument o) { int result; result = o.getAliases().hashCode(); result = prime * result + o.getDescriptions().hashCode(); result = prime * result + o.getLabels().hashCode(); result = prime * result + Long.hashCode(o.getRevisionId()); return result; }
/** * Returns the CSV-escaped label for the given entity based on the terms in * the given document. The returned string will have its quotes escaped, but * it will not be put in quotes (since this is not appropriate in all * contexts where this method is used). * * @param entityIdValue * the entity to label * @param termedDocument * the document to get labels from * @return the label */ private String getLabel(EntityIdValue entityIdValue, TermedDocument termedDocument) { MonolingualTextValue labelValue = termedDocument.getLabels().get("en"); if (labelValue != null) { return labelValue.getText().replace("\"", "\"\""); } else { return entityIdValue.getId(); } }
/** * Returns the CSV-escaped label for the given entity based on the terms in * the given document. The returned string will have its quotes escaped, but * it will not be put in quotes (since this is not appropriate in all * contexts where this method is used). * * @param entityIdValue * the entity to label * @param termedDocument * the document to get labels from * @return the label */ private String getLabel(EntityIdValue entityIdValue, TermedDocument termedDocument) { MonolingualTextValue labelValue = termedDocument.getLabels().get("en"); if (labelValue != null) { return labelValue.getText().replace("\"", "\"\""); } else { return entityIdValue.getId(); } }
private static boolean equalsTermedDocument(TermedDocument o1, TermedDocument other) { return o1.getEntityId().equals(other.getEntityId()) && o1.getAliases().equals(other.getAliases()) && o1.getDescriptions().equals(other.getDescriptions()) && o1.getLabels().equals(other.getLabels()) && (o1.getRevisionId() == other.getRevisionId()); }
private static boolean equalsTermedDocument(TermedDocument o1, TermedDocument other) { return o1.getEntityId().equals(other.getEntityId()) && o1.getAliases().equals(other.getAliases()) && o1.getDescriptions().equals(other.getDescriptions()) && o1.getLabels().equals(other.getLabels()) && (o1.getRevisionId() == other.getRevisionId()); }
/** * Count the terms (labels, descriptions, aliases) of an item or property * document. * * @param termedDocument * document to count the terms of * @param entityStatistics * record where statistics are counted */ protected void countTerms(TermedDocument termedDocument, EntityStatistics entityStatistics) { entityStatistics.countLabels += termedDocument.getLabels().size(); // for (MonolingualTextValue mtv : termedDocument.getLabels().values()) // { // countKey(usageStatistics.labelCounts, mtv.getLanguageCode(), 1); // } entityStatistics.countDescriptions += termedDocument.getDescriptions() .size(); // for (MonolingualTextValue mtv : termedDocument.getDescriptions() // .values()) { // countKey(usageStatistics.descriptionCounts, mtv.getLanguageCode(), // 1); // } for (String languageKey : termedDocument.getAliases().keySet()) { int count = termedDocument.getAliases().get(languageKey).size(); entityStatistics.countAliases += count; // countKey(usageStatistics.aliasCounts, languageKey, count); } }
/** * Count the terms (labels, descriptions, aliases) of an item or property * document. * * @param usageStatistics * statistics object to store counters in * @param termedDocument * document to count the terms of */ protected void countTerms(UsageStatistics usageStatistics, TermedDocument termedDocument) { usageStatistics.countLabels += termedDocument.getLabels().size(); for (MonolingualTextValue mtv : termedDocument.getLabels().values()) { countKey(usageStatistics.labelCounts, mtv.getLanguageCode(), 1); } usageStatistics.countDescriptions += termedDocument.getDescriptions() .size(); for (MonolingualTextValue mtv : termedDocument.getDescriptions() .values()) { countKey(usageStatistics.descriptionCounts, mtv.getLanguageCode(), 1); } for (String languageKey : termedDocument.getAliases().keySet()) { int count = termedDocument.getAliases().get(languageKey).size(); usageStatistics.countAliases += count; countKey(usageStatistics.aliasCounts, languageKey, count); } }
/** * Count the terms (labels, descriptions, aliases) of an item or property * document. * * @param usageStatistics * statistics object to store counters in * @param termedDocument * document to count the terms of */ protected void countTerms(UsageStatistics usageStatistics, TermedDocument termedDocument) { usageStatistics.countLabels += termedDocument.getLabels().size(); for (MonolingualTextValue mtv : termedDocument.getLabels().values()) { countKey(usageStatistics.labelCounts, mtv.getLanguageCode(), 1); } usageStatistics.countDescriptions += termedDocument.getDescriptions() .size(); for (MonolingualTextValue mtv : termedDocument.getDescriptions() .values()) { countKey(usageStatistics.descriptionCounts, mtv.getLanguageCode(), 1); } for (String languageKey : termedDocument.getAliases().keySet()) { int count = termedDocument.getAliases().get(languageKey).size(); usageStatistics.countAliases += count; countKey(usageStatistics.aliasCounts, languageKey, count); } }
void writeDocumentTerms(Resource subject, TermedDocument document) throws RDFHandlerException { if (hasTask(RdfSerializer.TASK_LABELS)) { writeTermTriples(subject, RdfWriter.RDFS_LABEL, document .getLabels().values()); } if (hasTask(RdfSerializer.TASK_DESCRIPTIONS)) { writeTermTriples(subject, RdfWriter.SCHEMA_DESCRIPTION, document .getDescriptions().values()); } if (hasTask(RdfSerializer.TASK_ALIASES)) { for (List<MonolingualTextValue> aliases : document.getAliases() .values()) { writeTermTriples(subject, RdfWriter.SKOS_ALT_LABEL, aliases); } } }
void writeDocumentTerms(Resource subject, TermedDocument document) throws RDFHandlerException { if (hasTask(RdfSerializer.TASK_LABELS)) { writeTermTriples(subject, RdfWriter.RDFS_LABEL, document .getLabels().values()); } if (hasTask(RdfSerializer.TASK_DESCRIPTIONS)) { writeTermTriples(subject, RdfWriter.SCHEMA_DESCRIPTION, document .getDescriptions().values()); } if (hasTask(RdfSerializer.TASK_ALIASES)) { for (List<MonolingualTextValue> aliases : document.getAliases() .values()) { writeTermTriples(subject, RdfWriter.SKOS_ALT_LABEL, aliases); } } }
MonolingualTextValue labelValue = termedDocument.getLabels() .get("en"); if (labelValue != null) {
MonolingualTextValue labelValue = termedDocument.getLabels() .get("en"); if (labelValue != null) {