public class KBcache
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
_cacheFileSuffix
The String constant that is the suffix for files of cached assertions.
|
java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>>> |
children
All the cached "child" relations of all transitive relations
meaning the relations between all first arguments and the
transitive closure of second arguments.
|
java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> |
explicitDisjointRelations
Disjoint relations which were explicitly defined in "partition", "disjoint",
"disjointDecomposition" and "exhaustiveDecomposition" expressions
|
java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> |
instances
Parent relations from instances, including those that are
transitive through (instance,instance) relations, such as
subAttribute and subrelation
|
java.util.HashSet<java.lang.String> |
insts
A temporary list of instances built during creation of the
children map, in order to efficiently create the instances map
|
java.util.HashSet<java.lang.String> |
instTransRels
all the transitive relations between instances in the kb
|
KB |
kb |
java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>>> |
parents
All the cached "parent" relations of all transitive relations
meaning the relations between all first arguments and the
transitive closure of second arguments.
|
java.util.HashSet<java.lang.String> |
relations
all the relations in the kb
|
java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>> |
signatures
Relation name keys and argument types with 0th arg always "".
|
java.util.HashSet<java.lang.String> |
transRels
all the transitive relations in the kb
|
java.util.HashMap<java.lang.String,java.lang.Integer> |
valences
The number of arguments to each relation.
|
Constructor and Description |
---|
KBcache(KB kb)
Constructor
|
KBcache(KBcache kbCacheIn,
KB kbIn) |
Modifier and Type | Method and Description |
---|---|
void |
buildCaches()
Main entry point for the class.
|
void |
buildChildren()
For each transitive relation, find its transitive closure.
|
void |
buildDisjointRelationsMap()
build a disjoint-relations-map which were explicitly defined in
"partition", "exhaustiveDecomposition", "disjointDecomposition"
and "disjoint" expressions;
|
void |
buildInstTransRels()
Compile the set of transitive relations that are between instances
|
void |
buildParents()
For each transitive relation, find its transitive closure.
|
void |
buildRelationsSet()
Do a proper search for relations (including Functions), utilizing
the formal definitions, rather than the convention of initial
lower case letter.
|
void |
buildTransitiveRelationsSet()
Do a proper search for relations (including Functions), utilizing
the formal definitions, rather than the convention of initial
lower case letter.
|
static boolean |
checkDisjoint(KB kb,
java.util.HashSet<java.lang.String> typeSet)
check if there are any two types in typeSet are disjoint or not;
|
static boolean |
checkDisjoint(KB kb,
java.lang.String rel1,
java.lang.String rel2)
check if rel1 and rel2 are disjoint
return true if rel1 and rel2 are disjoint; otherwise return false.
|
boolean |
childOfP(java.lang.String rel,
java.lang.String parent,
java.lang.String child)
Find whether the given child has the given parent for the given
transitive relation.
|
static java.util.HashSet<java.lang.String> |
collectArgFromFormulas(int arg,
java.util.ArrayList<Formula> forms)
Get the HashSet of the given arguments from an ArrayList of Formulas.
|
void |
collectDomains()
Build the argument type list for every relation.
|
java.util.HashSet<java.lang.String> |
getChildClasses(java.lang.String cl)
return child classes for the given cl from subclass expressions.
|
java.util.HashSet<java.lang.String> |
getInstancesForType(java.lang.String cl)
Get all instances for the given input class
For example, given the class "Nation", getInstancesForType(Nation)
returns all instances, like "America", "Austria", "Albania", etc.
|
java.util.HashSet<java.lang.String> |
getParentClasses(java.lang.String cl)
return parent classes for the given cl from subclass expressions.
|
java.util.HashSet<java.lang.String> |
getParentClassesOfInstance(java.lang.String cl)
return classes for the given instance cl.
|
void |
inheritDomains()
Find domain and domainSubclass definitions that impact a child
relation.
|
boolean |
isExplicitDisjoint(java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> explicitDisjointRelations,
java.lang.String rel1,
java.lang.String rel2)
return true if rel1 and rel2 are explicitly defined as disjoint
relations; otherwise return false.
|
boolean |
isInstanceOf(java.lang.String i,
java.lang.String c)
Returns true if i is an instance of c, else returns false.
|
static void |
main(java.lang.String[] args) |
boolean |
subAttributeOf(java.lang.String child,
java.lang.String parent)
Find whether the given class is the subAttribute of the given parent class.
|
boolean |
subclassOf(java.lang.String child,
java.lang.String parent)
Find whether the given class has the given parent class.
|
boolean |
transInstOf(java.lang.String child,
java.lang.String parent)
Find whether the given instance has the given parent class.
|
void |
writeCacheFile()
Delete and writes the cache .kif file then call addConstituent() so
that the file can be processed and loaded by the inference engine.
|
public KB kb
public static final java.lang.String _cacheFileSuffix
public java.util.HashSet<java.lang.String> relations
public java.util.HashSet<java.lang.String> transRels
public java.util.HashSet<java.lang.String> instTransRels
public java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>>> parents
public java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> instances
public java.util.HashSet<java.lang.String> insts
public java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>>> children
public java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>> signatures
public java.util.HashMap<java.lang.String,java.lang.Integer> valences
public java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> explicitDisjointRelations
public KBcache(KB kb)
public boolean childOfP(java.lang.String rel, java.lang.String parent, java.lang.String child)
public boolean isInstanceOf(java.lang.String i, java.lang.String c)
i
- A String denoting an instance.c
- A String denoting a Class.public boolean transInstOf(java.lang.String child, java.lang.String parent)
public boolean subclassOf(java.lang.String child, java.lang.String parent)
public boolean subAttributeOf(java.lang.String child, java.lang.String parent)
public void buildDisjointRelationsMap()
public static boolean checkDisjoint(KB kb, java.util.HashSet<java.lang.String> typeSet)
public static boolean checkDisjoint(KB kb, java.lang.String rel1, java.lang.String rel2)
public boolean isExplicitDisjoint(java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> explicitDisjointRelations, java.lang.String rel1, java.lang.String rel2)
public java.util.HashSet<java.lang.String> getParentClasses(java.lang.String cl)
public java.util.HashSet<java.lang.String> getChildClasses(java.lang.String cl)
public java.util.HashSet<java.lang.String> getParentClassesOfInstance(java.lang.String cl)
public java.util.HashSet<java.lang.String> getInstancesForType(java.lang.String cl)
public static java.util.HashSet<java.lang.String> collectArgFromFormulas(int arg, java.util.ArrayList<Formula> forms)
public void buildTransitiveRelationsSet()
public void buildRelationsSet()
public void buildParents()
public void buildChildren()
public void collectDomains()
public void writeCacheFile()
public void inheritDomains()
public void buildInstTransRels()
public void buildCaches()
public static void main(java.lang.String[] args)