本文整理汇总了Java中org.wikidata.wdtk.datamodel.interfaces.ItemDocument类的典型用法代码示例。如果您正苦于以下问题:Java ItemDocument类的具体用法?Java ItemDocument怎么用?Java ItemDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ItemDocument类属于org.wikidata.wdtk.datamodel.interfaces包,在下文中一共展示了ItemDocument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:17,代码来源:Revision.java
示例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);
}
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:19,代码来源:HasListLabel.java
示例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);
}
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:19,代码来源:LabelContainsMaleFirstName.java
示例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);
}
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:18,代码来源:IsHuman.java
示例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);
}
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:17,代码来源:NumberOfStatements.java
示例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);
}
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:23,代码来源:NumberOfQualifiers.java
示例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);
}
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:27,代码来源:IsLivingPerson.java
示例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);
}
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:17,代码来源:NumberOfReferences.java
示例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);
}
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:17,代码来源:NumberOfDescriptions.java
示例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);
}
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:19,代码来源:NumberOfAliases.java
示例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);
}
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:18,代码来源:NumberOfBadges.java
示例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);
}
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:19,代码来源:LabelCapitalizedWordRatio.java
示例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);
}
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:27,代码来源:CommentLabelSimilarity.java
示例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();
}
}
开发者ID:Wikidata,项目名称:Wikidata-Toolkit-Examples,代码行数:20,代码来源:EntityStatisticsProcessor.java
示例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;
}
}
开发者ID:Wikidata,项目名称:Wikidata-Toolkit-Examples,代码行数:24,代码来源:LifeExpectancyProcessor.java
示例16: countCoordinates
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
/**
* 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);
}
}
开发者ID:Wikidata,项目名称:Wikidata-Toolkit-Examples,代码行数:24,代码来源:WorldMapProcessor.java
示例17: includeDocument
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
/**
* 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.getStatements()) {
if (s.getClaim().getMainSnak() instanceof ValueSnak) {
Value v = ((ValueSnak) s.getClaim().getMainSnak())
.getValue();
// "Q1731" is "Dresden" on Wikidata
if (v instanceof ItemIdValue
&& "Q1731".equals(((ItemIdValue) v).getId())) {
return true;
}
}
}
}
return false;
}
开发者ID:Wikidata,项目名称:Wikidata-Toolkit-Examples,代码行数:29,代码来源:JsonSerializationProcessor.java
示例18: processGDMResourceNode
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
private ItemIdValue processGDMResourceNode(final ResourceNode resourceNode) {
final String resourceURI = resourceNode.getUri();
return gdmResourceURIWikidataItemMap.computeIfAbsent(resourceURI, resourceURI1 -> {
try {
final List<MonolingualTextValue> labels = generateLabels(resourceURI);
final List<MonolingualTextValue> descriptions = generateLabels(resourceURI);
final List<MonolingualTextValue> aliases = new ArrayList<>();
final List<StatementGroup> statementGroups = new ArrayList<>();
final Map<String, SiteLink> siteLinkMap = new HashMap<>();
// note: list of descriptions cannot be null
// note: list of aliases cannot be null
// note: list of statement groups cannot be null
final ItemDocument wikidataItem = Datamodel.makeItemDocument(null, labels, descriptions, aliases, statementGroups, siteLinkMap);
return createWikidataItem(resourceURI1, wikidataItem);
} catch (final WikidataImporterException e) {
throw WikidataImporterError.wrap(e);
}
});
}
开发者ID:dswarm,项目名称:wikidata-d-swarm-importer,代码行数:27,代码来源:WikidataDswarmImporter.java
示例19: testFindStatement
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
@Test
public void testFindStatement() {
Statement s1 = StatementBuilder.forSubjectAndProperty(Q1, P1)
.withValue(Q1).build();
Statement s2 = StatementBuilder.forSubjectAndProperty(Q1, P1)
.withValue(Q2).build();
Statement s3 = StatementBuilder.forSubjectAndProperty(Q1, P2)
.withValue(Q1).build();
ItemDocument id = ItemDocumentBuilder.forItemId(Q1).withStatement(s1)
.withStatement(s2).withStatement(s3).build();
assertTrue(id.hasStatement(P1));
assertTrue(id.hasStatement("P1"));
assertEquals(null, id.findStatement(P1));
assertEquals(null, id.findStatement("P1"));
assertTrue(id.hasStatement(P2));
assertTrue(id.hasStatement("P2"));
assertEquals(s3, id.findStatement(P2));
assertEquals(s3, id.findStatement("P2"));
assertFalse(id.hasStatement(P3));
assertFalse(id.hasStatement("P3"));
assertEquals(null, id.findStatement(P3));
assertEquals(null, id.findStatement("P3"));
}
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:25,代码来源:StatementDocumentTest.java
示例20: testFindStatementTimeValue
import org.wikidata.wdtk.datamodel.interfaces.ItemDocument; //导入依赖的package包/类
@Test
public void testFindStatementTimeValue() {
TimeValue v = Datamodel.makeTimeValue((byte) 2015, (byte) 10,
(byte) 16, (byte) 16, (byte) 51, (byte) 23,
TimeValue.PREC_SECOND, 0, 0, 0, TimeValue.CM_GREGORIAN_PRO);
Statement s = StatementBuilder.forSubjectAndProperty(q1, p1)
.withValue(v).build();
ItemDocument id = ItemDocumentBuilder.forItemId(q1).withStatement(s)
.build();
assertEquals(v, id.findStatementValue(p1));
assertEquals(v, id.findStatementValue("P1"));
assertEquals(v, id.findStatementTimeValue(p1));
assertEquals(v, id.findStatementTimeValue("P1"));
}
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:18,代码来源:StatementDocumentAccessTest.java
注:本文中的org.wikidata.wdtk.datamodel.interfaces.ItemDocument类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论