From: <ku...@us...> - 2010-09-17 10:00:13
|
Revision: 2313 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2313&view=rev Author: kurzum Date: 2010-09-17 10:00:04 +0000 (Fri, 17 Sep 2010) Log Message: ----------- changes before the transition Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/examples/MonogenicDiseases.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/examples/Parkinsons.java trunk/components-core/src/main/java/org/dllearner/examples/flags/ trunk/components-core/src/main/java/org/dllearner/examples/flags/FlagScript.java trunk/components-core/src/main/java/org/dllearner/examples/flags/Script.java trunk/test/ trunk/test/parkinsons/ trunk/test/parkinsons/files/ trunk/test/parkinsons/parkinsons.data trunk/test/parkinsons/parkinsons.owl trunk/test/parkinsons/train.conf Modified: trunk/components-core/src/main/java/org/dllearner/examples/MonogenicDiseases.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/examples/MonogenicDiseases.java 2010-09-17 09:32:51 UTC (rev 2312) +++ trunk/components-core/src/main/java/org/dllearner/examples/MonogenicDiseases.java 2010-09-17 10:00:04 UTC (rev 2313) @@ -54,21 +54,68 @@ * */ public class MonogenicDiseases { + +//---> OPTIONS: + private static int algorithmus = 1; // 1 = pos/neg Algorithmus 2 = Celoe + private static boolean writeAlephFiles = true; // Add AlephFiles + private static boolean writeYYFiles = true; // Add YinYangFiles + private static int posEx = 25; // Number of pos-Ex. + private static int negEx = 25; // Number of neg-Ex. + private static boolean cvAleph = true; // add Files for Aleph 10-Fold Cross Validation +//<--- OPTIONS end + private static IRI ontologyURI = IRI.create("http://dl-learner.org/mutation"); private static File owlFile = new File("examples/mutation/mutation.owl"); private static File confFile = new File("examples/mutation/mutation.conf"); + private static File badFile = new File("examples/mutation/mutation1.n"); // AlephFile + private static File posFile = new File("examples/mutation/mutation1.f"); // AlephFile + private static File yybadFile = new File("examples/mutation/mutationNegatives.txt"); //YYFile + private static File yyposFile = new File("examples/mutation/mutationPositives.txt"); //YYFile + + private static File split1n = new File("examples/mutation/split1.n"); + private static File split1f = new File("examples/mutation/split1.f"); + private static File split2n = new File("examples/mutation/split2.n"); + private static File split2f = new File("examples/mutation/split2.f"); + private static File split3n = new File("examples/mutation/split3.n"); + private static File split3f = new File("examples/mutation/split3.f"); + private static File split4n = new File("examples/mutation/split4.n"); + private static File split4f = new File("examples/mutation/split4.f"); + private static File split5n = new File("examples/mutation/split5.n"); + private static File split5f = new File("examples/mutation/split5.f"); + private static File split6n = new File("examples/mutation/split6.n"); + private static File split6f = new File("examples/mutation/split6.f"); + private static File split7n = new File("examples/mutation/split7.n"); + private static File split7f = new File("examples/mutation/split7.f"); + private static File split8n = new File("examples/mutation/split8.n"); + private static File split8f = new File("examples/mutation/split8.f"); + private static File split9n = new File("examples/mutation/split9.n"); + private static File split9f = new File("examples/mutation/split9.f"); + private static File split10n = new File("examples/mutation/split10.n"); + private static File split10f = new File("examples/mutation/split10.f"); + + // whether to generate a class containing the positive examples - private static boolean generatePosExampleClass = true; + private static boolean generatePosExampleClass = false; // set to true if accessing PostreSQL and false for MySQL private static boolean pgSQL = true; // generate fragment => limits the number of individuals in the ontology // to speed up learning -// private static boolean onlyFragment = true; + private static boolean learnMutation = true; + // private static boolean onlyFragment = true; public static void main(String[] args) throws ClassNotFoundException, BackingStoreException, SQLException { + + if (algorithmus == 1) { // LearnAlgo-Check + generatePosExampleClass = false; + } + if (algorithmus == 2) { // LearnAlgo-Check + generatePosExampleClass = true; + } + + // reading values for db connection from ini file String iniFile = "src/dl-learner/org/dllearner/examples/mutation.ini"; Preferences prefs = new IniFile(new File(iniFile)); @@ -251,12 +298,204 @@ rs = stmt.executeQuery("SELECT * FROM " + table + " WHERE (gain_contact is not null) AND (gain_contact != 0)"); } - int count = 0; - while(rs.next()) { +int count = 1; +int pos_count = 0; +int neg_count = 1; + + + if (writeAlephFiles){ // Clear AlephFiles + Files.clearFile(badFile); + Files.clearFile(posFile); + } + + if (writeYYFiles) { // Clear YinYangFiles + Files.clearFile(yybadFile); + Files.clearFile(yyposFile); + } + + if (cvAleph) { // Clear Aleph CV-Files + Files.clearFile(split1n); + Files.clearFile(split1f); + Files.clearFile(split2n); + Files.clearFile(split2f); + Files.clearFile(split3n); + Files.clearFile(split3f); + Files.clearFile(split4n); + Files.clearFile(split4f); + Files.clearFile(split5n); + Files.clearFile(split5f); + Files.clearFile(split6n); + Files.clearFile(split6f); + Files.clearFile(split7n); + Files.clearFile(split7f); + Files.clearFile(split8n); + Files.clearFile(split8f); + Files.clearFile(split9n); + Files.clearFile(split9f); + Files.clearFile(split10n); + Files.clearFile(split10f); + } + + int kp = 1; // k for CV positiv + int kn = 1; // k for CV negativ + int peps = posEx/10; // positiv Examples per Splitfile + int neps = negEx/10; // negative Examples per Splitfile + int aneg = 0; // aktuell negativ + int apos = 0; // aktuell positiv + + + while((rs.next()) && ((pos_count < posEx) || (neg_count < negEx))) { + + + // generate an individual for each entry in the table int mutationID = rs.getInt("id"); Individual mutationInd = new Individual(getURI("mutation" + mutationID)); + + String pt = rs.getString("phenotype"); + if ((pt.toLowerCase().contains("polymorphism"))&&( neg_count<=negEx )) { + if (writeAlephFiles) { + Files.appendFile(badFile, "deleterious(id"+mutationID+").\n"); + } + if (writeYYFiles) { + Files.appendFile(yybadFile, "http://example.com/mutation/mutation#mutation"+mutationID+"\n"); + } + if (cvAleph){ + switch (kn) { + case 1: + aneg++; + Files.appendFile(split1n, "deleterious(id"+mutationID+").\n"); + if (aneg == neps) {aneg = 0; kn++;} + break; + case 2: + aneg++; + Files.appendFile(split2n, "deleterious(id"+mutationID+").\n"); + if (aneg == neps) {aneg = 0; kn++;} + break; + case 3: + aneg++; + Files.appendFile(split3n, "deleterious(id"+mutationID+").\n"); + if (aneg == neps) {aneg = 0; kn++;} + break; + case 4: + aneg++; + Files.appendFile(split4n, "deleterious(id"+mutationID+").\n"); + if (aneg == neps) {aneg = 0; kn++;} + break; + case 5: + aneg++; + Files.appendFile(split5n, "deleterious(id"+mutationID+").\n"); + if (aneg == neps) {aneg = 0; kn++;} + break; + case 6: + aneg++; + Files.appendFile(split6n, "deleterious(id"+mutationID+").\n"); + if (aneg == neps) {aneg = 0; kn++;} + break; + case 7: + aneg++; + Files.appendFile(split7n, "deleterious(id"+mutationID+").\n"); + if (aneg == neps) {aneg = 0; kn++;} + break; + case 8: + aneg++; + Files.appendFile(split8n, "deleterious(id"+mutationID+").\n"); + if (aneg == neps) {aneg = 0; kn++;} + break; + case 9: + aneg++; + Files.appendFile(split9n, "deleterious(id"+mutationID+").\n"); + if (aneg == neps) {aneg = 0; kn++;} + break; + case 10: + aneg++; + Files.appendFile(split10n, "deleterious(id"+mutationID+").\n"); +// if (aneg == neps) {aneg = 0; kn++;} + break; +// case 11: // without comment its round negExamples / 10 +// break; + } + } + + neg_count++; + } + if ((!pt.toLowerCase().contains("polymorphism"))&& ( pos_count<=posEx)) { + if (writeAlephFiles) { + Files.appendFile(posFile, "deleterious(id"+mutationID+").\n"); + } + if (writeYYFiles) { + Files.appendFile(yyposFile, "http://example.com/mutation/mutation#mutation"+mutationID+"\n"); + } + if (cvAleph){ + switch (kp) { + case 1: + apos++; + Files.appendFile(split1f, "deleterious(id"+mutationID+").\n"); + if (apos == peps) {apos = 0; kp++;} + break; + case 2: + apos++; + Files.appendFile(split2f, "deleterious(id"+mutationID+").\n"); + if (apos == peps) {apos = 0; kp++;} + break; + case 3: + apos++; + Files.appendFile(split3f, "deleterious(id"+mutationID+").\n"); + if (apos == peps) {apos = 0; kp++;} + break; + case 4: + apos++; + Files.appendFile(split4f, "deleterious(id"+mutationID+").\n"); + if (apos == peps) {apos = 0; kp++;} + break; + case 5: + apos++; + Files.appendFile(split5f, "deleterious(id"+mutationID+").\n"); + if (apos == peps) {apos = 0; kp++;} + break; + case 6: + apos++; + Files.appendFile(split6f, "deleterious(id"+mutationID+").\n"); + if (apos == peps) {apos = 0; kp++;} + break; + case 7: + apos++; + Files.appendFile(split7f, "deleterious(id"+mutationID+").\n"); + if (apos == peps) {apos = 0; kp++;} + break; + case 8: + apos++; + Files.appendFile(split8f, "deleterious(id"+mutationID+").\n"); + if (apos == peps) {apos = 0; kp++;} + break; + case 9: + apos++; + Files.appendFile(split9f, "deleterious(id"+mutationID+").\n"); + if (apos == peps) {apos = 0; kp++;} + break; + case 10: + apos++; + Files.appendFile(split10f, "deleterious(id"+mutationID+").\n"); +// if (apos == peps) {apos = 0; kp++;} + break; +// case 11: // without comments its round to posExamples / 10 +// break; + } + } + + + pos_count++; + } + + if ((pt.toLowerCase().contains("polymorphism"))&&( neg_count > negEx )) { + continue; + } + if ((!pt.toLowerCase().contains("polymorphism"))&& ( pos_count > posEx)) { + continue; + } + + // size change is represented via 3 classes String modifSize = rs.getString("modif_size"); convertThreeValuedColumn(kb, mutationInd, modifSize, protSizeIncClass, protSizeUnchangedClass, protSizeDecClass); @@ -340,7 +579,7 @@ double identicalN1Contact = rs.getDouble("identical_n1_contact"); kb.addAxiom(new DoubleDatatypePropertyAssertion(identicalN1ContactProp, mutationInd, identicalN1Contact)); - // TODO Vorsicht bei 0-Werten in den weitern Feldern (klären, ob in dem + // TODO Vorsicht bei 0-Werten in den weitern Feldern (kl\xE4ren, ob in dem // Fall gar nichts geschrieben werden soll) // wt_accessibility @@ -372,10 +611,17 @@ // generate a class with all positive examples (optional) if(generatePosExampleClass) { String phenotype = rs.getString("phenotype"); + + if(!phenotype.toLowerCase().contains("polymorphism")) { kb.addAxiom(new ClassAssertionAxiom(deleteriousMutationClass, mutationInd)); } + } + +// String pt = rs.getString("phenotype"); +// if (pt.toLowerCase().contains("polymorphism")) { neg_count++; } +// if (!pt.toLowerCase().contains("polymorphism")) { pos_count++; } count++; @@ -387,6 +633,8 @@ OWLAPIReasoner.exportKBToOWL(owlFile, kb, ontologyURI); long writeDuration = System.nanoTime() - startWriteTime; System.out.println("OK (entities: " + count + "; time: " + Helper.prettyPrintNanoSeconds(writeDuration) + "; file size: " + owlFile.length()/1024 + " KB)."); + + // selecting examples // -> only a fraction of examples are selected as positive/negative @@ -399,52 +647,80 @@ } List<Individual> posExamples = new LinkedList<Individual>(); List<Individual> negExamples = new LinkedList<Individual>(); - while(rs.next()) { + +count = 1; +pos_count = 0; +neg_count = 0; + + + + while((rs.next()) && (pos_count < posEx) || (neg_count < negEx)) { int mutationID = rs.getInt("id"); String phenotype = rs.getString("phenotype"); - if(phenotype.toLowerCase().contains("polymorphism")) { - negExamples.add(new Individual(getURI("mutation" + mutationID))); - } else { - posExamples.add(new Individual(getURI("mutation" + mutationID))); +// if(phenotype.toLowerCase().contains("polymorphism")) { +// negExamples.add(new Individual(getURI("mutation" + mutationID))); neg_count++; +// } else { +// posExamples.add(new Individual(getURI("mutation" + mutationID))); pos_count++; +// } + + if((phenotype.toLowerCase().contains("polymorphism")) && (neg_count < negEx)) { + negExamples.add(new Individual(getURI("mutation" + mutationID))); neg_count++; + } + if((!phenotype.toLowerCase().contains("polymorphism")) && (pos_count < posEx)) { + posExamples.add(new Individual(getURI("mutation" + mutationID))); pos_count++; } + + +count++; } // writing conf file Files.clearFile(confFile); String confHeader = "import(\"" + owlFile.getName() + "\");\n\n"; confHeader += "reasoner = fastInstanceChecker;\n"; + + if (algorithmus == 1) { + confHeader += "problem = posNegLPStandard;\n"; + confHeader += "posNegLPStandard.useApproximations = true;\n"; + confHeader += "posNegLPStandard.accuracyMethod = \"fmeasure\";\n"; + confHeader += "posNegLPStandard.approxAccuracy = 0.03;\n"; + confHeader += "refexamples.noisePercentage = 15;\n"; + confHeader += "refexamples.startClass = \"" + getURI("Mutation") + "\";\n"; + confHeader += "refexamples.writeSearchTree = false;\n"; + confHeader += "refexamples.searchTreeFile = \"log/mutation/searchTree.log\";\n"; - confHeader += "problem = classLearning;\n"; - confHeader += "classLearning.classToDescribe = \"" + deleteriousMutationClass + "\";\n"; - confHeader += "classLearning.accuracyMethod = \"fmeasure\";\n"; - confHeader += "classLearning.approxAccuracy = 0.03;\n"; + confHeader += "\n"; + } -// confHeader += "problem = posNegLPStandard;\n"; -// confHeader += "posNegLPStandard.useApproximations = true;\n"; -// confHeader += "posNegLPStandard.accuracyMethod = \"fmeasure\";\n"; -// confHeader += "posNegLPStandard.approxAccuracy = 0.03;\n"; + if (algorithmus == 2) + { + confHeader += "problem = classLearning;\n"; + confHeader += "classLearning.classToDescribe = \"" + deleteriousMutationClass + "\";\n"; + confHeader += "classLearning.accuracyMethod = \"fmeasure\";\n"; + confHeader += "classLearning.approxAccuracy = 0.03;\n"; + confHeader += "algorithm = celoe;\n"; + confHeader += "celoe.maxExecutionTimeInSeconds = 10;\n"; + confHeader += "celoe.noisePercentage = 10;\n"; + confHeader += "celoe.singleSuggestionMode = true;\n"; + confHeader += "celoe.useNegation = true;\n"; + + confHeader += "\n"; + } - confHeader += "algorithm = celoe;\n"; - confHeader += "celoe.maxExecutionTimeInSeconds = 10;\n"; - confHeader += "celoe.noisePercentage = 10;\n"; - confHeader += "celoe.singleSuggestionMode = true;\n"; - confHeader += "celoe.useNegation = true;\n"; - -// confHeader += "refexamples.noisePercentage = 15;\n"; -// confHeader += "refexamples.startClass = \"" + getURI("Mutation") + "\";\n"; -// confHeader += "refexamples.writeSearchTree = false;\n"; -// confHeader += "refexamples.searchTreeFile = \"log/mutation/searchTree.log\";\n"; - confHeader += "\n"; Files.appendFile(confFile, confHeader); if(!generatePosExampleClass) { - Carcinogenesis.appendPosExamples(confFile, posExamples); - Carcinogenesis.appendNegExamples(confFile, negExamples); + MonogenicDiseases.appendPosExamples(confFile, posExamples); + MonogenicDiseases.appendNegExamples(confFile, negExamples); } long runTime = System.nanoTime() - startTime; System.out.println("Conf file written with " + posExamples.size() + " positive and " + negExamples.size() + " negative examples."); System.out.println("Database successfully converted in " + Helper.prettyPrintNanoSeconds(runTime) + "."); + if (writeAlephFiles) System.out.println("Added Aleph Files."); + if (writeYYFiles) System.out.println("Added YinYang Files."); + if (cvAleph) System.out.println("Added Aleph Split Filles for 10-Fold CrossValidation."); + } // a table column with values "+", "=", "-" is converted to subclasses @@ -460,5 +736,27 @@ private static String getURI(String name) { return ontologyURI + "#" + name; + } + + public static void appendPosExamples(File file, List<Individual> examples) { + StringBuffer content = new StringBuffer(); + for(Individual example : examples) { + if(learnMutation) + content.append("+\""+example.toString()+"\"\n"); + else + content.append("-\""+example.toString()+"\"\n"); + } + Files.appendFile(file, content.toString()); + } + + public static void appendNegExamples(File file, List<Individual> examples) { + StringBuffer content = new StringBuffer(); + for(Individual example : examples) { + if(learnMutation) + content.append("-\""+example.toString()+"\"\n"); + else + content.append("+\""+example.toString()+"\"\n"); + } + Files.appendFile(file, content.toString()); } } Added: trunk/components-core/src/main/java/org/dllearner/examples/Parkinsons.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/examples/Parkinsons.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/examples/Parkinsons.java 2010-09-17 10:00:04 UTC (rev 2313) @@ -0,0 +1,416 @@ +package org.dllearner.examples; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Scanner; +import java.util.Set; + +import org.dllearner.core.owl.Axiom; +import org.dllearner.core.owl.ClassAssertionAxiom; +import org.dllearner.core.owl.DatatypeProperty; +import org.dllearner.core.owl.DatatypePropertyAssertion; +import org.dllearner.core.owl.DoubleDatatypePropertyAssertion; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.KB; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.parser.KBParser; +import org.dllearner.parser.ParseException; +import org.dllearner.reasoning.OWLAPIReasoner; +import org.dllearner.utilities.Files; +import org.dllearner.utilities.Helper; +import org.semanticweb.owlapi.model.IRI; + +public class Parkinsons { + + private static IRI ontologyIRI = IRI + .create("http://dl-learner.org/parkinsons"); + private static final String fileName = "test/parkinsons/files/parkinsons.data"; + private static HashMap<String, Integer> patients = new HashMap<String, Integer>(); + private static List<Axiom> axioms = new LinkedList<Axiom>(); + + public static void main(String agrs[]) throws FileNotFoundException, + ParseException { + Scanner input = new Scanner(new File(fileName), "UTF-8"); + File owlFile = new File("test/parkinsons/parkinsons.owl"); + long startTime, duration; + String time; + KB kb = new KB(); + + String kbString = generateDomainAndRangeForObjectProperties(); + KB kb2 = KBParser.parseKBFile(kbString); + kb.addKB(kb2); + + System.out.print("Reading in parkinsons files ... "); + startTime = System.nanoTime(); + + while (input.hasNextLine()) { + String nextLine = input.next(); + + String name = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(name + ",", ""); + + String MDVPFo = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(MDVPFo + ",", ""); + + String MDVPFhi = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(MDVPFhi + ",", ""); + + String MDVPFlo = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(MDVPFlo + ",", ""); + + String MDVPJitter = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(MDVPJitter + ",", ""); + + String MDVPJitterAbs = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(MDVPJitterAbs + ",", ""); + + String MDVPRAP = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(MDVPRAP + ",", ""); + + String MDVPPPQ = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(MDVPPPQ + ",", ""); + + String JitterDDP = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(JitterDDP + ",", ""); + + String MDVPShimmer = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(MDVPShimmer + ",", ""); + + String MDVPShimmerdB = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(MDVPShimmerdB + ",", ""); + + String ShimmerAPQ3 = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(ShimmerAPQ3 + ",", ""); + + String ShimmerAPQ5 = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(ShimmerAPQ5 + ",", ""); + + String MDVPAPQ = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(MDVPAPQ + ",", ""); + + String ShimmerDDA = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(ShimmerDDA + ",", ""); + + String NHR = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(NHR + ",", ""); + + String HNR = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(HNR + ",", ""); + + String status = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(status + ",", ""); + + String RPDE = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(RPDE + ",", ""); + + String DFA = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(DFA + ",", ""); + + String spread1 = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(spread1 + ",", ""); + + String spread2 = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(spread2 + ",", ""); + + String D2 = nextLine.substring(0, nextLine.indexOf(",")); + nextLine = nextLine.replaceFirst(D2 + ",", ""); + + String PPE = nextLine; + + List<Axiom> axioms = mapClauses(name, MDVPFo, MDVPFhi, MDVPFlo, + MDVPJitter, MDVPJitterAbs, MDVPRAP, MDVPPPQ, JitterDDP, + MDVPShimmer, MDVPShimmerdB, ShimmerAPQ3, ShimmerAPQ5, + MDVPAPQ, ShimmerDDA, NHR, HNR, status, RPDE, DFA, spread1, + spread2, D2, PPE); + for (Axiom axiom : axioms) + kb.addAxiom(axiom); + + } + duration = System.nanoTime() - startTime; + time = Helper.prettyPrintNanoSeconds(duration, false, false); + System.out.println("OK (" + time + ")."); + + // writing generated knowledge base + System.out.print("Writing OWL file ... "); + startTime = System.nanoTime(); + OWLAPIReasoner.exportKBToOWL(owlFile, kb, ontologyIRI); + duration = System.nanoTime() - startTime; + time = Helper.prettyPrintNanoSeconds(duration, false, false); + System.out.println("OK (" + time + ")."); + + // generating second conf file + System.out.print("Generating conf file ... "); + File confTrainFile = new File("test/parkinsons/train.conf"); + Files.clearFile(confTrainFile); + generateConfFile(confTrainFile); + generateExamples(confTrainFile); + duration = System.nanoTime() - startTime; + time = Helper.prettyPrintNanoSeconds(duration, false, false); + System.out.println("OK (" + time + ")."); + System.out.println("Finished"); + + } + + private static List<Axiom> mapClauses(String name, String MDVPFo, + String MDVPFhi, String MDVPFlo, String MDVPJitter, + String MDVPJitterAbs, String MDVPRAP, String MDVPPPQ, + String JitterDDP, String MDVPShimmer, String MDVPShimmerdB, + String ShimmerAPQ3, String ShimmerAPQ5, String MDVPAPQ, + String ShimmerDDA, String NHR, String HNR, String status, + String RPDE, String DFA, String spread1, String spread2, String D2, + String PPE) { + ClassAssertionAxiom cmpAxiom = getConceptAssertion("Patient", + name); + axioms.add(cmpAxiom); + + DatatypePropertyAssertion dpa = getDoubleDatatypePropertyAssertion( + name, "hasMDVPFo", Double.parseDouble(MDVPFo)); + axioms.add(dpa); + + DatatypePropertyAssertion dpb = getDoubleDatatypePropertyAssertion( + name, "hasMDVPFhi", Double.parseDouble(MDVPFhi)); + axioms.add(dpb); + + DatatypePropertyAssertion dpc = getDoubleDatatypePropertyAssertion( + name, "hasMDVPFlo", Double.parseDouble(MDVPFlo)); + axioms.add(dpc); + + DatatypePropertyAssertion dpd = getDoubleDatatypePropertyAssertion( + name, "hasMDVPJitter", Double.parseDouble(MDVPJitter)); + axioms.add(dpd); + + DatatypePropertyAssertion dpe = getDoubleDatatypePropertyAssertion( + name, "hasMDVPJitterAbs", Double.parseDouble(MDVPJitterAbs)); + axioms.add(dpe); + + DatatypePropertyAssertion dpf = getDoubleDatatypePropertyAssertion( + name, "hasMDVPRAP", Double.parseDouble(MDVPRAP)); + axioms.add(dpf); + + DatatypePropertyAssertion dpg = getDoubleDatatypePropertyAssertion( + name, "hasMDVPPPQ", Double.parseDouble(MDVPPPQ)); + axioms.add(dpg); + + DatatypePropertyAssertion dph = getDoubleDatatypePropertyAssertion( + name, "hasJitterDDP", Double.parseDouble(JitterDDP)); + axioms.add(dph); + + DatatypePropertyAssertion dpi = getDoubleDatatypePropertyAssertion( + name, "hasMDVPShimmer", Double.parseDouble(MDVPShimmer)); + axioms.add(dpi); + + DatatypePropertyAssertion dpj = getDoubleDatatypePropertyAssertion( + name, "hasMDVPShimmerdB", Double.parseDouble(MDVPShimmerdB)); + axioms.add(dpj); + + DatatypePropertyAssertion dpk = getDoubleDatatypePropertyAssertion( + name, "hasShimmerAPQ3", Double.parseDouble(ShimmerAPQ3)); + axioms.add(dpk); + + DatatypePropertyAssertion dpl = getDoubleDatatypePropertyAssertion( + name, "hasShimmerAPQ5", Double.parseDouble(ShimmerAPQ5)); + axioms.add(dpl); + + DatatypePropertyAssertion dpm = getDoubleDatatypePropertyAssertion( + name, "hasMDVPAPQ", Double.parseDouble(MDVPAPQ)); + axioms.add(dpm); + + DatatypePropertyAssertion dpn = getDoubleDatatypePropertyAssertion( + name, "hasShimmerDDA", Double.parseDouble(ShimmerDDA)); + axioms.add(dpn); + + DatatypePropertyAssertion dpo = getDoubleDatatypePropertyAssertion( + name, "hasNHR", Double.parseDouble(NHR)); + axioms.add(dpo); + + DatatypePropertyAssertion dpp = getDoubleDatatypePropertyAssertion( + name, "hasHNR", Double.parseDouble(HNR)); + axioms.add(dpp); + + DatatypePropertyAssertion dpq = getDoubleDatatypePropertyAssertion( + name, "hasRPDE", Double.parseDouble(RPDE)); + axioms.add(dpq); + + + DatatypePropertyAssertion dpr = getDoubleDatatypePropertyAssertion( + name, "hasDFA", Double.parseDouble(DFA)); + axioms.add(dpr); + + DatatypePropertyAssertion dps = getDoubleDatatypePropertyAssertion( + name, "hasSpread1", Double.parseDouble(spread1)); + axioms.add(dps); + + DatatypePropertyAssertion dpt = getDoubleDatatypePropertyAssertion( + name, "hasSpread2", Double.parseDouble(spread2)); + axioms.add(dpt); + + DatatypePropertyAssertion dpu = getDoubleDatatypePropertyAssertion( + name, "hasD2", Double.parseDouble(D2)); + axioms.add(dpu); + + DatatypePropertyAssertion dpv = getDoubleDatatypePropertyAssertion( + name, "hasPPE", Double.parseDouble(PPE)); + axioms.add(dpv); + + patients.put(name, new Integer(status)); + return axioms; + } + + private static NamedClass getAtomicConcept(String name) { + return new NamedClass(ontologyIRI + "#" + name); + } + + private static ClassAssertionAxiom getConceptAssertion(String concept, + String i) { + Individual ind = getIndividual(i); + NamedClass c = getAtomicConcept(concept); + return new ClassAssertionAxiom(c, ind); + } + + private static Individual getIndividual(String name) { + return new Individual(ontologyIRI + "#" + name); + } + + private static void generateConfFile(File file) { + String confHeader = "import(\"parkinsons.owl\");\n\n"; + confHeader += "reasoner = fastInstanceChecker;\n"; + confHeader += "algorithm = refexamples;\n"; + confHeader += "refexamples.noisePercentage = 0;\n"; + confHeader += "refexamples.startClass = " + getURI2("Patient") + ";\n"; + confHeader += "refexamples.writeSearchTree = false;\n"; + confHeader += "refexamples.searchTreeFile = \"log/parkinsons/searchTree.log\";\n"; + confHeader += "\n"; + Files.appendFile(file, confHeader); + } + + private static void generateExamples(File file) { + StringBuffer content = new StringBuffer(); + Set<String> keys = patients.keySet(); + for (String key : keys) { + Integer subsValue = patients.get(key); + if (subsValue == 0) { + content.append("+\"" + getIndividual(key) + "\"\n"); + } else { + content.append("-\"" + getIndividual(key) + "\"\n"); + } + } + Files.appendFile(file, content.toString()); + } + + private static String getURI(String name) { + return ontologyIRI + "#" + name; + } + + // returns URI including quotationsmark (need for KBparser) + private static String getURI2(String name) { + return "\"" + getURI(name) + "\""; + } + + private static DoubleDatatypePropertyAssertion getDoubleDatatypePropertyAssertion( + String individual, String datatypeProperty, double value) { + Individual ind = getIndividual(individual); + DatatypeProperty dp = getDatatypeProperty(datatypeProperty); + return new DoubleDatatypePropertyAssertion(dp, ind, value); + } + + private static DatatypeProperty getDatatypeProperty(String name) { + return new DatatypeProperty(ontologyIRI + "#" + name); + } + + private static String generateDomainAndRangeForObjectProperties() + throws ParseException { + String kbString = "DPDOMAIN(" + getURI2("hasMDVPFo") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasMDVPFo") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasMDVPFhi") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasMDVPFhi") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasMDVPFlo") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasMDVPFlo") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasMDVPJitter") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasMDVPJitter") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasMDVPJitterAbs") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasMDVPJitterAbs") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasMDVPRAP") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasMDVPRAP") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasMDVPPPQ") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasMDVPPPQ") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasJitterDDP") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasJitterDDP") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasMDVPShimmer") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasMDVPShimmer") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasMDVPShimmerdB") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasMDVPShimmerdB") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasShimmerAPQ3") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasShimmerAPQ3") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasShimmerAPQ5") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasShimmerAPQ5") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasMDVPAPQ") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasMDVPAPQ") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasShimmerDDA") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasShimmerDDA") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasNHR") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasNHR") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasHNR") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasHNR") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasRPDE") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasRPDE") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasDFA") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasDFA") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasSpread1") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasSpread1") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasSpread2") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasSpread2") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasD2") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasD2") + ") = DOUBLE.\n"; + + kbString += "DPDOMAIN(" + getURI2("hasPPE") + ") = " + + getURI2("Patient") + ".\n"; + kbString += "DPRANGE(" + getURI2("hasPPE") + ") = DOUBLE.\n"; + + return kbString; + + } +} Added: trunk/components-core/src/main/java/org/dllearner/examples/flags/FlagScript.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/examples/flags/FlagScript.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/examples/flags/FlagScript.java 2010-09-17 10:00:04 UTC (rev 2313) @@ -0,0 +1,22 @@ +/** + * + */ +package org.dllearner.examples.flags; + +import org.dllearner.examples.flags.Script; + +/** + * @author flo + * + */ +public class FlagScript { + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + Script.createKB(); + } + +} Added: trunk/components-core/src/main/java/org/dllearner/examples/flags/Script.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/examples/flags/Script.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/examples/flags/Script.java 2010-09-17 10:00:04 UTC (rev 2313) @@ -0,0 +1,739 @@ +/** + * + */ +package org.dllearner.examples.flags; + +import org.dllearner.core.OntologyFormat; +import org.dllearner.core.owl.BooleanDatatypePropertyAssertion; +import org.dllearner.core.owl.ClassAssertionAxiom; +import org.dllearner.core.owl.Datatype; +import org.dllearner.core.owl.DatatypeProperty; +import org.dllearner.core.owl.DatatypePropertyDomainAxiom; +import org.dllearner.core.owl.DatatypePropertyRangeAxiom; +import org.dllearner.core.owl.DoubleDatatypePropertyAssertion; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.KB; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.ObjectPropertyAssertion; +import org.dllearner.core.owl.ObjectPropertyDomainAxiom; +import org.dllearner.core.owl.ObjectPropertyRangeAxiom; +import org.dllearner.core.owl.StringDatatypePropertyAssertion; +import org.semanticweb.owlapi.model.*; + + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; + +/** + * @author flo + * + */ +public class Script { + + private static final String flagDataPath = "C:/temp/Uni/Semantic Web Praktikum 10/flag.data"; + //private static final String flagNamesPath = "D:/Dokumente/Uni/Semantic Web Praktikum 10/flag.names"; + private static final String kbOutputPath = "D:/Dokumente/develop/java/eclipseWorkspace/DL-Learner/examples/flags/flag.owl"; + private static final String dataSeparator = ","; + //private static String ontoIri = "http://www.semanticweb.org/owlapi/ontologies/uniLpz/semWeb"; + + /*private static final String ontoFlagClassName = "Flag"; + private static final String ontoCountryClassName = "Country"; + private static String ontoLandmassClassName = "Landmass"; + private static String ontoHemisphereClassName = "Hemisphere"; + private static String ontoLanguageClassName = "Language"; + private static String ontoLanguageGroupClassName = "LanguageGroup"; + private static String ontoReligionClassName = "Religion"; + private static String ontoReligionGroupClassName = "ReligionGroup"; + private static String ontoColorClassName = "Color";*/ + private static final String ontoFlagClassName = "Flag"; + private static final String ontoCountryClassName = ""; + private static String ontoLandmassClassName = ""; + private static String ontoHemisphereClassName = ""; + private static String ontoLanguageClassName = ""; + private static String ontoLanguageGroupClassName = ""; + private static String ontoReligionClassName = ""; + private static String ontoReligionGroupClassName = ""; + private static String ontoColorClassName = ""; + + private static final String iriSeperator = "#"; + + //private static OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + //private static OWLDataFactory factory = manager.getOWLDataFactory(); + + //OWLClass flagClass = factory.getOWLClass(IRI.create(ontoIri + iriSeperator + ontoFlagClassName)); + + private static final KB kb = new KB(); + private static ArrayList<Individual> flags = new ArrayList<Individual>(); + private static ArrayList<Individual> countries = new ArrayList<Individual>(); + + + /*private static NamedClass Flag = new NamedClass(getIRI(ontoFlagClassName)); + private static NamedClass Country = new NamedClass(getIRI(ontoCountryClassName)); + private static NamedClass Landmass = new NamedClass(getIRI(ontoLandmassClassName)); + private static NamedClass Hemisphere = new NamedClass(getIRI(ontoHemisphereClassName)); + private static NamedClass Language = new NamedClass(getIRI(ontoLanguageClassName)); + private static NamedClass LanguageGroup = new NamedClass(getIRI(ontoLanguageGroupClassName)); + private static NamedClass Religion = new NamedClass(getIRI(ontoReligionClassName)); + private static NamedClass ReligionGroup = new NamedClass(getIRI(ontoReligionGroupClassName)); + private static NamedClass Color = new NamedClass(getIRI(ontoColorClassName));*/ + private static NamedClass Flag = new NamedClass(getIRI("Flag")); + private static NamedClass Country = new NamedClass(getIRI("Country")); + private static NamedClass Landmass = new NamedClass(getIRI("Landmass")); + private static NamedClass Hemisphere = new NamedClass(getIRI("Hemisphere")); + private static NamedClass Language = new NamedClass(getIRI("Language")); + private static NamedClass LanguageGroup = new NamedClass(getIRI("LanguageGroup")); + private static NamedClass Religion = new NamedClass(getIRI("Religion")); + private static NamedClass ReligionGroup = new NamedClass(getIRI("ReligionGroup")); + private static NamedClass Color = new NamedClass(getIRI("Color")); + + // Objektbeziehungen + private static ObjectProperty isFlagOf = new ObjectProperty(getIRI("isFlagOf")); + private static ObjectProperty isOnLandmass = new ObjectProperty(getIRI("isOnLandmass")); + private static ObjectProperty isInZone = new ObjectProperty(getIRI("isInZone")); + private static ObjectProperty spokenLanguage = new ObjectProperty(getIRI("spokenLanguage")); + private static ObjectProperty spokenLanguageGroup = new ObjectProperty(getIRI("spokenLanguageGroup")); + private static ObjectProperty hasReligion = new ObjectProperty(getIRI("hasReligion")); + private static ObjectProperty hasReligionGroup = new ObjectProperty(getIRI("hasReligionGroup")); + private static ObjectProperty hasColor = new ObjectProperty(getIRI("hasColor")); + private static ObjectProperty hasPredominationColor = new ObjectProperty(getIRI("hasPredominationColor")); + private static ObjectProperty hasTopleftColor = new ObjectProperty(getIRI("hasTopleftColor")); + private static ObjectProperty hasBottomRightColor = new ObjectProperty(getIRI("hasBottomRightColor")); + + // Objekteigenschaften + private static DatatypeProperty hasName = new DatatypeProperty(getIRI("hasName")); + private static DatatypeProperty hasArea = new DatatypeProperty(getIRI("hasArea")); + private static DatatypeProperty hasPopulation = new DatatypeProperty(getIRI("hasPopulation")); + private static DatatypeProperty numberOfVericalBars = new DatatypeProperty(getIRI("numberOfVericalBars")); + private static DatatypeProperty numberOfHorizontalStripes = new DatatypeProperty(getIRI("numberOfHorizontalStripes")); + private static DatatypeProperty numberOfDifferentColors = new DatatypeProperty(getIRI("numberOfVericalBars")); + private static DatatypeProperty hasColorRed = new DatatypeProperty(getIRI("hasColorRed")); + private static DatatypeProperty hasColorGreen = new DatatypeProperty(getIRI("hasColorGreen")); + private static DatatypeProperty hasColorBlue = new DatatypeProperty(getIRI("hasColorBlue")); + private static DatatypeProperty hasColorGold = new DatatypeProperty(getIRI("hasColorGold")); + private static DatatypeProperty hasColorWhite = new DatatypeProperty(getIRI("hasColorWhite")); + private static DatatypeProperty hasColorBlack = new DatatypeProperty(getIRI("hasColorBlack")); + private static DatatypeProperty hasColorOrange = new DatatypeProperty(getIRI("hasColorOrange")); + private static DatatypeProperty numberOfCircles = new DatatypeProperty(getIRI("numberOfCircles")); + private static DatatypeProperty numberOfUprightCrosses = new DatatypeProperty(getIRI("numberOfUprightCrosses")); + private static DatatypeProperty numberOfDiagonalCrosses = new DatatypeProperty(getIRI("numberOfDiagonalCrosses")); + private static DatatypeProperty numberOfQuarterSections = new DatatypeProperty(getIRI("numberOfQuarterSections")); + private static DatatypeProperty numberOfQuarteredSections = new DatatypeProperty(getIRI("numberOfQuarteredSections")); + private static DatatypeProperty numberOfSunOrStarSymbols = new DatatypeProperty(getIRI("numberOfSunOrStarSymbols")); + private static DatatypeProperty hasCrescentMoonSymbol = new DatatypeProperty(getIRI("hasCrescentMoonSymbol")); + private static DatatypeProperty hasTriangle = new DatatypeProperty(getIRI("hasTriangle")); + private static DatatypeProperty hasImageInanimate = new DatatypeProperty(getIRI("hasImageInanimate")); + private static DatatypeProperty hasImageAnimate = new DatatypeProperty(getIRI("hasImageAnimate")); + private static DatatypeProperty hasText = new DatatypeProperty(getIRI("hasText")); + + private static Individual landmassNorthAmerica = new Individual(getIRI(ontoLandmassClassName + "NorthAmerica")); + private static Individual landmassSouthAmerica = new Individual(getIRI(ontoLandmassClassName + "SouthAmerica")); + private static Individual landmassEurope = new Individual(getIRI(ontoLandmassClassName + "Europe")); + private static Individual landmassAfrica = new Individual(getIRI(ontoLandmassClassName + "Africa")); + private static Individual landmassAsia = new Individual(getIRI(ontoLandmassClassName + "Asia")); + private static Individual landmassOceania = new Individual(getIRI(ontoLandmassClassName + "Oceania")); + + private static Individual hemisphereNorthEast = new Individual(getIRI(ontoHemisphereClassName + "NorthEast")); + private static Individual hemisphereSouthEast = new Individual(getIRI(ontoHemisphereClassName + "SouthEast")); + private static Individual hemisphereSouthWest = new Individual(getIRI(ontoHemisphereClassName + "SouthWest")); + private static Individual hemisphereNorthWest = new Individual(getIRI(ontoHemisphereClassName + "NorthWest")); + + private static Individual languageGroupEnglish = new Individual(getIRI(ontoLanguageGroupClassName + "English")); + private static Individual languageGroupSpanish = new Individual(getIRI(ontoLanguageGroupClassName + "Spanish")); + private static Individual languageGroupFrench = new Individual(getIRI(ontoLanguageGroupClassName + "French")); + private static Individual languageGroupGerman = new Individual(getIRI(ontoLanguageGroupClassName + "German")); + private static Individual languageGroupSlavic = new Individual(getIRI(ontoLanguageGroupClassName + "Slavic")); + private static Individual languageGroupIndoEuropean = new Individual(getIRI(ontoLanguageGroupClassName + "IndoEuropean")); + private static Individual languageGroupChinese = new Individual(getIRI(ontoLanguageGroupClassName + "Chinese")); + private static Individual languageGroupArabic = new Individual(getIRI(ontoLanguageGroupClassName + "Arabic")); + private static Individual languageGroupJapTurkFinnMag = new Individual(getIRI(ontoLanguageGroupClassName + "JapaneseTurkishFinnishMagyar")); + private static Individual languageGroupOthers = new Individual(getIRI(ontoLanguageGroupClassName + "Others")); + + private static Individual religionGroupCatholic = new Individual(getIRI(ontoReligionGroupClassName + "Catholic")); + private static Individual religionGroupOtherChristian = new Individual(getIRI(ontoReligionGroupClassName + "OtherChristian")); + private static Individual religionGroupMuslim = new Individual(getIRI(ontoReligionGroupClassName + "Muslim")); + private static Individual religionGroupBuddhist = new Individual(getIRI(ontoReligionGroupClassName + "Buddhist")); + private static Individual religionGroupHindu = new Individual(getIRI(ontoReligionGroupClassName + "Hindu")); + private static Individual religionGroupEthnic = new Individual(getIRI(ontoReligionGroupClassName + "Ethnic")); + private static Individual religionGroupMarxist = new Individual(getIRI(ontoReligionGroupClassName + "Marxist")); + private static Individual religionGroupOthers = new Individual(getIRI(ontoReligionGroupClassName + "Others")); + + private static Individual colorRed = new Individual(getIRI(ontoColorClassName + "red")); + private static Individual colorGreen = new Individual(getIRI(ontoColorClassName + "green")); + private static Individual colorBlue = new Individual(getIRI(ontoColorClassName + "blue")); + private static Individual colorGold = new Individual(getIRI(ontoColorClassName + "gold")); + private static Individual colorYellow = new Individual(getIRI(ontoColorClassName + "yellow")); + private static Individual colorWhite = new Individual(getIRI(ontoColorClassName + "white")); + private static Individual colorBlack = new Individual(getIRI(ontoColorClassName + "black")); + private static Individual colorOrange = new Individual(getIRI(ontoColorClassName + "orange")); + private static Individual colorBrown = new Individual(getIRI(ontoColorClassName + "brown")); + private static HashMap<String, Individual> newColors = new HashMap<String, Individual>(); + + /** + * @param args + */ + + + // Klassen +// NamedClass Flag = new NamedClass(getIRI(ontoFlagClassName)); +// NamedClass Country = new NamedClass(getIRI(ontoCountryClassName)); +// NamedClass Landmass = new NamedClass(getIRI(ontoLandmassClassName)); +// NamedClass Hemisphere = new NamedClass(getIRI(ontoHemisphereClassName)); +// NamedClass Language = new NamedClass(getIRI(ontoLanguageClassName)); +// NamedClass LanguageGroup = new NamedClass(getIRI(ontoLanguageGroupClassName)); +// NamedClass Religion = new NamedClass(getIRI(ontoReligionClassName)); +// NamedClass ReligionGroup = new NamedClass(getIRI(ontoReligionGroupClassName)); +// NamedClass Color = new NamedClass(getIRI(ontoColorClassName)); + + public static boolean createKB() + { + + // Objektbeziehungen +// ObjectProperty isFlagOf = new ObjectProperty(getIRI("isFlagOf")); + kb.addAxiom(new ObjectPropertyDomainAxiom(isFlagOf, Flag)); + kb.addAxiom(new ObjectPropertyRangeAxiom(isFlagOf, Country)); + +// ObjectProperty isOnLandmass = new ObjectProperty(getIRI("isOnLandmass")); + kb.addAxiom(new ObjectPropertyDomainAxiom(isOnLandmass, Country)); + kb.addAxiom(new ObjectPropertyRangeAxiom(isOnLandmass, Landmass)); + +// ObjectProperty isInZone = new ObjectProperty(getIRI("isInZone")); + kb.addAxiom(new ObjectPropertyDomainAxiom(isInZone, Country)); + kb.addAxiom(new ObjectPropertyRangeAxiom(isInZone, Hemisphere)); + +// ObjectProperty spokenLanguage = new ObjectProperty(getIRI("spokenLanguage")); + kb.addAxiom(new ObjectPropertyDomainAxiom(spokenLanguage, Country)); + kb.addAxiom(new ObjectPropertyRangeAxiom(spokenLanguage, LanguageGroup)); + kb.addAxiom(new ObjectPropertyRangeAxiom(spokenLanguage, Language)); + +// ObjectProperty spokenLanguageGroup = new ObjectProperty(getIRI("spokenLanguageGroup")); + kb.addAxiom(new ObjectPropertyDomainAxiom(spokenLanguageGroup, Country)); + kb.addAxiom(new ObjectPropertyRangeAxiom(spokenLanguageGroup, LanguageGroup)); + +// ObjectProperty hasReligion = new ObjectProperty(getIRI("hasReligion")); + kb.addAxiom(new ObjectPropertyDomainAxiom(hasReligion, Country)); + kb.addAxiom(new ObjectPropertyDomainAxiom(hasReligion, ReligionGroup)); + kb.addAxiom(new ObjectPropertyRangeAxiom(hasReligion, Religion)); + +// ObjectProperty hasReligionGroup = new ObjectProperty(getIRI("hasReligionGroup")); + kb.addAxiom(new ObjectPropertyDomainAxiom(hasReligionGroup, Country)); + kb.addAxiom(new ObjectPropertyRangeAxiom(hasReligionGroup, ReligionGroup)); + +// ObjectProperty hasColor = new ObjectProperty(getIRI("hasColor")); + kb.addAxiom(new ObjectPropertyDomainAxiom(hasColor, Flag)); + kb.addAxiom(new ObjectPropertyRangeAxiom(hasColor, Color)); + +// ObjectProperty hasPredominationColor = new ObjectProperty(getIRI("hasPredominationColor")); + kb.addAxiom(new ObjectPropertyDomainAxiom(hasPredominationColor, Flag)); + kb.addAxiom(new ObjectPropertyRangeAxiom(hasPredominationColor, Color)); + +// ObjectProperty hasTopleftColor = new ObjectProperty(getIRI("hasTopleftColor")); + kb.addAxiom(new ObjectPropertyDomainAxiom(hasTopleftColor, Flag)); + kb.addAxiom(new ObjectPropertyRangeAxiom(hasTopleftColor, Color)); + +// ObjectProperty hasBottomRightColor = new ObjectProperty(getIRI("hasBottomRightColor")); + kb.addAxiom(new ObjectPropertyDomainAxiom(hasBottomRightColor, Flag)); + kb.addAxiom(new ObjectPropertyRangeAxiom(hasBottomRightColor, Color)); + + // Objekteigenschaften +// private static DatatypeProperty hasName = new DatatypeProperty(getIRI("hasName")); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasName, Country)); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasName, Landmass)); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasName, Hemisphere)); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasName, ReligionGroup)); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasName, LanguageGroup)); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasName, Religion)); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasName, Language)); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasName, Color)); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasName, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(hasName, Datatype.STRING)); + +// DatatypeProperty hasArea = new DatatypeProperty(getIRI("hasArea")); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasArea, Country)); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasArea, Landmass)); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasArea, Hemisphere)); + kb.addAxiom(new DatatypePropertyRangeAxiom(hasArea, Datatype.DOUBLE)); + +// DatatypeProperty hasPopulation = new DatatypeProperty(getIRI("hasPopulation")); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasPopulation, Country)); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasPopulation, Landmass)); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasPopulation, Hemisphere)); + kb.addAxiom(new DatatypePropertyRangeAxiom(hasPopulation, Datatype.DOUBLE)); + +// DatatypeProperty numberOfVericalBars = new DatatypeProperty(getIRI("numberOfVericalBars")); + kb.addAxiom(new DatatypePropertyDomainAxiom(numberOfVericalBars, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(numberOfVericalBars, Datatype.DOUBLE)); + +// DatatypeProperty numberOfHorizontalStripes = new DatatypeProperty(getIRI("numberOfHorizontalStripes")); + kb.addAxiom(new DatatypePropertyDomainAxiom(numberOfHorizontalStripes, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(numberOfHorizontalStripes, Datatype.DOUBLE)); + +// DatatypeProperty numberOfDifferentColors = new DatatypeProperty(getIRI("numberOfVericalBars")); + kb.addAxiom(new DatatypePropertyDomainAxiom(numberOfDifferentColors, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(numberOfDifferentColors, Datatype.DOUBLE)); + +// DatatypeProperty hasColorRed = new DatatypeProperty(getIRI("hasColorRed")); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasColorRed, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(hasColorRed, Datatype.BOOLEAN)); + +// DatatypeProperty hasColorGreen = new DatatypeProperty(getIRI("hasColorGreen")); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasColorGreen, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(hasColorGreen, Datatype.BOOLEAN)); + +// DatatypeProperty hasColorBlue = new DatatypeProperty(getIRI("hasColorBlue")); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasColorBlue, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(hasColorBlue, Datatype.BOOLEAN)); + +// DatatypeProperty hasColorGold = new DatatypeProperty(getIRI("hasColorGold")); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasColorGold, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(hasColorGold, Datatype.BOOLEAN)); + +// DatatypeProperty hasColorWhite = new DatatypeProperty(getIRI("hasColorWhite")); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasColorWhite, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(hasColorWhite, Datatype.BOOLEAN)); + +// DatatypeProperty hasColorBlack = new DatatypeProperty(getIRI("hasColorBlack")); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasColorBlack, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(hasColorBlack, Datatype.BOOLEAN)); + +// DatatypeProperty hasColorOrange = new DatatypeProperty(getIRI("hasColorOrange")); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasColorOrange, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(hasColorOrange, Datatype.BOOLEAN)); + +// DatatypeProperty numberOfCircles = new DatatypeProperty(getIRI("numberOfCircles")); + kb.addAxiom(new DatatypePropertyDomainAxiom(numberOfCircles, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(numberOfCircles, Datatype.DOUBLE)); + +// DatatypeProperty numberOfUprightCrosses = new DatatypeProperty(getIRI("numberOfUprightCrosses")); + kb.addAxiom(new DatatypePropertyDomainAxiom(numberOfUprightCrosses, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(numberOfUprightCrosses, Datatype.DOUBLE)); + +// DatatypeProperty numberOfDiagonalCrosses = new DatatypeProperty(getIRI("numberOfDiagonalCrosses")); + kb.addAxiom(new DatatypePropertyDomainAxiom(numberOfDiagonalCrosses, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(numberOfDiagonalCrosses, Datatype.DOUBLE)); + +// DatatypeProperty numberOfQuarterSections = new DatatypeProperty(getIRI("numberOfQuarterSections")); + kb.addAxiom(new DatatypePropertyDomainAxiom(numberOfQuarterSections, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(numberOfQuarterSections, Datatype.DOUBLE)); + +// DatatypeProperty numberOfQuarteredSections = new DatatypeProperty(getIRI("numberOfQuarteredSections")); + kb.addAxiom(new DatatypePropertyDomainAxiom(numberOfQuarteredSections, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(numberOfQuarteredSections, Datatype.DOUBLE)); + +// DatatypeProperty numberOfSunOrStarSymbols = new DatatypeProperty(getIRI("numberOfSunOrStarSymbols")); + kb.addAxiom(new DatatypePropertyDomainAxiom(numberOfSunOrStarSymbols, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(numberOfSunOrStarSymbols, Datatype.DOUBLE)); + +// DatatypeProperty hasCrescentMoonSymbol = new DatatypeProperty(getIRI("hasCrescentMoonSymbol")); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasCrescentMoonSymbol, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(hasCrescentMoonSymbol, Datatype.BOOLEAN)); + +// DatatypeProperty hasTriangle = new DatatypeProperty(getIRI("hasTriangle")); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasTriangle, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(hasTriangle, Datatype.BOOLEAN)); + +// DatatypeProperty hasImageInanimate = new DatatypeProperty(getIRI("hasImageInanimate")); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasImageInanimate, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(hasImageInanimate, Datatype.BOOLEAN)); + +// DatatypeProperty hasImageAnimate = new DatatypeProperty(getIRI("hasImageAnimate")); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasImageAnimate, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(hasImageAnimate, Datatype.BOOLEAN)); + +// DatatypeProperty hasText = new DatatypeProperty(getIRI("hasText")); + kb.addAxiom(new DatatypePropertyDomainAxiom(hasText, Flag)); + kb.addAxiom(new DatatypePropertyRangeAxiom(hasText, Datatype.BOOLEAN)); + + + +// Individual landmassNorthAmerica = new Individual(getIRI(ontoLandmassClassName + "NorthAmerica")); + kb.addAxiom(new ClassAssertionAxiom(Landmass,landmassNorthAmerica)); + kb.addAxiom(new StringDatatypePropertyAssertion(hasName, landmassNorthAmerica, "North America")); +// Individual landmassSouthAmerica = new Individual(getIRI(ontoLandmassClassName + "SouthAmerica")); + kb.addAxiom(new ClassAssertionAxiom(Landmass,landmassSouthAmerica)); + kb.addAxiom(new StringDatatypePropertyAssertion(hasName, landmassNorthAmerica, "South America")); +// Individual landmassEurope = new Individual(getIRI(ontoLandmassClassName + "Europe")); + kb.addAxiom(new ClassAssertionAxiom(Landmass,landmassEurope)); + kb.addAxiom(new StringDatatypePropertyAssertion(hasName, landmassNorthAmerica, "Europe")); +// Individual landmassAfrica = new Individual(getIRI(ontoLandmassClassName + "Africa")); + kb.addAxiom(new ClassAssertionAxiom(Landmass,landmassAfrica)); + kb.addAxiom(new StringDatatypePropertyAssertion(hasName, landmassNorthAmerica, "Africa")); +// Individual landmassAsia = new Individual(getIRI(ontoLandmassClassName + "Asia")); + kb.addAxiom(new ClassAssertionAxiom(Landmass,landmassAsia)); + kb.addAxiom(new StringDatatypePropertyAssertion(hasName, landmassNorthAmerica, "Asia")); +// Individual landmassOceania = new Individual(getIRI(ontoLandmassClassName + "Oceania")); + kb.addAxiom(new ClassAssertionAxiom(Landmass,landmassOceania)); + kb.addAxiom(new StringDatatypePropertyAssertion(hasName, landmassNorthAmerica, "Oceania")); + + +// Individual hemisphereNorthEast = new Individual(getIRI(ontoHemisphereClassName + "NorthEast")); + kb.addAxiom(new ClassAssertionAxiom(Hemisphere,hemisphereNorthEast)); +// Individual hemisphereSouthEast = new Individual(getIRI(ontoHemisphereClassName + "SouthEast")); + kb.addAxiom(new ClassAssertionAxiom(Hemisphere,hemisphereSouthEast)); +// Individual hemisphereSouthWest = new Individual(getIRI(ontoHemisphereClassName... [truncated message content] |