當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。