本文整理汇总了Java中com.hp.hpl.jena.rdf.model.StmtIterator.next方法的典型用法代码示例。如果您正苦于以下问题:Java StmtIterator.next方法的具体用法?Java StmtIterator.next怎么用?Java StmtIterator.next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.rdf.model.StmtIterator
的用法示例。
在下文中一共展示了StmtIterator.next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeCategories
import com.hp.hpl.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
public Set<String> initializeCategories() {
Model model = ModelFactory.createDefaultModel();
model.read("/home/zwicklbauer/HDTGeneration/skos_categories_en.nt");
StmtIterator it = model.listStatements();
Set<String> set = new HashSet<String>();
System.out.println("Los gehts");
while (it.hasNext()) {
Statement s = it.next();
Resource r = s.getSubject();
Property p = s.getPredicate();
RDFNode n = s.getObject();
if (p.getURI().equalsIgnoreCase(
"http://www.w3.org/2004/02/skos/core#broader")
&& n.isResource()) {
Resource target = n.asResource();
if(!hasSubCategory(target.getURI()))
set.add(target.getURI());
if(!hasSubCategory(r.getURI()))
set.add(r.getURI());
}
}
return set;
}
示例2: getRDFNodes
import com.hp.hpl.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
public List<RDFNode> getRDFNodes(Resource r, Property p, NodeType acceptableNodes) {
List<RDFNode> result = new ArrayList<RDFNode>();
StmtIterator it = r.listProperties(p);
while (it.hasNext()) {
Statement stmt = it.next();
remainingTriples.remove(stmt);
if (acceptableNodes.isTypeOf(stmt.getObject())) {
result.add(stmt.getObject());
} else {
if (acceptableNodes.coerce(stmt.getObject()) != null) {
result.add(acceptableNodes.coerce(stmt.getObject()));
}
report.report(acceptableNodes.ifNot, r, p, stmt.getObject());
}
}
Collections.sort(result, RDFComparator.getRDFNodeComparator());
return result;
}
示例3: main
import com.hp.hpl.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
public static final void main(String[] args) throws MalformedURLException, FileNotFoundException {
Model model = ModelFactory.createDefaultModel();
model.read(args[0]);
StmtIterator iter = model.listStatements();
System.out.println("Start");
while (iter.hasNext()) {
Statement stmt = iter.next();
Resource subject = stmt.getSubject();
String url[] = subject.getURI().split("/");
String subjectIdent = url[url.length - 1];
RDFNode object = stmt.getObject();
String s[] = object.asResource().getURI().split("/");
String objIdent = s[s.length - 1];
try {
System.out.println(objIdent+" "+subjectIdent);
HBaseOperations.getInstance().addRecord("DBPEDIA_CatToEnts", objIdent, "data", String.valueOf(subjectIdent.hashCode()), subjectIdent);
} catch (IOException e) {
e.printStackTrace();
}
}
}
示例4: fetchLabels
import com.hp.hpl.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
private void fetchLabels(Model m)
{
Map<String,String> map = new HashMap();
Property p = m.getProperty(SKOS_PREF_LABEL);
ResIterator rIter = m.listResourcesWithProperty(m.getProperty(RDF_TYPE));
while ( rIter.hasNext() )
{
Resource r = rIter.next();
fetchAlternatives(map, r);
StmtIterator sIter = r.listProperties(p);
while ( sIter.hasNext() )
{
Statement stmt = sIter.next();
put(stmt.getSubject(), getKey(stmt.getString(), map));
}
map.clear();
}
}
示例5: sportsTeamsSurfaceForms
import com.hp.hpl.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
public void sportsTeamsSurfaceForms() {
Model m = ModelFactory.createDefaultModel();
m.read(INSTANCEMAPPINGTYPES_NT);
StmtIterator it = m.listStatements();
while (it.hasNext()) {
Statement s = it.next();
Resource subject = s.getSubject();
RDFNode object = s.getObject();
if (object.isResource()) {
Resource obj = object.asResource();
if (obj.getURI().equalsIgnoreCase("http://dbpedia.org/ontology/SportsTeam")) {
teams.add(subject.getURI());
}
}
}
}
示例6: main
import com.hp.hpl.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
public static void main(String[] args) {
Model m = ModelFactory.createDefaultModel();
m.read(args[0]);
StmtIterator iter = m.listStatements();
HashSet<String> hash = new HashSet<String>();
while (iter.hasNext()) {
Statement stmt = iter.next();
RDFNode node = stmt.getObject();
String uri = node.asResource().getURI();
hash.add(uri);
}
File output = new File(args[1]);
try {
PrintWriter writer = new PrintWriter(output);
for(String s : hash) {
writer.println(s);
}
writer.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
示例7: copyAllowedProperties
import com.hp.hpl.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
protected void copyAllowedProperties(Model readModel, Model model, Set<Resource> classes,
Set<Property> allowedProperties) {
StmtIterator stmtIterator = readModel.listStatements();
Statement s;
Literal label;
while (stmtIterator.hasNext()) {
s = stmtIterator.next();
if (classes.contains(s.getSubject()) && allowedProperties.contains(s.getPredicate())
&& (!s.getObject().isAnon())) {
if (s.getPredicate().equals(RDFS.label)) {
label = s.getObject().asLiteral();
if (label.getLanguage().equals("en")) {
model.add(s.getSubject(), RDFS.label,
model.createLiteral(label.getString().toLowerCase(), "en"));
}
} else {
model.add(s);
}
}
}
}
示例8: triplesInvolvingVocabulary
import com.hp.hpl.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
public Model triplesInvolvingVocabulary(Model model) {
Model result = ModelFactory.createDefaultModel();
result.getNsPrefixMap().putAll(model.getNsPrefixMap());
StmtIterator it = model.listStatements();
while (it.hasNext()) {
Statement stmt = it.next();
if (properties.contains(stmt.getPredicate())
|| (stmt.getPredicate().equals(RDF.type) && classes.contains(stmt.getObject()))) {
result.add(stmt);
}
}
return result;
}
示例9: checkForSpuriousTriples
import com.hp.hpl.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
private void checkForSpuriousTriples() {
StmtIterator it = remainingTriples.listStatements();
while (it.hasNext()) {
Statement stmt = it.next();
report.report(Problem.SPURIOUS_TRIPLE, stmt.getSubject(), stmt.getPredicate(), stmt.getObject());
}
}
示例10: testAsk
import com.hp.hpl.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
@Test
public void testAsk() {
StmtIterator it = expectedTriples.listStatements();
while (it.hasNext()) {
Statement stmt = it.next();
assertTrue("Missing statement: " + stmt, loader.getModelD2RQ().contains(stmt));
}
}
示例11: printIndividual
import com.hp.hpl.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
protected static String printIndividual(Individual individual) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Individual: " + individual.getLocalName() + "\n");
StmtIterator properties = individual.listProperties();
while (properties.hasNext()) {
Statement s = properties.next();
stringBuilder.append(" " + s.getPredicate().getLocalName() + " : " + s.getObject().toString() + "\n");
}
properties.close();
stringBuilder.append("\n");
stringBuilder.append(StringUtils.repeat("-", 70));
return stringBuilder.toString();
}
示例12: listRelatedStatements
import com.hp.hpl.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
private HashSet<Statement> listRelatedStatements(Resource r) {
HashSet<Statement> statements = new HashSet<Statement>();
StmtIterator st1 = model.listStatements(r, null, (RDFNode) null);
StmtIterator st3 = model.listStatements(null, null, r);
StmtIterator stmt = model.listStatements(null, model.getProperty(Namespace.LIST+"hasContents"), r);
while (stmt.hasNext()) {
Statement s = stmt.next();
Resource list = s.getSubject();
if (list.getProperty(model.getProperty(Namespace.LIST+"hasNext"))!=null) {
statements.add(list.getProperty(model.getProperty(Namespace.LIST+"hasNext")));
statements.add(list.getProperty(RDF.type));
StmtIterator st = model.listStatements(null, model.getProperty(Namespace.LIST+"hasNext"), list);
while (st.hasNext()) {
statements.addAll(retrieveList(new HashSet<Statement>(),
st.next()));
}
}
}
while (st1.hasNext()) {
Statement statement=st1.next();
statements.add(statement);
if(statement.getObject() instanceof Resource){
statements=removePrimaryTypes(statements,statement);
if (((Resource)statement.getObject()).getProperty(HASCONTENTS)!=null){
statements.addAll(retrieveList2(new HashSet<Statement>(),((Resource)statement.getObject()).getProperty(HASCONTENTS)));
}
}
}
while (st3.hasNext()) {
statements.add(st3.next());
}
return statements;
}
示例13: main
import com.hp.hpl.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, WktParseException{
InputStream in=ConvexHullTest.class.getClassLoader().getResourceAsStream("lifeline_geometry.ttl");
Model model=ModelFactory.createDefaultModel();
model.read(in,null,"TTL");
StmtIterator stmts=model.listStatements(null, GEOM.hasGeometry, (RDFNode)null);
while(stmts.hasNext()){
Statement stmt=stmts.next();
System.out.print(stmt.getSubject().getLocalName()+ " : ");
String ewkt=stmt.getObject().asResource().getProperty(GEOM.asBody).getObject().asLiteral().getString();
EwktReader reader=new EwktReader(ewkt);
Geometry geometry=reader.readGeometry();
if (geometry.geometryTypeId()==GeometryType.TYPE_POLYHEDRALSURFACE){
PolyhedralSurface ps=new ConvexHull().buildConvexHull((PolyhedralSurface)geometry);
Polyhedron ph=new Polyhedron(ps);
MVBB obb=new MVBB(ph);
obb.computeMinBB();
Box box=obb.getBox();
System.out.println(box.getVolume()/1000000000);
System.out.print(box.getOrientation().getN1());
System.out.print(box.getOrientation().getN2());
System.out.println(box.getOrientation().getN3());
// System.out.println(box.getMin());
// System.out.println(box.getMax());
}
}
}
示例14: buildMappings
import com.hp.hpl.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
private void buildMappings(Model model) throws MalformedURLException {
mappings = new HashMap();
Property mapsTo = model.createProperty(RTM_MAPSTO);
StmtIterator it = model.listStatements(null, mapsTo, (RDFNode) null);
while (it.hasNext()) {
Statement stmt = (Statement) it.next();
StatementHandler mapper = getMapper(stmt.getSubject(), stmt.getObject(), model);
mappings.put(stmt.getSubject().getURI(), mapper);
}
it.close();
}
示例15: getNumberOfIncomingLinks
import com.hp.hpl.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
public static int getNumberOfIncomingLinks(Resource resource) {
StmtIterator stmtIterator = resource.getModel().listStatements(null, null, resource);
int count = 0;
for (; stmtIterator.hasNext(); ++count) {
stmtIterator.next();
}
return count;
}