本文整理匯總了Java中com.hp.hpl.jena.rdf.model.Statement.getObject方法的典型用法代碼示例。如果您正苦於以下問題:Java Statement.getObject方法的具體用法?Java Statement.getObject怎麽用?Java Statement.getObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hp.hpl.jena.rdf.model.Statement
的用法示例。
在下文中一共展示了Statement.getObject方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initializeCategories
import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的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: main
import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的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();
}
}
}
示例3: main
import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
public static void main(String[] args) {
HDT hdt = null;
try {
hdt = HDTManager.mapIndexedHDT(TYPES, null);
} catch (IOException e) {
e.printStackTrace();
}
HDTGraph graph = new HDTGraph(hdt);
Model m = ModelFactory.createModelForGraph(graph);
StmtIterator iter = m.listStatements();
HashMap<String, Integer> hash = new HashMap<String, Integer>();
int number = 0;
while (iter.hasNext()) {
if (number % 50000 == 0) {
System.out.println("Processed Entries: " + number);
}
Statement stmt = iter.next();
RDFNode object = stmt.getObject();
String s = null;
s = object.asResource().getURI();
hash.put(s, 0);
number++;
}
System.out.println("Anzahl an Typen: " +hash.size());
}
示例4: getSourceType
import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
private SourceTypes getSourceType(Resource mappingResource)
{
Property sourceNameProp = model.getProperty(Uris.KM_SOURCE_TYPE_URI);
Statement s = model.getProperty(mappingResource, sourceNameProp);
String sourceType = null;
if(s != null)
{
RDFNode node = s.getObject();
if(node != null && node.isLiteral())
{
sourceType = node.asLiteral().getString();
return SourceTypes.valueOf(sourceType);
}
}
return SourceTypes.CSV;
}
示例5: sportsTeamsSurfaceForms
import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的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.Statement; //導入方法依賴的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: parseN3
import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
private static void parseN3(GrabMappingsHandler handler, String infileurl) {
Model model = ModelFactory.createDefaultModel();
model.read(infileurl, "N3");
AResourceImpl sub = new AResourceImpl();
AResourceImpl pred = new AResourceImpl();
AResourceImpl objres = new AResourceImpl();
ALiteralImpl objlit = new ALiteralImpl();
StmtIterator it = model.listStatements();
while (it.hasNext()) {
Statement stmt = it.nextStatement();
RDFNode object = stmt.getObject();
sub.setResource(stmt.getSubject());
pred.setResource(stmt.getPredicate());
if (object instanceof Literal) {
objlit.setLiteral((Literal) object);
handler.statement(sub, pred, objlit);
} else {
objres.setResource((Resource) object);
handler.statement(sub, pred, objres);
}
}
}
示例8: writeStatement
import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
private void writeStatement(Statement stmt, PrintStream out)
{
String name = getQName(stmt.getPredicate());
Map<String,String> attrs = null;
String value = null;
RDFNode node = stmt.getObject();
if ( node.isLiteral() )
{
Literal l = node.asLiteral();
value = l.getString();
String lang = l.getLanguage();
if ( !lang.isEmpty() ) { attrs = Collections.singletonMap("xml:lang", lang); }
String datatype = l.getDatatypeURI();
if ( datatype != null ) { attrs = Collections.singletonMap("rdf:datatype", datatype); }
}
else {
attrs = Collections.singletonMap("rdf:resource", getURI(node.asResource()));
}
writeProperty(name, attrs, value, out);
}
示例9: getRequest
import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
private List getRequest(Resource pcho)
{
List l = new ArrayList();
StmtIterator iter = pcho.listProperties();
while ( iter.hasNext() )
{
Statement stmt = iter.nextStatement();
RDFNode node = stmt.getObject();
String uri = stmt.getPredicate().getURI();
if ( node.isResource() || !_fields.containsKey(uri) ) { continue; }
String prop = getQName(stmt.getPredicate());
String value = node.asLiteral().getString();
String[] vocs = _fields.get(uri);
for ( String key : normalizeInternal(value) )
{
Map m = new HashMap(3);
m.put("originalField", prop + ";" + value);
m.put("value", key);
m.put("vocabularies", vocs);
l.add(m);
}
}
return l;
}
示例10: fixLanguage
import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
public static void fixLanguage(StmtIterator iter, String sLang)
{
if ( (sLang == null) || sLang.trim().isEmpty() ) { return; }
List<Statement> list = iter.toList();
for ( Statement stmt : list )
{
RDFNode n = stmt.getObject();
if ( !n.isLiteral() ) { continue; }
Literal l = n.asLiteral();
String sL = l.getLanguage();
if ( (sL != null) && !sL.trim().isEmpty() ) { continue; }
stmt.changeObject(l.getString(), sLang);
}
}
示例11: dumpStatement
import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
void dumpStatement(Statement stmt) {
Resource subject = stmt.getSubject();
Property predicate = stmt.getPredicate();
RDFNode object = stmt.getObject();
System.out.print(subject + " " + predicate + " ");
if (object instanceof Resource) {
System.out.print(object);
} else { // object is a literal
System.out.print(" \"" + object + "\"");
}
System.out.println(" .");
}
示例12: retrieveList2
import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
private List<Statement> retrieveList2(List<Statement> statements,Statement s){
statements.add(s);
Resource list=s.getSubject();
Statement st = list.getProperty(RDF.rest);
statements.add(st);
if (st.getObject() instanceof Resource && ((Resource)st.getObject()).getProperty(RDF.first)!=null){
statements=retrieveList2(statements,((Resource)st.getObject()).getProperty(RDF.first));
}
return statements;
}
示例13: listRelatedStatements
import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的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;
}
示例14: removePrimaryTypes
import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
private HashSet<Statement> removePrimaryTypes(HashSet<Statement> statements, Statement statement){
Resource object=(Resource)statement.getObject();
Statement s=object.getProperty(HASBOOLEAN);
if(s!=null){
statements.add(s);
statements.add(object.getProperty(RDF.type));
}
s=object.getProperty(HASSTRING);
if(s!=null){
statements.add(s);
statements.add(object.getProperty(RDF.type));
}
s=object.getProperty(HASDOUBLE);
if(s!=null){
statements.add(s);
statements.add(object.getProperty(RDF.type));
}
s=object.getProperty(HASLOGICAL);
if(s!=null){
statements.add(s);
statements.add(object.getProperty(RDF.type));
}
s=object.getProperty(HASINTEGER);
if(s!=null){
statements.add(s);
statements.add(object.getProperty(RDF.type));
}
s=object.getProperty(HASHEXBINARY);
if(s!=null){
statements.add(s);
statements.add(object.getProperty(RDF.type));
}
return statements;
}
示例15: retrieveList2
import com.hp.hpl.jena.rdf.model.Statement; //導入方法依賴的package包/類
private HashSet<Statement> retrieveList2(HashSet<Statement> statements,Statement s){
statements.add(s);
statements=removePrimaryTypes(statements,s);
Resource list=s.getSubject();
statements.add(list.getProperty(RDF.type));
Statement st = list.getProperty(model.getProperty(Namespace.LIST+"hasNext"));
if(st!=null){
statements.add(st);
if (st.getObject() instanceof Resource && ((Resource)st.getObject()).getProperty(model.getProperty(Namespace.LIST+"hasContents"))!=null){
statements=retrieveList2(statements,((Resource)st.getObject()).getProperty(model.getProperty(Namespace.LIST+"hasContents")));
}
}
return statements;
}