当前位置: 首页>>代码示例>>Java>>正文


Java ItemDocument类代码示例

本文整理汇总了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;	
}
 
开发者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


注:本文中的org.wikidata.wdtk.datamodel.interfaces.ItemDocument类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。