public static INode FromJenaNode(RDFNode n, JenaMapping mapping) { if (n.isResource()) { return(FromJenaResource((Resource)n, mapping)); } else if (n.isLiteral()) { Literal lit = (Literal)n; if (lit.getDatatypeURI() != null) { return(mapping.Graph.CreateLiteralNode(lit.getLexicalForm(), new Uri(lit.getDatatypeURI()))); } else if (!lit.getLanguage().Equals(String.Empty)) { return(mapping.Graph.CreateLiteralNode(lit.getLexicalForm(), lit.getLanguage())); } else { return(mapping.Graph.CreateLiteralNode(lit.getLexicalForm())); } } else { throw new RdfException("Unable to convert from an unknown Jena Node type to a dotNetRDF Node"); } }
private IEnumerable<Triple> GetTriples(Resource r, Property p, RDFNode rdfn) { if (r == null) { if (p == null) { //Object specified return this._g.GetTriplesWithObject(JenaConverter.FromJenaNode(rdfn, this._mapping)); } else if (rdfn == null) { //Predicate specified return this._g.GetTriplesWithPredicate(JenaConverter.FromJenaProperty(p, this._mapping)); } else { //Object and Predicate specified return this._g.GetTriplesWithPredicateObject(JenaConverter.FromJenaProperty(p, this._mapping), JenaConverter.FromJenaNode(rdfn, this._mapping)); } } else if (p == null) { if (rdfn == null) { //Subject specified return this._g.GetTriplesWithSubject(JenaConverter.FromJenaResource(r, this._mapping)); } else { //Subject and Object specified return this._g.GetTriplesWithSubjectObject(JenaConverter.FromJenaResource(r, this._mapping), JenaConverter.FromJenaNode(rdfn, this._mapping)); } } else if (rdfn == null) { //Subject and Predicate specified return this._g.GetTriplesWithSubjectPredicate(JenaConverter.FromJenaResource(r, this._mapping), JenaConverter.FromJenaProperty(p, this._mapping)); } else { Triple t = new Triple(JenaConverter.FromJenaResource(r, this._mapping), JenaConverter.FromJenaProperty(p, this._mapping), JenaConverter.FromJenaNode(rdfn, this._mapping)); if (this._g.ContainsTriple(t)) { return t.AsEnumerable(); } else { return Enumerable.Empty<Triple>(); } } }
private IEnumerable <Triple> GetTriples(Resource r, Property p, RDFNode rdfn) { if (r == null) { if (p == null) { //Object specified return(this._g.GetTriplesWithObject(JenaConverter.FromJenaNode(rdfn, this._mapping))); } else if (rdfn == null) { //Predicate specified return(this._g.GetTriplesWithPredicate(JenaConverter.FromJenaProperty(p, this._mapping))); } else { //Object and Predicate specified return(this._g.GetTriplesWithPredicateObject(JenaConverter.FromJenaProperty(p, this._mapping), JenaConverter.FromJenaNode(rdfn, this._mapping))); } } else if (p == null) { if (rdfn == null) { //Subject specified return(this._g.GetTriplesWithSubject(JenaConverter.FromJenaResource(r, this._mapping))); } else { //Subject and Object specified return(this._g.GetTriplesWithSubjectObject(JenaConverter.FromJenaResource(r, this._mapping), JenaConverter.FromJenaNode(rdfn, this._mapping))); } } else if (rdfn == null) { //Subject and Predicate specified return(this._g.GetTriplesWithSubjectPredicate(JenaConverter.FromJenaResource(r, this._mapping), JenaConverter.FromJenaProperty(p, this._mapping))); } else { Triple t = new Triple(JenaConverter.FromJenaResource(r, this._mapping), JenaConverter.FromJenaProperty(p, this._mapping), JenaConverter.FromJenaNode(rdfn, this._mapping)); if (this._g.ContainsTriple(t)) { return(t.AsEnumerable()); } else { return(Enumerable.Empty <Triple>()); } } }
public StmtIterator listStatements(Resource r, Property p, RDFNode rdfn) { throw new NotImplementedException(); }
public Statement createStatement(Resource r, Property p, RDFNode rdfn) { throw new NotImplementedException(); }
public RDFList createList(RDFNode[] rdfnarr) { throw new NotImplementedException(); }
public bool containsResource(RDFNode rdfn) { throw new NotImplementedException(); }
public bool contains(Resource r, Property p, RDFNode rdfn) { return this.GetTriples(r, p, rdfn).Any(); }
public bool contains(Resource r, Property p, RDFNode rdfn) { return(this.GetTriples(r, p, rdfn).Any()); }
public static INode FromJenaNode(RDFNode n, JenaMapping mapping) { if (n.isResource()) { return FromJenaResource((Resource)n, mapping); } else if (n.isLiteral()) { Literal lit = (Literal)n; if (lit.getDatatypeURI() != null) { return mapping.Graph.CreateLiteralNode(lit.getLexicalForm(), new Uri(lit.getDatatypeURI())); } else if (!lit.getLanguage().Equals(String.Empty)) { return mapping.Graph.CreateLiteralNode(lit.getLexicalForm(), lit.getLanguage()); } else { return mapping.Graph.CreateLiteralNode(lit.getLexicalForm()); } } else { throw new RdfException("Unable to convert from an unknown Jena Node type to a dotNetRDF Node"); } }
public Model remove(Resource r, Property p, RDFNode rdfn) { throw new NotImplementedException(); }
public ResIterator listSubjectsWithProperty(Property p, RDFNode rdfn) { throw new NotImplementedException(); }
/// <summary> /// Metodo que retorna una lista de nombres de conceptos (clases) e individuos de la ontología /// </summary> public static List <OntologyConceptCopy> ObtenerConceptosOntologia(string ontologia) { List <OntologyConceptCopy> listaClases = new List <OntologyConceptCopy>(); List <string> noduplicados = new List <string>(); string rutaDirActual = System.AppDomain.CurrentDomain.BaseDirectory; string rutaRelOwl = @ontologia; string rutaOwl = Path.Combine(rutaDirActual, rutaRelOwl); //string clases = ""; rutaOwl = "file:///" + rutaOwl; OntModel m; m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); m.read(rutaOwl, "RDF/XML"); for (Iterator i = m.listNamedClasses(); i.hasNext();) //se recorren todas clases nombradas { //se la convierte a OntClass para su analisis OntClass cls = (OntClass)i.next(); //Añadimos el nombre de las anotaciones Label que tenga la clase ExtendedIterator label = cls.listLabels(null); while (label.hasNext()) { //Variable temporal en el que se almacena el concepto actual OntologyConceptCopy Oconcept = new OntologyConceptCopy(); Oconcept.Urlconcepto = cls.getURI().ToString(); RDFNode thisLabel = (RDFNode)label.next(); if (thisLabel.isLiteral()) { Oconcept.OntCopyNameConcept = ((Literal)thisLabel).getValue().ToString(); //Verificar no colocar conceptos duplicados if (!noduplicados.Contains(Oconcept.OntCopyNameConcept)) { listaClases.Add(Oconcept); noduplicados.Add(Oconcept.OntCopyNameConcept); } } else { Oconcept.OntCopyNameConcept = thisLabel.ToString(); //Verificar no colocar conceptos duplicados if (!noduplicados.Contains(Oconcept.OntCopyNameConcept)) { listaClases.Add(Oconcept); noduplicados.Add(Oconcept.OntCopyNameConcept); } } } //Se añaden las instancias. Para que no se aliminada una instancia con el mismo nombre de una clase se inicializa el vector de duplicados noduplicados.Clear(); for (Iterator j = cls.listInstances(true); j.hasNext();) { Individual ind = (Individual)j.next(); if (ind.isIndividual()) { //Añadimos el nombre de las anotaciones Label que tenga el individuo ExtendedIterator labelind = ind.listLabels(null); while (labelind.hasNext()) { //Variable temporal en el que se almacena el concepto actual OntologyConceptCopy Oconcept = new OntologyConceptCopy(); Oconcept.Urlconcepto = cls.getURI().ToString(); RDFNode thisLabel = (RDFNode)labelind.next(); if (thisLabel.isLiteral()) { Oconcept.OntCopyNameConcept = ((Literal)thisLabel).getValue().ToString(); //Verificar no colocar conceptos duplicados if (!noduplicados.Contains(Oconcept.OntCopyNameConcept)) { listaClases.Add(Oconcept); noduplicados.Add(Oconcept.OntCopyNameConcept); } } else { Oconcept.OntCopyNameConcept = thisLabel.toString(); //Verificar no colocar conceptos duplicados if (!noduplicados.Contains(Oconcept.OntCopyNameConcept)) { listaClases.Add(Oconcept); noduplicados.Add(Oconcept.OntCopyNameConcept); } } } } } } return(listaClases); }