001    /**
002     * Copyright (C) 2007-2011, Jens Lehmann
003     *
004     * This file is part of DL-Learner.
005     *
006     * DL-Learner is free software; you can redistribute it and/or modify
007     * it under the terms of the GNU General Public License as published by
008     * the Free Software Foundation; either version 3 of the License, or
009     * (at your option) any later version.
010     *
011     * DL-Learner is distributed in the hope that it will be useful,
012     * but WITHOUT ANY WARRANTY; without even the implied warranty of
013     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014     * GNU General Public License for more details.
015     *
016     * You should have received a copy of the GNU General Public License
017     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
018     */
019    
020    package org.dllearner.core.owl;
021    
022    import java.util.HashMap;
023    import java.util.Map;
024    import java.util.SortedSet;
025    import java.util.TreeSet;
026    
027    /**
028     * A flat ABox can be used to store knowledge of a completely dematerialised knowledge base.
029     * 
030     * @author Jens Lehmann
031     *
032     */
033    public class FlatABox {
034        
035        public SortedSet<String> roles = new TreeSet<String>();
036        public SortedSet<String> concepts = new TreeSet<String>();
037        public SortedSet<String> domain = new TreeSet<String>();
038        public SortedSet<String> top = new TreeSet<String>();
039        public SortedSet<String> bottom = new TreeSet<String>();   
040        
041        public Map<String,SortedSet<String>> atomicConceptsPos = new HashMap<String,SortedSet<String>>();
042        public Map<String,SortedSet<String>> atomicConceptsNeg = new HashMap<String,SortedSet<String>>();
043        public Map<String,Map<String,SortedSet<String>>> rolesPos = new HashMap<String,Map<String,SortedSet<String>>>();
044        public Map<String,Map<String,SortedSet<String>>> rolesNeg = new HashMap<String,Map<String,SortedSet<String>>>();
045        
046        public Map<String,SortedSet<String>> exampleConceptsPos = new HashMap<String,SortedSet<String>>();
047        public Map<String,SortedSet<String>> exampleConceptsNeg = new HashMap<String,SortedSet<String>>();
048        
049        public FlatABox() {
050            
051        }
052        
053        public SortedSet<String> getPositiveInstances(String conceptName) {
054            return atomicConceptsPos.get(conceptName);
055        }
056        
057        public SortedSet<String> getNegativeInstances(String conceptName) {
058            return atomicConceptsPos.get(conceptName);
059        }
060        
061            @Override           
062        public String toString() {
063            String output = "";
064            output += "domain: " + domain.toString() + "\n";
065            output += "top: " + top.toString() + "\n";
066            output += "bottom: " + bottom.toString() + "\n";
067            output += "concept pos: " + atomicConceptsPos.toString() + "\n";    
068            output += "concept neg: " + atomicConceptsNeg.toString() + "\n";       
069            output += "role pos: " + rolesPos.toString() + "\n";    
070            output += "role neg: " + rolesNeg.toString() + "\n"; 
071            output += "positive examples: " + exampleConceptsPos.toString() + "\n";
072            output += "negative examples: " + exampleConceptsNeg.toString() + "\n";
073            return output;
074        }
075        
076        public String getTargetConcept() {
077            return (String) exampleConceptsPos.keySet().toArray()[0];
078        }
079        
080    //    public void createExampleABox() {
081    //        domain = new TreeSet<String>();
082    //        domain.add("stefan");
083    //        domain.add("markus");
084    //        
085    //        top = domain;
086    //        bottom = new TreeSet<String>();
087    //        
088    //        atomicConceptsPos = new HashMap<String,Set<String>>();
089    //        Set<String> male = new TreeSet<String>();
090    //        male.add("stefan");
091    //        male.add("markus");
092    //        atomicConceptsPos.put("male",male);
093    //        
094    //        atomicConceptsNeg = new HashMap<String,Set<String>>();
095    //        Set<String> maleNeg = new TreeSet<String>();  
096    //        atomicConceptsNeg.put("male",maleNeg);
097    //        
098    //        rolesPos = new HashMap<String,Map<String,Set<String>>>();
099    //        Map<String,Set<String>> hasChild = new HashMap<String,Set<String>>();
100    //        Set<String> childsStefan = new TreeSet<String>();
101    //        childsStefan.add("markus");
102    //        hasChild.put("stefan",childsStefan);
103    //        Set<String> childsMarkus = new TreeSet<String>();
104    //        hasChild.put("markus", childsMarkus);
105    //        rolesPos.put("hasChild", hasChild);
106    //        
107    //        rolesNeg = new HashMap<String,Map<String,Set<String>>>();
108    //        Map<String,Set<String>> hasChildNeg = new HashMap<String,Set<String>>();
109    //        Set<String> childsStefanNeg = new TreeSet<String>();
110    //        hasChildNeg.put("stefan",childsStefanNeg);
111    //        Set<String> childsMarkusNeg = new TreeSet<String>();
112    //        hasChildNeg.put("markus", childsMarkusNeg);
113    //        rolesNeg.put("hasChild", hasChildNeg);
114    //    }
115        
116        
117    }