本文整理汇总了Java中org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue类的典型用法代码示例。如果您正苦于以下问题:Java PropertyIdValue类的具体用法?Java PropertyIdValue怎么用?Java PropertyIdValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyIdValue类属于org.wikidata.wdtk.datamodel.interfaces包,在下文中一共展示了PropertyIdValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writePropertyStatisticsToFile
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue; //导入依赖的package包/类
/**
* Stores the gathered usage statistics about property uses to a CSV file.
*
* @param usageStatistics
* the statistics to store
* @param fileName
* the name of the file to use
*/
private void writePropertyStatisticsToFile(UsageStatistics usageStatistics,
String fileName) {
try (PrintStream out = new PrintStream(
ExampleHelpers.openExampleFileOuputStream(fileName))) {
out.println("Property id,in statements,in qualifiers,in references,total");
for (Entry<PropertyIdValue, Integer> entry : usageStatistics.propertyCountsMain
.entrySet()) {
int qCount = usageStatistics.propertyCountsQualifier.get(entry
.getKey());
int rCount = usageStatistics.propertyCountsReferences.get(entry
.getKey());
int total = entry.getValue() + qCount + rCount;
out.println(entry.getKey().getId() + "," + entry.getValue()
+ "," + qCount + "," + rCount + "," + total);
}
} catch (IOException e) {
e.printStackTrace();
}
}
示例2: writePropertyData
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue; //导入依赖的package包/类
/**
* Writes the data collected about properties to a file.
*/
private void writePropertyData() {
try (PrintStream out = new PrintStream(
ExampleHelpers.openExampleFileOuputStream("properties.csv"))) {
out.println("Id" + ",Label" + ",Description" + ",URL" + ",Datatype"
+ ",Uses in statements" + ",Items with such statements"
+ ",Uses in statements with qualifiers"
+ ",Uses in qualifiers" + ",Uses in references"
+ ",Uses total" + ",Related properties");
List<Entry<PropertyIdValue, PropertyRecord>> list = new ArrayList<Entry<PropertyIdValue, PropertyRecord>>(
this.propertyRecords.entrySet());
Collections.sort(list, new UsageRecordComparator());
for (Entry<PropertyIdValue, PropertyRecord> entry : list) {
printPropertyRecord(out, entry.getValue(), entry.getKey());
}
} catch (IOException e) {
e.printStackTrace();
}
}
示例3: StatementGroupImpl
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue; //导入依赖的package包/类
/**
* Constructor.
*
* @param statements
* a non-empty list of statements that use the same subject and
* main-snak property in their claim
*/
public StatementGroupImpl(List<Statement> statements) {
Validate.notNull(statements, "List of statements cannot be null");
Validate.notEmpty(statements, "List of statements cannot be empty");
EntityIdValue subject = statements.get(0).getClaim().getSubject();
PropertyIdValue property = statements.get(0).getClaim().getMainSnak()
.getPropertyId();
for (Statement s : statements) {
if (!subject.equals(s.getClaim().getSubject())) {
throw new IllegalArgumentException(
"All statements in a statement group must use the same subject");
}
if (!property.equals(s.getClaim().getMainSnak().getPropertyId())) {
throw new IllegalArgumentException(
"All statements in a statement group must use the same main property");
}
}
this.statements = statements;
}
示例4: equalityBasedOnContent
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue; //导入依赖的package包/类
@Test
public void equalityBasedOnContent() {
Claim cDiffSubject, cDiffMainSnak, cDiffQualifiers;
EntityIdValue subject2 = new ItemIdValueImpl("Q43",
"http://wikidata.org/entity/");
PropertyIdValue property = new PropertyIdValueImpl(
"P43", "http://wikidata.org/entity/");
ValueSnak mainSnak2 = new ValueSnakImpl(property, subject2);
cDiffSubject = new ClaimImpl(subject2, mainSnak,
Collections.<SnakGroup> emptyList());
cDiffMainSnak = new ClaimImpl(subject, mainSnak2,
Collections.<SnakGroup> emptyList());
cDiffQualifiers = new ClaimImpl(subject, mainSnak,
Collections.<SnakGroup> singletonList(new SnakGroupImpl(
Collections.<Snak> singletonList(mainSnak))));
assertEquals(c1, c1);
assertEquals(c1, c2);
assertThat(c1, not(equalTo(cDiffSubject)));
assertThat(c1, not(equalTo(cDiffMainSnak)));
assertThat(c1, not(equalTo(cDiffQualifiers)));
assertThat(c1, not(equalTo(null)));
assertFalse(c1.equals(this));
}
示例5: getRdfValue
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue; //导入依赖的package包/类
@Override
public Value getRdfValue(EntityIdValue value,
PropertyIdValue propertyIdValue, boolean simple) {
String datatype = this.propertyRegister
.setPropertyTypeFromEntityIdValue(propertyIdValue, value);
switch (datatype) {
case DatatypeIdValue.DT_ITEM:
if (simple) {
this.rdfConversionBuffer.addObjectProperty(propertyIdValue);
return this.rdfWriter.getUri(value.getIri());
} else {
return null; // or blank node
}
case DatatypeIdValue.DT_PROPERTY:
if (simple) {
this.rdfConversionBuffer.addObjectProperty(propertyIdValue);
return this.rdfWriter.getUri(value.getIri());
} else {
return null; // or blank node
}
default:
logIncompatibleValueError(propertyIdValue, datatype, "entity");
return null;
}
}
示例6: getRdfValue
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue; //导入依赖的package包/类
@Override
public Value getRdfValue(GlobeCoordinatesValue value,
PropertyIdValue propertyIdValue, boolean simple) {
String datatype = this.propertyRegister
.setPropertyTypeFromGlobeCoordinatesValue(propertyIdValue,
value);
switch (datatype) {
case DatatypeIdValue.DT_GLOBE_COORDINATES:
if (simple) {
return getSimpleGeoValue(value);
} else {
URI valueUri = this.rdfWriter.getUri(Vocabulary
.getGlobeCoordinatesValueUri(value,
this.propertyRegister.getUriPrefix()));
this.rdfConversionBuffer.addObjectProperty(propertyIdValue);
addValue(value, valueUri);
return valueUri;
}
default:
logIncompatibleValueError(propertyIdValue, datatype,
"globe coordinates");
return null;
}
}
示例7: testUriPatternStatement
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue; //导入依赖的package包/类
@Test
public void testUriPatternStatement() throws RDFHandlerException,
RDFParseException, IOException {
ItemIdValue subject = Datamodel.makeItemIdValue("Q100",
Datamodel.SITE_WIKIDATA);
PropertyIdValue propertyId = Datamodel
.makeWikidataPropertyIdValue("P434");
StringValue value = Datamodel
.makeStringValue("d735497b-25f9-4503-8fb5-f50150730c18");
Snak mainSnak = Datamodel.makeValueSnak(propertyId, value);
Claim claim = Datamodel.makeClaim(subject, mainSnak,
Collections.<SnakGroup> emptyList());
Statement statement = Datamodel.makeStatement(claim,
Collections.<Reference> emptyList(), StatementRank.NORMAL,
"stmtid");
this.rdfConverter.writeStatement(statement);
this.rdfWriter.finish();
Model model = RdfTestHelpers.parseRdf(this.out.toString());
assertEquals(model, RdfTestHelpers.parseRdf(RdfTestHelpers
.getResourceFromFile("StatementMusicBrainz.rdf")));
}
示例8: testFreebaseStatement
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue; //导入依赖的package包/类
@Test
public void testFreebaseStatement() throws RDFHandlerException,
RDFParseException, IOException {
ItemIdValue subject = Datamodel.makeItemIdValue("Q100",
Datamodel.SITE_WIKIDATA);
PropertyIdValue propertyId = Datamodel
.makeWikidataPropertyIdValue("P646");
StringValue value = Datamodel.makeStringValue("/m/0j9kvph");
Snak mainSnak = Datamodel.makeValueSnak(propertyId, value);
Claim claim = Datamodel.makeClaim(subject, mainSnak,
Collections.<SnakGroup> emptyList());
Statement statement = Datamodel.makeStatement(claim,
Collections.<Reference> emptyList(), StatementRank.NORMAL,
"stmtid");
this.rdfConverter.writeStatement(statement);
this.rdfWriter.finish();
Model model = RdfTestHelpers.parseRdf(this.out.toString());
assertEquals(model, RdfTestHelpers.parseRdf(RdfTestHelpers
.getResourceFromFile("StatementFreebase.rdf")));
}
示例9: testSimplePropertyDocumentBuild
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue; //导入依赖的package包/类
@Test
public void testSimplePropertyDocumentBuild() {
MonolingualTextValue mtv = Datamodel.makeMonolingualTextValue("Test",
"de");
PropertyDocument pd1 = Datamodel.makePropertyDocument(
PropertyIdValue.NULL, Collections.singletonList(mtv),
Collections.<MonolingualTextValue> emptyList(),
Collections.<MonolingualTextValue> emptyList(),
Collections.<StatementGroup> emptyList(),
Datamodel.makeDatatypeIdValue(DatatypeIdValue.DT_ITEM));
PropertyDocument pd2 = PropertyDocumentBuilder
.forPropertyIdAndDatatype(PropertyIdValue.NULL,
DatatypeIdValue.DT_ITEM).withLabel(mtv).build();
assertEquals(pd1, pd2);
}
示例10: testWriteUnboundedQuantityValue
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue; //导入依赖的package包/类
@Test
public void testWriteUnboundedQuantityValue() throws RDFHandlerException,
RDFParseException, IOException {
QuantityValueConverter valueConverter = new QuantityValueConverter(
this.rdfWriter, this.propertyRegister, this.rdfConversionBuffer);
QuantityValue value = this.objectFactory.getQuantityValue(new BigDecimal(100));
PropertyIdValue propertyIdValue = objectFactory.getPropertyIdValue(
"P1081", "http://www.wikidata.org/entity/");
Value valueURI = valueConverter.getRdfValue(value, propertyIdValue,
false);
valueConverter.writeValue(value, (Resource) valueURI);
this.rdfWriter.finish();
Model model = RdfTestHelpers.parseRdf(this.out.toString());
assertEquals(model, RdfTestHelpers.parseRdf(RdfTestHelpers
.getResourceFromFile("UnboundedQuantityValue.rdf")));
}
示例11: testWriteGlobeCoordinatesValue
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue; //导入依赖的package包/类
@Test
public void testWriteGlobeCoordinatesValue() throws RDFHandlerException,
RDFParseException, IOException {
GlobeCoordinatesValueConverter valueConverter = new GlobeCoordinatesValueConverter(
this.rdfWriter, this.propertyRegister, this.rdfConversionBuffer);
GlobeCoordinatesValue value = this.objectFactory
.getGlobeCoordinatesValue(51.033333333333, 13.733333333333,
(GlobeCoordinatesValue.PREC_DECI_DEGREE),
"http://www.wikidata.org/entity/Q2");
PropertyIdValue propertyIdValue = objectFactory.getPropertyIdValue(
"P625", "http://www.wikidata.org/entity/");
Value valueURI = valueConverter.getRdfValue(value, propertyIdValue,
false);
valueConverter.writeValue(value, (Resource) valueURI);
this.rdfWriter.finish();
Model model = RdfTestHelpers.parseRdf(this.out.toString());
assertEquals(model, RdfTestHelpers.parseRdf(RdfTestHelpers
.getResourceFromFile("GlobeCoordinatesValue.rdf")));
}
示例12: testWriteTimeValue
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue; //导入依赖的package包/类
@Test
public void testWriteTimeValue() throws RDFHandlerException,
RDFParseException, IOException {
TimeValueConverter valueConverter = new TimeValueConverter(
this.rdfWriter, this.propertyRegister, this.rdfConversionBuffer);
TimeValue value = objectFactory.getTimeValue(2008, (byte) 1, (byte) 1,
(byte) 0, (byte) 0, (byte) 0, (byte) 9, 0, 0, 0,
"http://www.wikidata.org/entity/Q1985727");
PropertyIdValue propertyIdValue = objectFactory.getPropertyIdValue(
"P569", "http://www.wikidata.org/entity/");
Value valueURI = valueConverter.getRdfValue(value, propertyIdValue,
false);
valueConverter.writeValue(value, (Resource) valueURI);
this.rdfWriter.finish();
Model model = RdfTestHelpers.parseRdf(this.out.toString());
assertEquals(model, RdfTestHelpers.parseRdf(RdfTestHelpers
.getResourceFromFile("TimeValue.rdf")));
}
示例13: statementListRequiresSameProperty
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void statementListRequiresSameProperty() {
List<Statement> statements = new ArrayList<Statement>();
statements.add(statement1);
PropertyIdValue property2 = new PropertyIdValueImpl("P23", "http://wikidata.org/entity/");
Snak mainSnak = new NoValueSnakImpl(property2);
Claim claim = new ClaimImpl(subject, mainSnak,
Collections.<SnakGroup> emptyList());
Statement s2 = new StatementImpl(claim,
Collections.<Reference> emptyList(), StatementRank.NORMAL,
"MyId");
statements.add(s2);
new StatementGroupImpl(statements);
}
示例14: countCooccurringProperties
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue; //导入依赖的package包/类
/**
* Counts each property for which there is a statement in the given item
* document, ignoring the property thisPropertyIdValue to avoid properties
* counting themselves.
*
* @param statementDocument
* @param usageRecord
* @param thisPropertyIdValue
*/
private void countCooccurringProperties(
StatementDocument statementDocument, UsageRecord usageRecord,
PropertyIdValue thisPropertyIdValue) {
for (StatementGroup sg : statementDocument.getStatementGroups()) {
if (!sg.getProperty().equals(thisPropertyIdValue)) {
Integer propertyId = getNumId(sg.getProperty().getId(), false);
if (!usageRecord.propertyCoCounts.containsKey(propertyId)) {
usageRecord.propertyCoCounts.put(propertyId, 1);
} else {
usageRecord.propertyCoCounts.put(propertyId,
usageRecord.propertyCoCounts.get(propertyId) + 1);
}
}
}
}
示例15: testQualifierList
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue; //导入依赖的package包/类
@Test
public void testQualifierList() {
ItemIdValue i = ItemIdValue.NULL;
PropertyIdValue p = PropertyIdValue.NULL;
Snak q1 = Datamodel.makeSomeValueSnak(p);
Snak q2 = Datamodel.makeNoValueSnak(p);
Snak q3 = Datamodel.makeValueSnak(p, i);
SnakGroup sg = Datamodel.makeSnakGroup(Arrays.asList(q1, q2, q3));
Reference r = Datamodel.makeReference(Collections.singletonList(sg));
Statement stmt1 = Datamodel.makeStatement(Datamodel.makeClaim(i,
Datamodel.makeValueSnak(p, i), Collections.singletonList(sg)),
Collections.singletonList(r), StatementRank.PREFERRED, "id");
Statement stmt2 = StatementBuilder.forSubjectAndProperty(i, p)
.withRank(StatementRank.PREFERRED).withValue(i)
.withQualifiers(stmt1.getClaim().getQualifiers()).withId("id")
.withReference(r).build();
assertEquals(stmt1, stmt2);
}