IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Frameworks Discussion :

Insérer des individus dans une ontologie


Sujet :

Frameworks

  1. #1
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Mai 2012
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Mai 2012
    Messages : 31
    Points : 19
    Points
    19
    Par défaut Insérer des individus dans une ontologie
    Bonjour,
    je veux ajouter des individus à mon ontologie.
    j'ai suivi vos instructions pour l'ajout d'individus mais j'ai des problèmes dans le code .
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    package conn;
     
    import com.hp.hpl.jena.iri.impl.Main;
    import com.hp.hpl.jena.ontology.DatatypeProperty;
    import com.hp.hpl.jena.ontology.Individual;
    import com.hp.hpl.jena.ontology.OntClass;
    import com.hp.hpl.jena.ontology.OntModel;
    import com.hp.hpl.jena.ontology.OntModelSpec;
    import com.hp.hpl.jena.rdf.model.*;
    import com.hp.hpl.jena.util.FileManager;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.Iterator;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import com.hp.hpl.jena.query.Query;
    import com.hp.hpl.jena.vocabulary.XSD;
    import java.io.BufferedInputStream;
    import java.io.FileInputStream;
     
    public class ExpleInsert {
     
       public static final String NL      = System.getProperty("line.separator") ;
       public static final String URIB="http://www.owl-ontologies.com/reuses.owl#";
        public static final String owlFile="file:///C:/Program20%Files/Protege_3.4.7/examples/Krs1.owl";
     
       public void connect() throws FileNotFoundException
       {  
     
     
           OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF);
     
           String inputFileName ="file:///C:/Program Files/Protege_3.4.7/examples/Krs1.owl";
           // use the FileManager to find the input file
           InputStream in = FileManager.get().open(inputFileName );
           if (in == null) {
                       model.read(in, " ", inputFileName);
               throw new IllegalArgumentException("File: " + inputFileName + " not found");}
           OntModel ontology = ModelFactory.createOntologyModel();
           OntModel mod = ModelFactory.createOntologyModel();
    /*OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF); 
     
    InputStream is = new BufferedInputStream(new FileInputStream(owlFile));
    //C:\\Users\\sarah\\Desktop\\ontocerist.owl
    OntModel ontology = ModelFactory.createOntologyModel();
    model.read(is, "RDF/XML");
     
    OntModel mod = ModelFactory.createOntologyModel();*/
     
    OntClass BesoinClass = ontology.getOntClass("http://www.owl-ontologies.com/reuses.owl#Besoin");
    Individual c = mod.createIndividual("http://www.owl-ontologies.com/reuses.owl#Besoin",BesoinClass);
    DatatypeProperty nomProp = ontology.getDatatypeProperty("http://www.owl-ontologies.com/reuses.owl#hasnamebesoin");
    //DatatypeProperty prenomProp = ontology.getDatatypeProperty("http://www.semanticweb.org/SEVEN7/ontologies/2012/2/Ontology1331977184905.owl#Prenom");
     
     
    // on peut éventuellement mettre un langageTag:
    Literal n = mod.createLiteral("sarah");
    //Literal p = mod.createLiteral("sefti"); // idem
     
    //c.addLiteral(nomProp, n);
    mod.createStatement(c,nomProp,n);
    //mod.createStatement(c,prenomProp,p);
     
     
     
     
     
     
     
     
    }
     
     
     
     
     
     
     
     
        public static void main(String[]  args)throws Exception {
     
     ExpleInsert a=new  ExpleInsert ();
     a.connect();
     
     
     
        }
     
     
        }
    voici les erreurs
    Exception in thread "main" java.lang.NullPointerException
    at com.hp.hpl.jena.rdf.model.impl.StatementImpl.<init>(StatementImpl.java:31)
    at com.hp.hpl.jena.rdf.model.impl.ModelCom.createStatement(ModelCom.java:1126)
    at conn.ExpleInsert.connect(ExpleInsert.java:65)
    at conn.ExpleInsert.main(ExpleInsert.java:87)

  2. #2
    Membre habitué
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    87
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Etats-Unis

    Informations forums :
    Inscription : Juillet 2005
    Messages : 87
    Points : 134
    Points
    134
    Par défaut
    On dirait que ligne 65, un des paramètres de createStatement est null.

    A toi de les vérifier.

    Edit: C'est normal d'avoir l'URI pour ta classe Besoin et ton individu? (ligne 54 et 55)

  3. #3
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Mai 2012
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Mai 2012
    Messages : 31
    Points : 19
    Points
    19
    Par défaut
    bonsoir,
    merci pour votre attention et pour les paramètres ne sont pas null.

  4. #4
    Membre habitué
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    87
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Etats-Unis

    Informations forums :
    Inscription : Juillet 2005
    Messages : 87
    Points : 134
    Points
    134
    Par défaut
    Tu as lu toute ma reponse?

    Y'a un probleme ligne 54 et 55 ...

    Tiens, ca va t'aider la doc sur la methode createIndividual

Discussions similaires

  1. [Jena] Insérer des individus dans une ontologie
    Par helabah dans le forum Frameworks
    Réponses: 2
    Dernier message: 25/05/2012, 00h33
  2. Insérer des Jpeg dans une BDD
    Par KRis dans le forum Bases de données
    Réponses: 8
    Dernier message: 19/03/2009, 19h16
  3. Réponses: 26
    Dernier message: 01/07/2006, 13h14
  4. Insérer des lignes dans une StringGrid
    Par da_latifa dans le forum Composants VCL
    Réponses: 1
    Dernier message: 26/09/2005, 12h45
  5. insérer des images dans une bd postgresql
    Par ephet dans le forum PostgreSQL
    Réponses: 3
    Dernier message: 20/01/2004, 09h18

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo