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.kb.sparql;
021    
022    import java.util.ArrayList;
023    import java.util.Arrays;
024    import java.util.HashMap;
025    import java.util.HashSet;
026    import java.util.List;
027    import java.util.Map;
028    import java.util.Set;
029    import java.util.SortedSet;
030    import java.util.Stack;
031    import java.util.TreeSet;
032    
033    import org.apache.log4j.Logger;
034    import org.dllearner.algorithms.gp.ADC;
035    import org.dllearner.core.ComponentManager;
036    import org.dllearner.core.owl.DatatypeExactCardinalityRestriction;
037    import org.dllearner.core.owl.DatatypeMaxCardinalityRestriction;
038    import org.dllearner.core.owl.DatatypeMinCardinalityRestriction;
039    import org.dllearner.core.owl.DatatypeProperty;
040    import org.dllearner.core.owl.DatatypeSomeRestriction;
041    import org.dllearner.core.owl.DatatypeValueRestriction;
042    import org.dllearner.core.owl.Description;
043    import org.dllearner.core.owl.DescriptionVisitor;
044    import org.dllearner.core.owl.Individual;
045    import org.dllearner.core.owl.Intersection;
046    import org.dllearner.core.owl.NamedClass;
047    import org.dllearner.core.owl.Negation;
048    import org.dllearner.core.owl.Nothing;
049    import org.dllearner.core.owl.ObjectAllRestriction;
050    import org.dllearner.core.owl.ObjectExactCardinalityRestriction;
051    import org.dllearner.core.owl.ObjectMaxCardinalityRestriction;
052    import org.dllearner.core.owl.ObjectMinCardinalityRestriction;
053    import org.dllearner.core.owl.ObjectOneOf;
054    import org.dllearner.core.owl.ObjectProperty;
055    import org.dllearner.core.owl.ObjectSomeRestriction;
056    import org.dllearner.core.owl.ObjectValueRestriction;
057    import org.dllearner.core.owl.StringValueRestriction;
058    import org.dllearner.core.owl.Thing;
059    import org.dllearner.core.owl.Union;
060    import org.dllearner.parser.KBParser;
061    import org.dllearner.parser.ParseException;
062    
063    /**
064     * Converter from DL-Learner descriptions to a corresponding SPARQL query to get
065     * all instances that are described by this description.
066     * 
067     * @author Sebastian Knappe
068     * @author Sebastian Hellmann
069     * 
070     */
071    public class SparqlQueryDescriptionConvertVisitor implements DescriptionVisitor {
072    
073            
074            private static Logger logger = Logger.getLogger(ComponentManager.class);
075    
076            private int limit = 5;
077            private int offset = -1;
078            private boolean labels = false;
079            private boolean distinct = false;
080            private boolean count = false;
081            private String customFilter = null;
082            
083            
084            private SortedSet<String> transitiveProperties =null;
085            private Map<String,Set<String>> subclassMap = null;
086            
087            private Stack<String> stack = new Stack<String>();
088            private String query = "";
089            private int currentObject = 0;
090            private List<String> foundNamedClasses = new ArrayList<String>();
091            
092            /**
093             * resets internal variables
094             */
095            private void reset(){
096                    currentObject = 0;
097                    stack = new Stack<String>();
098                    stack.push("subject");
099                    query = "";
100                    foundNamedClasses =  new ArrayList<String>() ;
101            }
102            
103            public SparqlQueryDescriptionConvertVisitor() {
104                    stack.push("subject");
105            }
106    
107            /**
108             * @param descriptionKBSyntax description which is parsed and passed to getSparqlQuery( Description description)
109             * @return
110             * @throws ParseException
111             */
112            public String getSparqlQuery( String descriptionKBSyntax) throws ParseException { 
113                    Description description = KBParser.parseConcept(descriptionKBSyntax);
114                    return getSparqlQuery( description);
115            }
116            
117            /**
118             * takes a description and transforms it into SPARQL
119             * @param description
120             * @return
121             */
122            public String getSparqlQuery( Description description) { 
123                    description.accept(this);
124                    expandSubclasses();
125                    String ret =  "";
126                    String customFilterTmp = pointalize(customFilter);
127                    query = pointalize(query);
128                    if(count){
129                            ret = "SELECT  count(distinct(?subject)) as ?count { "+ query + " \n"+customFilterTmp+" \n } " ;
130                    }else{
131                            ret = "SELECT "+distinct()+"?subject "+((labels)?"?label":"")+" { "+labels()+ query + " \n"+customFilterTmp+"\n } " + limit();
132                    }
133                    reset();
134                    return ret;
135            }
136            
137            
138            /**
139             * finalizes the patterns with a point
140             * @param toBePointed
141             * @return
142             */
143            private static String pointalize(String toBePointed){
144                    if(toBePointed==null){
145                            return "";
146                    }
147                    return (toBePointed.trim().endsWith("."))?toBePointed:toBePointed+" . ";
148            }
149            
150            private void expandSubclasses(){
151                    if(subclassMap == null){
152                            return;
153                    }
154                    int counter = 0;
155                    int index = 0;
156                    String var = "";
157                    String uriPattern = "";
158                    StringBuffer tmp ;
159                    StringBuffer filter = new StringBuffer() ;
160                    Set<String> subClasses;
161                    for(String nc: foundNamedClasses){
162                            index = query.indexOf("<"+nc+">");
163                            subClasses = subclassMap.get(nc);
164                            if(index == -1){
165                                    logger.error("named class was found before, but is not in query any more?? "+nc);
166                            }else if(subClasses != null){
167                                    var = "?expanded"+counter;
168                                    uriPattern = "<"+nc+">";
169                                    tmp = new StringBuffer();
170                                    tmp.append(query.substring(0, index));
171                                    tmp.append(var);
172                                    tmp.append(query.substring(index+(uriPattern.length())));
173                                    query = tmp.toString();
174                                    filter.append(makeFilter(var, subClasses, nc));
175                            }else{
176                                    logger.debug("no mapping found ("+nc+")  "+this.getClass().getSimpleName());
177                            }
178                            
179                            counter++;
180                    }
181                    query += filter.toString();
182            }
183            
184            private String makeFilter(String var, Set<String> classes, String superClassUri){
185                    StringBuffer buf = new StringBuffer("\nFILTER ( "+var+" IN ( ");
186                    for (String string : classes) {
187                            buf.append("<"+string+">, ");
188                    }
189                    buf.append("<"+superClassUri+"> ) ). ");
190                    return buf.toString();
191            }
192            
193            private String limit() {
194                    if (limit > 0 && offset > 0){
195                            return " LIMIT " + limit + " OFFSET "+offset+" ";
196                    }else if(limit > 0 ){
197                            return " LIMIT " + limit + " ";
198                    }else {
199                            return "";
200                    }
201            }
202            private String labels() {
203                    return (labels)?"\n?subject rdfs:label ?label . ":"";
204            }
205            private String distinct() {
206                    return (distinct)?"DISTINCT ":"";
207            }
208    
209            /**
210             * @param limit <= 0 means no limit
211             */
212            public void setLimit(int limit) {
213                    this.limit = limit;
214            }
215            
216            public void noLimit() {
217                    this.limit = -1;
218            }
219    
220            /**
221             * also retrieve labels (untested)
222             * 
223             * @param labels
224             */
225            public void setLabels(boolean labels) {
226                    this.labels = labels;
227            }
228    
229            /**
230             * result is distinct
231             * @param distinct
232             */
233            public void setDistinct(boolean distinct) {
234                    this.distinct = distinct;
235            }
236            
237            /**
238             * virtuoso optimisation for transitive properties
239             * @param transitiveProperties
240             */
241            public void setTransitiveProperties(SortedSet<String> transitiveProperties) {
242                    this.transitiveProperties = transitiveProperties;
243            }
244            
245    
246            /**
247             * needed for expanding subclasses, if store does no reasoning
248             * @param subclassMap
249             */
250            public void setSubclassMap(Map<String, Set<String>> subclassMap) {
251                    this.subclassMap = subclassMap;
252            }
253            
254            public void setCount(boolean count) {
255                    this.count = count;
256            }
257            
258            public void setOffset(int offset) {
259                    this.offset = offset;
260            }
261    
262            public void setCustomFilter(String customFilter) {
263                    this.customFilter = customFilter;
264            }
265    
266            public static String getSparqlQuery(String descriptionKBSyntax, int limit, boolean labels, boolean distinct) throws ParseException {
267                    Description d = KBParser.parseConcept(descriptionKBSyntax);
268                    return getSparqlQuery(d, limit, labels, distinct);
269            }
270            
271            public static String getSparqlQuery(Description description, int limit, boolean labels, boolean distinct) {
272                    SparqlQueryDescriptionConvertVisitor visitor = new SparqlQueryDescriptionConvertVisitor();
273                    visitor.setDistinct(distinct);
274                    visitor.setLabels(labels);
275                    visitor.setLimit(limit);
276                    return visitor.getSparqlQuery(description);
277            }
278    
279            /**
280             * COMMENT: write some more includes subclasses, costly function, because
281             * subclasses have to be received first. TODO mentioned method cannot be
282             * found by Javadoc tool conceptRewrite(String descriptionKBSyntax,
283             * SparqlEndpoint se, Cache c, boolean simple)
284             * 
285             * @param descriptionKBSyntax
286             *            @see #getSparqlQuery(Description description, int limit)
287             * @param resultLimit
288             *            @see #getSparqlQuery(Description description, int limit)
289             * @param maxDepth
290             * @throws ParseException
291             */
292            
293            public static String getSparqlQueryIncludingSubclasses(String descriptionKBSyntax, int resultLimit,
294                            SPARQLTasks st, int maxDepth) throws ParseException {
295                    String rewritten = SparqlQueryDescriptionConvertRDFS
296                                    .conceptRewrite(descriptionKBSyntax, st, maxDepth);
297    
298                    return getSparqlQuery(rewritten, resultLimit, false, false);
299    
300            }
301            
302            
303            public static void testHasValue() throws Exception{
304    //               String ttt = "(\"http://dbpedia.org/ontology/Plant\" AND (\"http://dbpedia.org/ontology/kingdom\" hasValue \"http://dbpedia.org/resource/Plantae\" OR EXISTS \"http://dbpedia.org/ontology/family\".\"http://dbpedia.org/ontology/FloweringPlant\"))";
305                     String ttt = "(\"http://dbpedia.org/ontology/Plant\" AND ((\"http://dbpedia.org/ontology/kingdom\" HASVALUE \"http://dbpedia.org/resource/Plantae\") OR EXISTS \"http://dbpedia.org/ontology/family\".\"http://dbpedia.org/ontology/FloweringPlant\"))";
306                     SparqlQueryDescriptionConvertVisitor testVisitor = new SparqlQueryDescriptionConvertVisitor();
307                     String q = testVisitor.getSparqlQuery(ttt);
308                     System.out.println(q);
309                     Description description = KBParser.parseConcept(ttt);
310                     System.out.println(description.toString());
311                     System.out.println(description.toKBSyntaxString());
312                     System.out.println(description.toKBSyntaxString(null,null));
313                     if (true) {
314                            System.exit(0);
315                    }
316                            
317            }
318            public static void testTrans() throws Exception{
319    //               String ttt = "(\"http://dbpedia.org/ontology/Plant\" AND (\"http://dbpedia.org/ontology/kingdom\" hasValue \"http://dbpedia.org/resource/Plantae\" OR EXISTS \"http://dbpedia.org/ontology/family\".\"http://dbpedia.org/ontology/FloweringPlant\"))";
320    //              String ttt = "(\"http://dbpedia.org/ontology/Plant\" AND ((\"http://dbpedia.org/ontology/kingdom\" HASVALUE \"http://dbpedia.org/resource/Plantae\") OR EXISTS \"http://dbpedia.org/ontology/family\".\"http://dbpedia.org/ontology/FloweringPlant\"))";
321                    String ttt = "EXISTS \"http://dbpedia.org/ontology/kingdom\".\"http://dbpedia.org/resource/Plantae\"";
322                    SparqlQueryDescriptionConvertVisitor testVisitor = new SparqlQueryDescriptionConvertVisitor();
323                    testVisitor.setTransitiveProperties(new TreeSet<String>(Arrays.asList(new String[]{"http://dbpedia.org/ontology/kingdom" })));
324                    String q = testVisitor.getSparqlQuery(ttt);
325                    System.out.println(q);
326                    Description description = KBParser.parseConcept(ttt);
327                    System.out.println(description.toString());
328                    System.out.println(description.toKBSyntaxString());
329                    System.out.println(description.toKBSyntaxString(null,null));
330                    if (true) {
331                            System.exit(0);
332                    }
333                    
334            }
335    
336            /**
337             * Used for testing the Sparql Query converter.
338             * 
339             * @param args
340             */
341            public static void main(String[] args) throws Exception{
342                    
343                    try {
344    //                      testTrans();
345                    testHasValue();
346                    
347                    
348                    //SparqlQueryConverter.test();
349                    
350                            SortedSet<String> s = new TreeSet<String>();
351                            HashMap<String, String> result = new HashMap<String, String>();
352                            HashMap<String, String> subclassMap = new HashMap<String, String>();
353                            subclassMap.put("http://nlp2rdf.org/ontology/Sentence","<http://nlp2rdf.org/ontology/Subsentence>");
354                            String conj = "(\"http://dbpedia.org/class/yago/Person100007846\" AND \"http://dbpedia.org/class/yago/Head110162991\")";
355    
356                            s.add("EXISTS \"http://dbpedia.org/property/disambiguates\".TOP");
357                            s.add("EXISTS \"http://dbpedia.org/property/successor\".\"http://dbpedia.org/class/yago/Person100007846\"");
358                            s.add("EXISTS \"http://dbpedia.org/property/successor\"." + conj);
359                            s.add("ALL \"http://dbpedia.org/property/disambiguates\".TOP");
360                            s.add("ALL \"http://dbpedia.org/property/successor\".\"http://dbpedia.org/class/yago/Person100007846\"");
361                            s.add("\"http://dbpedia.org/class/yago/Person100007846\"");
362                            s.add(conj);
363                            s.add("(\"http://dbpedia.org/class/yago/Person100007846\" OR \"http://dbpedia.org/class/yago/Head110162991\")");
364                            s.add("NOT \"http://dbpedia.org/class/yago/Person100007846\"");
365                            s.add("(\"http://dbpedia.org/class/yago/HeadOfState110164747\" AND (\"http://dbpedia.org/class/yago/Negotiator110351874\" AND \"http://dbpedia.org/class/yago/Representative110522035\"))");
366    
367                            s.clear();
368    //                      s.add("(\"http://nlp2rdf.org/ontology/Sentence\" AND (EXISTS \"http://nlp2rdf.org/ontology/syntaxTreeHasPart\".\"http://nachhalt.sfb632.uni-potsdam.de/owl/stts.owl#Pronoun\" AND EXISTS \"http://nlp2rdf.org/ontology/syntaxTreeHasPart\".\"http://nlp2rdf.org/ontology/sentencefinalpunctuation_tag\"))");
369    //                      s.add("(\"http://nlp2rdf.org/ontology/Sentence\" AND (\"http://nlp2rdf.org/ontology/hasLemma\" VALUE \"test\" )");
370    
371                            String prefix = "http://nlp2rdf.org/ontology/";
372                            String test = "(\"Sentence\" AND (EXISTS \"syntaxTreeHasPart\".\"VVPP\" AND EXISTS \"syntaxTreeHasPart\".(\"stts:AuxilliaryVerb\" AND \"hasLemma\" = werden)))";
373    
374                            ObjectProperty stp  = new ObjectProperty(prefix+"syntaxTreeHasPart");
375                            DatatypeProperty dtp = new DatatypeProperty(prefix+"hasLemma");
376                            StringValueRestriction svr = new StringValueRestriction(dtp,"werden" );
377                            Intersection inner = new Intersection(new NamedClass(prefix+"Auxillary"), svr);
378                            Intersection middle = new Intersection(
379                                            new ObjectSomeRestriction(stp, new NamedClass(prefix+"VVPP")),
380                                            new ObjectSomeRestriction(stp, inner));
381                            Intersection outer = new Intersection(
382                                            new NamedClass(prefix+"Sentence"),
383                                            middle
384                                            );
385                            
386                            System.out.println(outer.toKBSyntaxString(null,null));
387                            System.out.println(test);
388    
389                            Map<String, Set<String>> testMap = new HashMap<String, Set<String>>();
390                            testMap.put(prefix+"Sentence", new HashSet<String>(Arrays.asList(new String[]{"whatever","loser"})));
391    //                      s.add(outer.toKBSyntaxString(null,null));
392                            SparqlQueryDescriptionConvertVisitor testVisitor = new SparqlQueryDescriptionConvertVisitor();
393                            testVisitor.setSubclassMap(testMap);
394                            String q = testVisitor.getSparqlQuery(outer.toKBSyntaxString());
395                            System.out.println(q);
396                            if (true) {
397                                    System.exit(0);
398                            }
399    //                      <http://nlp2rdf.org/ontology/sentencefinalpunctuation_tag>
400                            String query = "";
401                            SparqlQueryDescriptionConvertVisitor visit = new SparqlQueryDescriptionConvertVisitor();
402                            visit.setLabels(false);
403                            visit.setDistinct(false);
404    //                      visit.setClassToSubclassesVirtuoso(subclassMap);
405                            
406                            
407                            
408                            for (String kbsyntax : s) {
409                                    query = visit.getSparqlQuery(kbsyntax);
410                                    result.put(kbsyntax, query);
411                            }
412                            System.out.println("************************");
413                            for (String string : result.keySet()) {
414                                    System.out.println("KBSyntayString: " + string);
415                                    System.out.println("Query:\n" + result.get(string));
416                                    System.out.println("************************");
417                            }
418                            System.out.println("Finished");
419                    } catch (ParseException e) {
420                            e.printStackTrace();
421                    }
422            }
423    
424            /*
425             * (non-Javadoc)
426             * 
427             * @see
428             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl
429             * .Negation)
430             */
431            public void visit(Negation description) {
432                    logger.trace("Negation");
433            }
434    
435            /*
436             * (non-Javadoc)
437             * 
438             * @see
439             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl
440             * .ObjectAllRestriction)
441             */
442            public void visit(ObjectAllRestriction description) {
443                    logger.trace("ObjectAllRestriction");
444            }
445    
446            /*
447             * (non-Javadoc)
448             * 
449             * @see
450             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl
451             * .ObjectSomeRestriction)
452             */
453            public void visit(ObjectSomeRestriction description) {
454                    logger.trace("ObjectSomeRestriction");
455                    String option = "";
456                    if(transitiveProperties!= null && transitiveProperties.contains(description.getRole().toString()) ){
457                            option =" OPTION (TRANSITIVE , t_in(?" + stack.peek()+"), t_out(?object" + currentObject + "), T_MIN(0), T_MAX(6), T_DIRECTION 1 , T_NO_CYCLES) ";
458                    }
459                    
460                    if(description.getChild(0) instanceof Thing){
461                            //I removed a point here at the end
462                            query += "\n?" + stack.peek() + " <" + description.getRole() + ">  [] " + option + "  ";
463                    }else{
464                            query += "\n?" + stack.peek() + " <" + description.getRole() + "> ?object" + currentObject + option + " . ";
465                            stack.push("object" + currentObject);
466                            currentObject++;
467                            description.getChild(0).accept(this);
468                            stack.pop();
469                    }
470                    
471                    logger.trace(description.getRole().toString());
472                    logger.trace(description.getChild(0).toString());
473            }
474    
475            /*
476             * (non-Javadoc)
477             * 
478             * @see
479             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl
480             * .Nothing)
481             */
482            public void visit(Nothing description) {
483                    logger.trace("Nothing");
484            }
485    
486            /*
487             * (non-Javadoc)
488             * 
489             * @see
490             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl
491             * .Thing)
492             */
493            public void visit(Thing description) {
494                    logger.trace("Thing");
495    
496            }
497    
498            /*
499             * (non-Javadoc)
500             * 
501             * @see
502             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl
503             * .Intersection)
504             */
505            public void visit(Intersection description) {
506                    if(description.getChild(0) instanceof Thing ){
507                            logger.trace("Intersection with TOP");
508                            description.getChild(1).accept(this);
509                    }else if(description.getChild(1) instanceof Thing ){
510                            logger.trace("Intersection with TOP");
511                            description.getChild(0).accept(this);
512                    }else{
513                            logger.trace("Intersection");
514                            description.getChild(0).accept(this);
515                            query += ". ";
516                            description.getChild(1).accept(this);
517                    }
518            }
519    
520            /*
521             * (non-Javadoc)
522             * 
523             * @see
524             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl
525             * .Union)
526             */
527            public void visit(Union description) {
528    
529                    if(description.getChild(0) instanceof Thing ){
530                            logger.trace("Union with TOP");
531                            description.getChild(1).accept(this);
532                    }else if(description.getChild(1) instanceof Thing ){
533                            logger.trace("Union with TOP");
534                            description.getChild(0).accept(this);
535                    }else{
536                            logger.trace("Union");
537                            query += "{";
538                            description.getChild(0).accept(this);
539                            query += "} UNION {";
540                            description.getChild(1).accept(this);
541                            query += "}";
542                    }
543                    
544                    
545            }
546    
547            /*
548             * (non-Javadoc)
549             * 
550             * @see
551             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl
552             * .ObjectMinCardinalityRestriction)
553             */
554            public void visit(ObjectMinCardinalityRestriction description) {
555                    logger.trace("ObjectMinCardinalityRestriction");
556            }
557    
558            /*
559             * (non-Javadoc)
560             * 
561             * @see
562             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl
563             * .ObjectExactCardinalityRestriction)
564             */
565            public void visit(ObjectExactCardinalityRestriction description) {
566                    logger.trace("ObjectExactCardinalityRestriction");
567            }
568    
569            /*
570             * (non-Javadoc)
571             * 
572             * @see
573             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl
574             * .ObjectMaxCardinalityRestriction)
575             */
576            public void visit(ObjectMaxCardinalityRestriction description) {
577                    logger.trace("ObjectMaxCardinalityRestriction");
578            }
579    
580            /*
581             * (non-Javadoc)
582             * 
583             * @see
584             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl
585             * .ObjectValueRestriction)
586             */
587            public void visit(ObjectValueRestriction description) {
588                    ObjectProperty op = (ObjectProperty) description.getRestrictedPropertyExpression();
589                    Individual ind = description.getIndividual();
590                    query += "\n?" + stack.peek() + " <" + op.getName() + "> <" + ind.getName() + "> ";
591            }
592    
593            /*
594             * (non-Javadoc)
595             * 
596             * @see
597             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl
598             * .DatatypeValueRestriction)
599             */
600            public void visit(DatatypeValueRestriction description) {
601                    logger.trace("DatatypeValueRestriction");
602                    query += "\n?" + stack.peek() + " <" + description.getRestrictedPropertyExpression() + ">  \""+description.getValue().getLiteral()+"\" ";
603            }
604    
605            /*
606             * (non-Javadoc)
607             * 
608             * @see
609             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl
610             * .NamedClass)
611             */
612            public void visit(NamedClass description) {
613                    logger.trace("NamedClass");
614                    query += "\n?" + stack.peek() + " a <" + description.getName() + "> ";
615                    foundNamedClasses.add(description.getName());
616            }
617    
618            /*
619             * (non-Javadoc)
620             * 
621             * @see
622             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.algorithms
623             * .gp.ADC)
624             */
625            public void visit(ADC description) {
626                    logger.trace("ADC");
627            }
628    
629            /*
630             * (non-Javadoc)
631             * 
632             * @see
633             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl
634             * .DatatypeMinCardinalityRestriction)
635             */
636            public void visit(DatatypeMinCardinalityRestriction description) {
637                    logger.trace("DatatypeMinCardinalityRestriction");
638            }
639    
640            /*
641             * (non-Javadoc)
642             * 
643             * @see
644             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl
645             * .DatatypeExactCardinalityRestriction)
646             */
647            public void visit(DatatypeExactCardinalityRestriction description) {
648                    logger.trace("DatatypeExactCardinalityRestriction");
649            }
650    
651            /*
652             * (non-Javadoc)
653             * 
654             * @see
655             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl
656             * .DatatypeMaxCardinalityRestriction)
657             */
658            public void visit(DatatypeMaxCardinalityRestriction description) {
659                    logger.trace("DatatypeMaxCardinalityRestriction");
660            }
661    
662            /*
663             * (non-Javadoc)
664             * 
665             * @see
666             * org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl
667             * .DatatypeSomeRestriction)
668             */
669            public void visit(DatatypeSomeRestriction description) {
670                    logger.trace("DatatypeSomeRestriction");
671            }
672    
673            @Override
674            public void visit(ObjectOneOf description) {
675                    logger.trace("ObjectOneOf");
676                    
677            }
678    
679            
680    
681    }