本文整理汇总了Java中org.wikidata.wdtk.datamodel.interfaces.ItemDocument类的典型用法代码示例。如果您正苦于以下问题:Java ItemDocument类的具体用法?Java ItemDocument怎么用?Java ItemDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ItemDocument类属于org.wikidata.wdtk.datamodel.interfaces包,在下文中一共展示了ItemDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setLatestItemDocument
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
public void setLatestItemDocument(ItemDocument latestItemDocument) {
// Depending on the exact type of ItemDocument, a deep copy might be
// necessary here. JacksonItemDocument is not thread-safe (the various
// ArrayList iterators within ItemDocument throw
// ConcurrentModificationException otherwise.) However,
// ItemDocumentImpl which is currently used seems to be thread-safe.
// DatamodelConverter converter = new DatamodelConverter(new DataObjectFactoryImpl());
// this.latestItemDocument = converter.copy(latestItemDocument);
// Temporary solution to fix ConcurrentModificationException
// this.latestItemDocument = null;
this.latestItemDocument = latestItemDocument;
}
示例2: calculate
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
@Override
public FeatureBooleanValue calculate(Revision revision) {
Boolean result = null;
ItemDocument itemDocument = revision.getItemDocument();
if (itemDocument != null) {
ItemDocumentDbItem item = new ItemDocumentDbItem(itemDocument);
String label = item.getLabel();
if (label != null) {
result = matcher.reset(label).matches();
}
}
return new FeatureBooleanValue(result);
}
示例3: calculate
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
@Override
public FeatureBooleanValue calculate(Revision revision) {
Boolean result = null;
ItemDocument itemDocument = revision.getItemDocument();
if (itemDocument != null) {
ItemDocumentDbItem item = new ItemDocumentDbItem(itemDocument);
String label = item.getLabel();
if (label != null) {
result = matcher.reset(label).matches();
}
}
return new FeatureBooleanValue(result);
}
示例4: calculate
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
@Override
public FeatureBooleanValue calculate(Revision revision) {
Boolean result = null;
ItemDocument itemDocument = revision.getItemDocument();
if (itemDocument != null) {
ItemDocumentDbItem item = new ItemDocumentDbItem(itemDocument);
Set<Integer> ids = item.getAllInstanceOfIds();
if (!ids.isEmpty()) {
result = ids.contains(HUMAN_ITEM_ID);
}
}
return new FeatureBooleanValue(result);
}
示例5: calculate
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
@Override
public FeatureIntegerValue calculate(Revision revision) {
int result = 0;
ItemDocument itemDocument = revision.getItemDocument();
if (itemDocument != null) {
Iterator<Statement> statements = itemDocument.getAllStatements();
while (statements.hasNext()) {
statements.next();
result += 1;
}
}
return new FeatureIntegerValue(result);
}
示例6: calculate
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
@Override
public FeatureIntegerValue calculate(Revision revision) {
int result = 0;
ItemDocument itemDocument = revision.getItemDocument();
if (itemDocument != null) {
Iterator<Statement> statements = itemDocument.getAllStatements();
while (statements.hasNext()) {
Statement statement = statements.next();
Iterator<Snak> qualifiers =
statement.getClaim().getAllQualifiers();
while (qualifiers.hasNext()) {
qualifiers.next();
result += 1;
}
}
}
return new FeatureIntegerValue(result);
}
示例7: calculate
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
@Override
public FeatureBooleanValue calculate(Revision revision) {
ItemDocument itemDocument = revision.getItemDocument();
boolean hasDateOfBirth = false;
boolean hasDateOfDeath = false;
if (itemDocument != null) {
List<StatementGroup> statementGroups =
itemDocument.getStatementGroups();
for (StatementGroup statementGroup: statementGroups) {
String property = statementGroup.getProperty().getId();
if (property.equals("P569")) {
hasDateOfBirth = true;
}
if (property.equals("P570")) {
hasDateOfDeath = true;
}
}
}
boolean result = hasDateOfBirth && !hasDateOfDeath;
return new FeatureBooleanValue(result);
}
示例8: calculate
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
@Override
public FeatureIntegerValue calculate(Revision revision) {
int result = 0;
ItemDocument itemDocument = revision.getItemDocument();
if (itemDocument != null) {
Iterator<Statement> statements = itemDocument.getAllStatements();
while (statements.hasNext()) {
Statement statement = statements.next();
result += statement.getReferences().size();
}
}
return new FeatureIntegerValue(result);
}
示例9: calculate
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
@Override
public FeatureIntegerValue calculate(Revision revision) {
int result = 0;
ItemDocument itemDocument = revision.getItemDocument();
if (itemDocument != null) {
Map<String, MonolingualTextValue> descriptions =
itemDocument.getDescriptions();
if (descriptions != null) {
result = descriptions.size();
}
}
return new FeatureIntegerValue(result);
}
示例10: calculate
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
@Override
public FeatureIntegerValue calculate(Revision revision) {
int result = 0;
ItemDocument itemDocument = revision.getItemDocument();
if (itemDocument != null) {
Map<String, List<MonolingualTextValue>> aliases =
itemDocument.getAliases();
if (aliases != null) {
for (Map.Entry<String, List<MonolingualTextValue>> entry : aliases.entrySet()) {
result += entry.getValue().size();
}
}
}
return new FeatureIntegerValue(result);
}
示例11: calculate
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
@Override
public FeatureIntegerValue calculate(Revision revision) {
int result = 0;
ItemDocument itemDocument = revision.getItemDocument();
if (itemDocument != null) {
Map<String, SiteLink> sitelinks = itemDocument.getSiteLinks();
for (Map.Entry<String, SiteLink> entry: sitelinks.entrySet()) {
SiteLink siteLink = entry.getValue();
result += siteLink.getBadges().size();
}
}
return new FeatureIntegerValue(result);
}
示例12: calculate
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
@Override
public FeatureFloatValue calculate(Revision revision) {
Float result = null;
ItemDocument itemDocument = revision.getItemDocument();
if (itemDocument != null) {
ItemDocumentDbItem item = new ItemDocumentDbItem(itemDocument);
String label = item.getLabel();
if (label != null) {
result = Utils.wordRatio(label, pattern);
}
}
return new FeatureFloatValue(result);
}
示例13: calculate
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
@Override
public FeatureFloatValue calculate(Revision revision) {
Float result = null;
String suffixComment = revision.getParsedComment().getSuffixComment();
if (suffixComment != null) {
suffixComment = suffixComment.trim();
ItemDocument itemDocument = revision.getItemDocument();
if (itemDocument != null) {
ItemDocumentDbItem item = new ItemDocumentDbItem(itemDocument);
String label = item.getLabel();
if (label != null) {
label = label.trim();
result = (float) StringUtils.getJaroWinklerDistance(
suffixComment, label);
}
}
}
return new FeatureFloatValue(result);
}
示例14: processItemDocument
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
@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();
}
}
示例15: processItemDocument
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
@Override
public void processItemDocument(ItemDocument itemDocument) {
int birthYear = getYearIfAny(itemDocument, "P569");
int deathYear = getYearIfAny(itemDocument, "P570");
if (birthYear != Integer.MIN_VALUE && deathYear != Integer.MIN_VALUE
&& birthYear >= 1200) {
// Do some more sanity checks to filter strange values:
if (deathYear > birthYear && deathYear - birthYear < 130) {
lifeSpans[birthYear] += (deathYear - birthYear);
peopleCount[birthYear]++;
totalLifeSpan += (deathYear - birthYear);
totalPeopleCount++;
printedStatus = false;
}
}
// Print the status once in a while:
if (!printedStatus && totalPeopleCount % 10000 == 0) {
printStatus();
printedStatus = true;
}
}