Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package it.unibz.krdb.obda.owlrefplatform.core.reformulation;
  
  /*
   * #%L
   * ontop-reformulation-core
   * %%
   * Copyright (C) 2009 - 2014 Free University of Bozen-Bolzano
   * %%
   * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * 
  *      http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * #L%
  */
 
 import java.util.List;
 import java.util.Set;
 
TreeWitness: universal tree witnesses as in the KR 2012 paper each tree witness is deNewLiteralined by its domain, root NewLiterals and a set of \exists R.B concept that generate a tree in the TBox canonical model to embed the tree witness part of the query roots are the NewLiterals that are mapped to the root of that tree the "tree witness part of the query" consists of all atoms in the query with NewLiterals in the tw domain and at least one of the NewLiterals not being a tw root each instance also stores those atoms of the query with all NewLiterals among the tw roots this information is enough to produce the tree witness formula tw_f

Author(s):
Roman Kontchakov
 
 
 public class TreeWitness {
 	private final TermCover terms;
 	
 	private final Set<FunctionrootAtoms// atoms of the query that contain only the roots of the tree witness
 	                            // these atoms must hold true for this tree witness to be realised
 	private final Collection<TreeWitnessGeneratorgens// the \exists R.B concepts that realise the tree witness 
 	                                          // in the canonical model of the TBox
 	
 	private final IntersectionOfConceptSets rootConcepts// store concept for merging tree witnesses
 	
 	private List<List<Function>> twfs;  // tw-formula: disjunction of conjunctions of atoms
 
 	public TreeWitness(Collection<TreeWitnessGeneratorgensTermCover termsSet<FunctionrootAtomsIntersectionOfConceptSets rootConcepts) {
 		this. = gens;
 		this. = terms;
 		this. = rootAtoms;
 		this. = rootConcepts;
 		//this.domain = domain; // new HashSet<NewLiteral>(roots); domain.addAll(nonroots);
 	}
 	
 	void setFormula(List<List<Function>> twfs) {
 		this. = twfs;
 	}
 	
 	public List<List<Function>> getFormula() {
 		return ;
 	}
 	
 		return ;
 	}

Set<NewLiteral> getRoots()

Returns:
set of roots of the tree witness
 
 	public Set<TermgetRoots() {
 		return .;
 	}

boolean isMergeable()

Returns:
true if all root NewLiterals are quantified variables and there is the intersection of root concepts is non-empty
 
 	public boolean isMergeable() {
 		return !.isEmpty();
 	}

Set<NewLiteral> getDomain()

Returns:
the domain (set of NewLiterals) of the tree witness
	public Set<TermgetDomain() {
		return .;
	}
	public TermCover getTerms() {
		return ;
	}

Set<TreeWitnessGenerator> getGenerator()

Returns:
the tree witness generators \exists R.B
		return ;
	}

getSubConcepts

Parameters:
twgs a set of tree witness generators
Returns:
the set of all sub-concepts for all of the tree witness generators
		if (.size() == 1)
		for (TreeWitnessGenerator twg : 
		return all;
	}


Set<Function> getRootAtoms()

Returns:
query atoms with all NewLiterals among the roots of tree witness
	public Set<FunctiongetRootAtoms() {
		return ;
	}

boolean isCompatibleWith(TreeWitness tw1, TreeWitness tw2) tree witnesses are consistent iff their domains intersect on their **common** roots

Parameters:
tw1: a tree witness
Returns:
true if tw1 is compatible with the given tree witness
	public static boolean isCompatible(TreeWitness tw1TreeWitness tw2) {
		Set<TermcommonTerms = new HashSet<Term>(tw1.getDomain());
		commonTerms.retainAll(tw2.getDomain());
		if (!commonTerms.isEmpty()) {
			if (!tw1.getRoots().containsAll(commonTerms) || !tw2.getRoots().containsAll(commonTerms))
				return false;
		}
		return true;
	}
	public String toString() {
		return "tree witness generated by " +  + "\n    with domain " +  + " and root atoms " + ;
	}

TermCover stores the domain and the set of roots of a tree witness implements methods for efficient comparison and hashing

Author(s):
Roman Kontchakov
	public static class TermCover {
		private final Set<Termdomain// terms that are covered by the tree witness
		private final Set<Termroots;   // terms that are mapped onto the root of the tree witness
		public TermCover(Set<TermdomainSet<Termroots) {
			this. = domain;
			this. = roots;
		}
		public Set<TermgetDomain() {
			return ;
		}
		public Set<TermgetRoots() {
			return ;
		}
		public String toString() {
			return "tree witness domain " +  + " with roots " + ;
		}
		public boolean equals(Object obj) {
			if (obj instanceof TermCover) {
				TermCover other = (TermCover)obj;
				return this..equals(other.roots) && 
					   this..equals(other.domain);			
			}
			return false;
		}
		public int hashCode() {
			return .hashCode() ^ .hashCode(); 
		}
	}
New to GrepCode? Check out our FAQ X