私はクラスを持っていMAN
ます。jack
プロパティを持つ個体 を追加したい:
hasage="50"
hasadress="france"
jack
個人を作成してプロパティを追加し、ファイルに保存するにはどうすればよいですdatabase.owl
か? これが接続です。私は Eclipse と Jena API を使用しています。
JenaOWLModel owlModel ;
OntModel model;
owlModel = ProtegeOWL.createJenaOWLModelFromURI("file:///C:/database.owl");
model = owlModel.getOntModel();
私はあなたに助けを求めています.私の論文の弁護にはまだ数日かかります.このコードは完全に機能します.個人をファイルに保存できます.owl.
助けてください どうすればいいですか、本当に心配です よろしくお願いします
public class testins {
static JenaOWLModel owlModel ;
public static void main(String[] args) {
OntModel model;
javax.swing.JDialog jDialog1 = new javax.swing.JDialog();
try{
owlModel = ProtegeOWL.createJenaOWLModelFromURI("file:///D:/file.owl");// the link of my owl file
model = owlModel.getOntModel();
JOptionPane.showMessageDialog(jDialog1,
"loaded with success","Information",JOptionPane.INFORMATION_MESSAGE);
}
catch(Exception e){
JOptionPane.showMessageDialog(jDialog1,
"error",
"Information",
JOptionPane.INFORMATION_MESSAGE);
}
OWLNamedClass theAlert = owlModel.getOWLNamedClass("Alert"); //my class Alert
theAlert.createOWLIndividual("indivname1"); //i add here an indevidual
theAlert.createOWLIndividual("indivname2"); //i add here another indevidual
// now how to add to those two Individuals properties ?? each individual has 2
// properties , the property witch its name est_evaluer and the second est_analyser those
// to properties will contain values so here is my problem how to add those values to an
// individual and save all of them
Collection errors ;
String fileName ;
fileName= ("D:/file.owl");
errors = new ArrayList();
//here i'll save it and it work ,it mean that i find in my file "file.owl"
//individuals i added witch are "indivname1" and "indivname2" in my class ALERT
// so now my problem is how to add properties to those indiviuals i add , and save them also
try{ owlModel.save(new File(fileName).toURI(), FileUtils.langXMLAbbrev, errors);
System.out.println("File saved with " + errors.size() + " errors.");
}
catch(Exception e){
}
}
}