001/**
002 * Copyright (C) 2007 - 2016, 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 */
019package org.dllearner.kb.manipulator;
020
021import java.util.LinkedList;
022import java.util.List;
023import java.util.SortedSet;
024
025import org.dllearner.kb.extraction.Node;
026import org.dllearner.utilities.datastructures.RDFNodeTuple;
027import org.dllearner.utilities.owl.OWLVocabulary;
028
029
030public class DBpediaNavigatorFilterRule extends Rule{
031        
032        
033        public DBpediaNavigatorFilterRule(Months month){
034                super(month);
035        }
036        // Set<String> classproperties;
037        
038        @Override
039        public  SortedSet<RDFNodeTuple> applyRule(Node subject, SortedSet<RDFNodeTuple> tuples){
040//              RDFNode clazz = null;
041                RDFNodeTuple typeTuple = null;
042                List<RDFNodeTuple> toRemove= new LinkedList<>();
043                for (RDFNodeTuple tuple : tuples) {
044                                                
045                        if (tuple.a.toString().equals(OWLVocabulary.RDF_TYPE)){
046//                              clazz = tuple.b;
047                                typeTuple = tuple;
048                        }
049                        
050                        if (tuple.a.toString().equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#type") && !(tuple.b.toString().startsWith("http://dbpedia.org/class/yago"))){
051                                toRemove.add(typeTuple);
052                        }
053                        /*if (tuple.a.toString().equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#type") && !(tuple.b.toString().startsWith("http://dbpedia.org/ontology"))){
054                                toRemove.add(typeTuple);
055                        }*/
056                }//end for
057                for (RDFNodeTuple tuple : toRemove)
058                        tuples.remove(tuple);
059                return tuples;
060        }
061
062        @Override
063        public void logJamon(){
064                
065        }
066
067}