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


Java Statement.getSubject方法代码示例

本文整理汇总了Java中org.apache.jena.rdf.model.Statement.getSubject方法的典型用法代码示例。如果您正苦于以下问题:Java Statement.getSubject方法的具体用法?Java Statement.getSubject怎么用?Java Statement.getSubject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jena.rdf.model.Statement的用法示例。


在下文中一共展示了Statement.getSubject方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeOrphans

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
void removeOrphans(OntModel ont, Resource type) {
	boolean b = true;
	// removing orphans may create orphans
	while (b) {
		b = false;
		// orphaned classes
		for (ResIterator classes = ont.listSubjectsWithProperty(RDF.type,type); classes.hasNext(); ) {
			Resource c = classes.nextResource();
			if (c.isAnon()) {
				// an orphan is anonymous and has no referee other than itself
				Resource r = null;
				Statement s = null;
				for (StmtIterator si = ont.listStatements(null,null,c); si.hasNext(); ) {
					s = si.nextStatement();
					r = s.getSubject();
					if (!r.equals(c)) break;
				}					
				if (r==null || r.equals(c)) {
					b = true;
					c.removeProperties();
				}
			}
		}
	}
}
 
开发者ID:stevebattle,项目名称:Gloze,代码行数:26,代码来源:schema.java

示例2: createIndividual

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
private Model createIndividual(VirtualEntity virtualEntity) {
        // some definitions
        String personURI = "http://somewhere/JohnSmith";
        String givenName = "John";
        String familyName = "Smith";
        String fullName = givenName + " " + familyName;

// create an empty Model
        Model model = ModelFactory.createDefaultModel();

// create the resource
//   and add the properties cascading style
        Resource johnSmith
                = model.createResource(personURI)
                        .addProperty(VCARD.FN, fullName)
                        .addProperty(VCARD.N,
                                model.createResource()
                                        .addProperty(VCARD.Given, givenName)
                                        .addProperty(VCARD.Family, familyName));

        // list the statements in the Model
        StmtIterator iter = model.listStatements();

// print out the predicate, subject and object of each statement
        while (iter.hasNext()) {
            Statement stmt = iter.nextStatement();  // get next statement
            Resource subject = stmt.getSubject();     // get the subject
            Property predicate = stmt.getPredicate();   // get the predicate
            RDFNode object = stmt.getObject();      // get the object

            System.out.print(subject.toString());
            System.out.print(" " + predicate.toString() + " ");
            if (object instanceof Resource) {
                System.out.print(object.toString());
            } else {
                // object is a literal
                System.out.print(" \"" + object.toString() + "\"");
            }

            System.out.println(" .");
        }

        return model;
    }
 
开发者ID:nailtonvieira,项目名称:cloudsemanticwot,代码行数:45,代码来源:DataConnectorImpl.java

示例3: list

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
public Collection<Organisation> list(){
	Collection<Organisation> organisationList = new ArrayList<Organisation>();

	StmtIterator stmtIterator = model.listStatements(null, RDF.type, FOAF.Organization);
	while(stmtIterator.hasNext()){
		Statement stmt = stmtIterator.next();
		Resource organisationResource = stmt.getSubject();
		Organisation organisation = new Organisation(organisationResource);
		organisationList.add(organisation);
	}
	return organisationList;
}
 
开发者ID:AnLiGentile,项目名称:cLODg,代码行数:13,代码来源:Organisations.java

示例4: list

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
public Collection<Person> list(){
	Collection<Person> personList = new ArrayList<Person>();

	StmtIterator stmtIterator = model.listStatements(null, RDF.type, FOAF.Person);
	while(stmtIterator.hasNext()){
		Statement stmt = stmtIterator.next();
		Resource personResource = stmt.getSubject();
		Person person = new Person(personResource);
		personList.add(person);
	}
	return personList;
}
 
开发者ID:AnLiGentile,项目名称:cLODg,代码行数:13,代码来源:People.java

示例5: list

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
public Collection<InProceedings> list(){
	Collection<InProceedings> inProceedingsList = new ArrayList<InProceedings>();

	StmtIterator stmtIterator = model.listStatements(null, RDF.type, ModelFactory.createDefaultModel().createResource("http://swrc.ontoware.org/ontology#InProceedings"));
	while(stmtIterator.hasNext()){
		Statement stmt = stmtIterator.next();
		Resource inProceedingsResource = stmt.getSubject();
		InProceedings inProceedings = new InProceedings(inProceedingsResource);
		inProceedingsList.add(inProceedings);
	}
	return inProceedingsList;
}
 
开发者ID:AnLiGentile,项目名称:cLODg,代码行数:13,代码来源:InProceedingsSet.java

示例6: getEdgeSource

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
@Override
public RDFNode getEdgeSource(Statement e) {
    return e.getSubject();
}
 
开发者ID:SmartDataAnalytics,项目名称:SubgraphIsomorphismIndex,代码行数:5,代码来源:PseudoGraphJenaModel.java

示例7: processModel

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
public ColouredGraph processModel(Model model) {
    ColourPalette vertexPalette = createVertexPalette(model);
    ColourPalette edgePalette = createEdgePalette(model);
    ColouredGraph graph = new ColouredGraph(vertexPalette, edgePalette);
    ObjectIntOpenHashMap<Resource> resourceIdMapping = new ObjectIntOpenHashMap<Resource>();
    StmtIterator iterator = model.listStatements();
    Statement statement;
    Resource subject, object;
    Property property;
    int subjectId, propertyId, objectId;
    String propertyUri;
    // Iterator over all statements
    while (iterator.hasNext()) {
        statement = iterator.next();
        subject = statement.getSubject();
        // Add the subject if it is not existing
        if (resourceIdMapping.containsKey(subject)) {
            subjectId = resourceIdMapping.get(subject);
        } else {
            subjectId = graph.addVertex();
            resourceIdMapping.put(subject, subjectId);
        }
        // if this statement has a resource as object
        if (statement.getObject().isResource()) {
            // Add the object if it is not existing
            object = statement.getObject().asResource();
            if (resourceIdMapping.containsKey(object)) {
                objectId = resourceIdMapping.get(object);
            } else {
                objectId = graph.addVertex();
                resourceIdMapping.put(object, objectId);
            }
            // Add the property if it is not existing
            property = statement.getPredicate();
            propertyId = graph.addEdge(subjectId, objectId);
            // Set the colour of the edge
            propertyUri = property.getURI();
            if (!edgePalette.containsUri(propertyUri)) {
                edgePalette.addColour(propertyUri);
            }
            graph.setEdgeColour(propertyId, edgePalette.getColour(propertyUri));

            // if this triple defines the class of the subject
            if (property.equals(RDF.type)) {
                graph.setVertexColour(subjectId,
                        vertexPalette.addToColour(graph.getVertexColour(subjectId), object.getURI()));
            }
        }
    }
    return graph;
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:52,代码来源:GraphCreator.java

示例8: createEdgePalette

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
protected ColourPalette createEdgePalette(Model model) {
    RDFNode node;
    Resource resource1, resource2;
    StmtIterator sIterator = model.listStatements(null, RDFS.subPropertyOf, (RDFNode) null);
    Statement statement;
    HierarchyNode hNode1, hNode2;
    // Iterate over the class hierarchy triples
    while (sIterator.hasNext()) {
        statement = sIterator.next();
        resource1 = statement.getSubject();
        node = statement.getObject();
        if (node.isResource()) {
            resource2 = node.asResource();
            if (properties.containsKey(resource1)) {
                hNode1 = properties.get(resource1);
            } else {
                // this property is not known, add it
                hNode1 = new HierarchyNode();
                properties.put(resource1, hNode1);
            }
            if (properties.containsKey(resource2)) {
                hNode2 = properties.get(resource2);
            } else {
                // this property is not known, add it
                hNode2 = new HierarchyNode();
                properties.put(resource2, hNode2);
            }
            // add the hierarchy information
            // if there is no list of child nodes
            if (hNode1.childNodes == null) {
                hNode1.childNodes = new Resource[] { resource2 };
            } else {
                hNode1.childNodes = Arrays.copyOf(hNode1.childNodes, hNode1.childNodes.length + 1);
                hNode1.childNodes[hNode1.childNodes.length - 1] = resource2;
            }
            // if there is no list of parent nodes
            if (hNode2.parentNodes == null) {
                hNode2.parentNodes = new Resource[] { resource1 };
            } else {
                hNode2.parentNodes = Arrays.copyOf(hNode2.parentNodes, hNode2.parentNodes.length + 1);
                hNode2.parentNodes[hNode2.parentNodes.length - 1] = resource1;
            }
        }
    }

    // All properties have been collected
    // The colours can be defined
    for (int i = 0; i < properties.allocated.length; ++i) {
        if (properties.allocated[i]) {
            edgePalette.addColour(((Resource) ((Object[]) properties.keys)[i]).getURI());
        }
    }

    // The hierarchy can be used to create colour mixtures that contain the
    // hierarchy
    // Search for all root nodes that have child nodes
    for (int i = 0; i < properties.allocated.length; ++i) {
        if (properties.allocated[i]) {
            hNode1 = (HierarchyNode) ((Object[]) properties.values)[i];
            if ((hNode1.childNodes != null) && (hNode1.parentNodes == null)) {
                mixColours((Resource) ((Object[]) properties.keys)[i], hNode1, properties, edgePalette);
            }
        }
    }

    return edgePalette;
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:68,代码来源:GraphCreator.java

示例9: main

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
public static void main(String[] args) {
	Model model = FileManager.get().loadModel("out/eswc_data_final.rdf");

	StmtIterator stmtIterator = model.listStatements(null,
			model.createProperty("http://dpedia.org/ontology/thumbnail"),
			(RDFNode) null);

	Model modelTmp = ModelFactory.createDefaultModel();

	while (stmtIterator.hasNext()) {
		Statement stmt = stmtIterator.next();

		Resource subject = stmt.getSubject();
		Property predicate = stmt.getPredicate();
		RDFNode object = stmt.getObject();

		String paperId = subject.getURI().substring(
				subject.getURI().lastIndexOf("/") + 1);
		String name = object.toString().replace(
				"http://wit.istc.cnr.it/eswc-stc/images/papers/resized/",
				"");
		String track = name.substring(0, name.lastIndexOf("/"));

		File file;
		if (!name.endsWith(".jpg"))
			file = new File("img/papers/" + name + ".jpg");
		else
			file = new File("img/papers/" + name);

		file.renameTo(new File("img/papers/" + track + "/" + paperId
				+ ".jpg"));

		Resource newImg = modelTmp
				.createResource("http://wit.istc.cnr.it/eswc-stc/images/papers/resized/"
						+ track + "/" + paperId + ".jpg");
		model.add(subject, predicate, newImg);

	}

	model.removeAll(null,
			model.createProperty("http://dpedia.org/ontology/thumbnail"),
			(RDFNode) null);
	model.add(modelTmp);
}
 
开发者ID:AnLiGentile,项目名称:cLODg,代码行数:45,代码来源:ImageAligner.java


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