Java SiteLink类代码示例(javasitelink类代码示例汇总)

本文整理汇总了Java中org.wikidata.wdtk.datamodel.interfaces.SiteLink的典型用法代码示例。如果您正苦于以下问题:Java SiteLink类的具体用法?Java SiteLink怎么用?Java SiteLink使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Java SiteLink类代码示例(javasitelink类代码示例汇总)

SiteLink类属于org.wikidata.wdtk.datamodel.interfaces包,在下文中一共展示了SiteLink类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: calculate

import org.wikidata.wdtk.datamodel.interfaces.SiteLink; //导入依赖的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

示例2: processItemDocument

import org.wikidata.wdtk.datamodel.interfaces.SiteLink; //导入依赖的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

示例3: processGDMResourceNode

import org.wikidata.wdtk.datamodel.interfaces.SiteLink; //导入依赖的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

示例4: testWriteSiteLinks

import org.wikidata.wdtk.datamodel.interfaces.SiteLink; //导入依赖的package包/类
@Test
public void testWriteSiteLinks() throws RDFHandlerException, IOException,
		RDFParseException {
	this.sites.setSiteInformation("enwiki", "wikipedia", "en", "mediawiki",
			"http://en.wikipedia.org/w/$1",
			"http://en.wikipedia.org/wiki/$1");
	this.sites.setSiteInformation("dewiki", "wikipedia", "de", "mediawiki",
			"http://de.wikipedia.org/w/$1",
			"http://de.wikipedia.org/wiki/$1");
	Map<String, SiteLink> siteLinks = objectFactory.createSiteLinks();
	this.rdfConverter.writeSiteLinks(this.resource, siteLinks);
	this.rdfWriter.finish();
	Model model = RdfTestHelpers.parseRdf(out.toString());
	assertEquals(model, RdfTestHelpers.parseRdf(RdfTestHelpers
			.getResourceFromFile("SiteLinks.rdf")));

} 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:18,代码来源:RdfConverterTest.java

示例5: processItemDocument

import org.wikidata.wdtk.datamodel.interfaces.SiteLink; //导入依赖的package包/类
@Override
public void processItemDocument(ItemDocument itemDocument) {
	// Record relevant labels:
	Integer itemId = getNumId(itemDocument.getItemId().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);
	}
} 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:17,代码来源:SchemaUsageAnalyzer.java

示例6: countSiteLink

import org.wikidata.wdtk.datamodel.interfaces.SiteLink; //导入依赖的package包/类
private void countSiteLink(SiteLink siteLink) {
	if (!this.siteRecords.containsKey(siteLink.getSiteKey())) {
		String key = siteLink.getSiteKey();
		String url = this.sites.getPageUrl(key, "$Placeholder12345");
		if (url == null) {
			System.err
					.println("Could not find site information for " + key);
		} else {
			url = url.replace("%24Placeholder12345", "$1");
		}
		this.siteRecords.put(key,
				new SiteRecord(this.sites.getLanguageCode(key), url,
						this.sites.getGroup(key)));
	}
	this.siteRecords.get(siteLink.getSiteKey()).itemCount++;
} 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:17,代码来源:SchemaUsageAnalyzer.java

示例7: copySiteLinks

import org.wikidata.wdtk.datamodel.interfaces.SiteLink; //导入依赖的package包/类
/**
 * Copies a map of {@link SiteLink} objects as part of a shallow copy.
 *
 * @param siteLinks
 *            object to copy
 * @return the copied object
 */
private Map<String, SiteLink> copySiteLinks(Map<String, SiteLink> siteLinks) {
	if (this.filter.getSiteLinkFilter() == null) {
		return siteLinks;
	} else if (this.filter.getSiteLinkFilter().isEmpty()) {
		return Collections.emptyMap();
	}

	Map<String, SiteLink> result = new HashMap<>(siteLinks.size());
	for (Entry<String, SiteLink> entry : siteLinks.entrySet()) {
		if (this.filter.getSiteLinkFilter().contains(entry.getKey())) {
			result.put(entry.getKey(), entry.getValue());
		}
	}
	return result;
} 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:23,代码来源:DatamodelConverter.java

示例8: equalsSiteLink

import org.wikidata.wdtk.datamodel.interfaces.SiteLink; //导入依赖的package包/类
/**
 * Returns true if the parameters are two {@link SiteLink} 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 equalsSiteLink(SiteLink o1, Object o2) {
	if (o2 == null) {
		return false;
	}
	if (o2 == o1) {
		return true;
	}
	if (!(o2 instanceof SiteLink)) {
		return false;
	}
	SiteLink other = (SiteLink) o2;
	return o1.getPageTitle().equals(other.getPageTitle())
			&& o1.getSiteKey().equals(other.getSiteKey())
			&& o1.getBadges().equals(other.getBadges());
} 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:27,代码来源:Equality.java

示例9: testComplexItemDocumentBuild

import org.wikidata.wdtk.datamodel.interfaces.SiteLink; //导入依赖的package包/类
@Test
public void testComplexItemDocumentBuild() {


	MonolingualTextValue mtv = Datamodel.makeMonolingualTextValue("Test",
			"de");
	SiteLink sl = Datamodel.makeSiteLink("Test", "frwiki",
			Collections.singletonList("Badge"));

	ItemDocument id1 = Datamodel.makeItemDocument(i,
			Collections.singletonList(mtv), Collections.singletonList(mtv),
			Collections.singletonList(mtv), Collections.singletonList(sg),
			Collections.singletonMap("frwiki", sl), 1234);

	ItemDocument id2 = ItemDocumentBuilder.forItemId(i)
			.withLabel("Test", "de").withDescription("Test", "de")
			.withAlias("Test", "de")
			.withSiteLink("Test", "frwiki", "Badge").withStatement(s1)
			.withStatement(s2).withRevisionId(1234).build();

	assertEquals(id1, id2);
} 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:23,代码来源:ItemDocumentBuilderTest.java

示例10: testGetItemDocument

import org.wikidata.wdtk.datamodel.interfaces.SiteLink; //导入依赖的package包/类
@Test
public final void testGetItemDocument() {
	ItemDocument o1 = Datamodel.makeItemDocument(
			factory.getItemIdValue("Q42", "foo"),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<StatementGroup> emptyList(),
			Collections.<String, SiteLink> emptyMap());
	ItemDocument o2 = factory.getItemDocument(
			factory.getItemIdValue("Q42", "foo"),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<StatementGroup> emptyList(),
			Collections.<String, SiteLink> emptyMap());
	assertEquals(o1, o2);
} 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:19,代码来源:DatamodelTest.java

示例11: testItemDocumentToJson

import org.wikidata.wdtk.datamodel.interfaces.SiteLink; //导入依赖的package包/类
@Test
public void testItemDocumentToJson() {
	ItemDocument id = Datamodel.makeItemDocument(
			Datamodel.makeWikidataItemIdValue(JsonTestData.TEST_ITEM_ID),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<MonolingualTextValue> emptyList(),
			Collections.<StatementGroup> emptyList(),
			Collections.<String, SiteLink> emptyMap());

	String result1 = JsonSerializer.getJsonString(id);
	String result2 = JsonSerializer.getJsonString(datamodelConverter
			.copy(id));

	JsonComparator.compareJsonStrings(JsonTestData.JSON_WRAPPED_ITEMID,
			result1);
	JsonComparator.compareJsonStrings(JsonTestData.JSON_WRAPPED_ITEMID,
			result2);
} 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:20,代码来源:JsonSerializerTest.java

示例12: equalityBasedOnContent

import org.wikidata.wdtk.datamodel.interfaces.SiteLink; //导入依赖的package包/类
@Test
public void equalityBasedOnContent() {
	SiteLink sDiffTitle = new SiteLinkImpl("Berlin", "enwiki",
			Collections.<String> emptyList());
	SiteLink sDiffSiteKey = new SiteLinkImpl("Dresden", "dewiki",
			Collections.<String> emptyList());
	SiteLink sDiffBadges = new SiteLinkImpl("Dresden", "enwiki",
			Collections.singletonList("some badge?"));

	assertEquals(s1, s1);
	assertEquals(s1, s2);
	assertThat(s1, not(equalTo(sDiffTitle)));
	assertThat(s1, not(equalTo(sDiffSiteKey)));
	assertThat(s1, not(equalTo(sDiffBadges)));
	assertThat(s1, not(equalTo(null)));
	assertFalse(s1.equals(this));
} 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:18,代码来源:SiteLinkImplTest.java

示例13: getTestSiteLinks

import org.wikidata.wdtk.datamodel.interfaces.SiteLink; //导入依赖的package包/类
public static Map<String, SiteLink> getTestSiteLinks(int size) {
	Map<String, SiteLink> result = new HashMap<>(size);
	List<String> someBadges = new ArrayList<>(2);
	someBadges.add("badge1");
	someBadges.add("badge2");
	for (int i = 0; i < size; i++) {
		if (i % 3 == 0) {
			result.put("site" + i, new SiteLinkImpl("Badged article" + i,
					"site" + i, someBadges));
		} else {
			result.put("site" + i, new SiteLinkImpl("Article" + i, "site"
					+ i, Collections.<String> emptyList()));
		}
	}
	return result;

} 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:18,代码来源:DataObjectFactoryImplTest.java

示例14: calculate

import org.wikidata.wdtk.datamodel.interfaces.SiteLink; //导入依赖的package包/类
@Override
public FeatureIntegerValue calculate(Revision revision) {
	int result = 0;
	ItemDocument itemDocument = revision.getItemDocument();
	
	if (itemDocument != null) {
		Map<String, SiteLink> sitelinks = itemDocument.getSiteLinks();
		
		if (sitelinks != null) {
			result = sitelinks.size();
		}
	}

	return new FeatureIntegerValue(result);
} 
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:16,代码来源:NumberOfSitelinks.java

示例15: getEnglishSitelink

import org.wikidata.wdtk.datamodel.interfaces.SiteLink; //导入依赖的package包/类
private static String getEnglishSitelink(ItemDocument itemDocument) {
	String result = null;
	
	if (itemDocument != null) {
		Map<String, SiteLink> map = itemDocument.getSiteLinks();
		
		SiteLink sitelink = map.get("enwiki");
		
		if (sitelink != null) {
			result = sitelink.getPageTitle();
		}
	}
		
	return result;		
} 
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:16,代码来源:CommentSitelinkSimilarity.java

本文标签属性:

示例:示例英文

代码:代码编程

java:java模拟器

SiteLink:斯特林卡丹

上一篇:刘浩龙个人资料简历 刘浩龙简介(刘浩龙既生平)
下一篇:C++ R_FindSymbol函数代码示例(c++findsymbol函数代码示例汇总)

为您推荐