Serializable
, Cloneable
, Comparable<AbstractTerm>
, Iterable<Term>
, AbstractTerm
Conjunction
, DifferenceExt
, DifferenceInt
, Disjunction
, Image
, IntersectionExt
, IntersectionInt
, Negation
, Product
, SetTensional
, Statement
public abstract class CompoundTerm extends Term implements Iterable<Term>
Modifier and Type | Class | Description |
---|---|---|
static class |
CompoundTerm.ConvRectangle |
|
static class |
CompoundTerm.UnableToCloneException |
Term.TermVisitor
Modifier and Type | Field | Description |
---|---|---|
short |
complexity |
syntactic complexity of the compound, the sum of those of its term plus 1
|
(package private) static Interval |
conceptival |
|
(package private) int |
containedTemporalRelations |
|
(package private) int |
hash |
|
private boolean |
hasIntervals |
Whether contains a variable
|
private boolean |
hasVarDeps |
Whether contains a variable
|
private boolean |
hasVariables |
Whether contains a variable
|
private boolean |
hasVarIndeps |
Whether contains a variable
|
private boolean |
hasVarQueries |
Whether contains a variable
|
private boolean |
normalized |
|
Term[] |
term |
list of (direct) term
|
EmptyTermArray, imagination, index_variable, SELF, SEQ_SPATIAL, SEQ_TEMPORAL, term_indices
Constructor | Description |
---|---|
CompoundTerm(Term[] components) |
subclasses should be sure to call init() in their constructors;
it is not done here to allow subclass constructors to set data before calling init()
|
Modifier and Type | Method | Description |
---|---|---|
static Set<Term> |
addComponentsRecursively(Term t,
Set<Term> components) |
Add all the components of term t into components recursively
|
void |
addTermsTo(Collection<Term> c) |
|
Term |
applySubstitute(Map<Term,Term> subs) |
Recursively apply a substitute to the current CompoundTerm
May return null if the term can not be created
|
CompoundTerm |
applySubstituteToCompound(Map<Term,Term> substitute) |
returns result of applySubstitute, if and only if it's a CompoundTerm.
|
List<Term> |
asTermList() |
|
abstract CompoundTerm |
clone() |
clone method
|
abstract Term |
clone(Term[] replaced) |
Must be Term return type because the type of Term may change with different arguments
|
CompoundTerm |
cloneDeep() |
|
CompoundTerm |
cloneDeepVariables() |
|
Term[] |
cloneTerms(Term... additional) |
Clone the component list
|
static Term[] |
cloneTermsAppend(Term[] original,
Term[] additional) |
Deep clone an array list of terms
|
Term[] |
cloneTermsDeep() |
forced deep clone of terms
|
Term[] |
cloneTermsExcept(boolean requireModification,
Term[] toRemove) |
Cloned array of Terms, except for one or more Terms.
|
List<Term> |
cloneTermsListDeep() |
forced deep clone of terms
|
Term[] |
cloneTermsReplacing(Term from,
Term to) |
|
Term[] |
cloneVariableTermsDeep() |
|
int |
compareTo(AbstractTerm that) |
|
int |
containedTemporalRelations() |
|
boolean |
containsAllTermsOf(Term t) |
Check whether the compound contains all term of another term, or
that term as a whole
|
boolean |
containsTerm(Term t) |
Check whether the compound contains a certain component
Also matches variables, ex: (&&,<a --> b>,<b --> c>) also contains <a --> #1>
|
boolean |
containsTermRecursively(Term target) |
Recursively check if a compound contains a term
|
Map<Term,Integer> |
countTermRecursively(Map<Term,Integer> map) |
Recursively count how often the terms are contained
|
boolean |
equals(Object that) |
Equal terms have identical name, though not necessarily the same
reference.
|
static List<Long> |
extractIntervals(Memory mem,
Term T) |
|
private static void |
ExtractIntervals(Memory mem,
List<Long> ivals,
CompoundTerm comp) |
|
short |
getComplexity() |
report the term's syntactic complexity
|
Set<Term> |
getContainedTerms() |
Gives a set of all contained term, recursively
|
int |
hashCode() |
Produce a hash code for the term
|
boolean |
hasInterval() |
|
boolean |
hasVar() |
Whether this compound term contains any variable term
|
boolean |
hasVarDep() |
|
boolean |
hasVarIndep() |
|
boolean |
hasVarQuery() |
|
protected void |
init(Term[] term) |
call this after changing Term[] contents
|
void |
invalidateName() |
|
boolean |
isCommutative() |
Check if the order of the term matters
|
boolean |
isNormalized() |
|
Iterator<Term> |
iterator() |
|
protected static CharSequence |
makeCompoundName(Symbols.NativeOperator op,
Term... arg) |
default method to make the oldName of a compound term from given fields
|
protected CharSequence |
makeName() |
default method to make the oldName of the current term from existing
fields.
|
CharSequence |
name() |
Reporting the name of the current Term.
|
abstract Symbols.NativeOperator |
operator() |
method to get the operator of the compound
|
List<TermLink> |
prepareComponentLinks() |
Build TermLink templates to constant term and subcomponents
|
static Term |
replaceIntervals(Term T) |
|
private static void |
ReplaceIntervals(CompoundTerm comp) |
|
Term |
setComponent(int index,
Term t,
Memory memory) |
Try to replace a component in a compound at a given index by another one
|
void |
setNormalized(boolean b) |
|
(package private) static void |
shuffle(Term[] ar,
Random randomNumber) |
|
int |
size() |
get the number of term
|
static Term[] |
termArray(Term... t) |
build a component list from terms
|
static List<Term> |
termList(Term... t) |
|
static void |
transformIndependentVariableToDependent(CompoundTerm T) |
|
static CompoundTerm.ConvRectangle |
UpdateConvRectangle(Term[] term) |
forEach, spliterator
finalize, getClass, notify, notifyAll, wait, wait, wait
get, get, getIsSpatial, getTemporalOrder, hasVar, isConstant, isExecutable, isHigherOrderStatement, isSelf, nameInternal, recurseSubtermsContainingVariables, recurseSubtermsContainingVariables, recurseTerms, setName, subjectOrPredicateIsIndependentVar, text, toSortedSet, toSortedSetArray, toString, valid
public final Term[] term
public short complexity
private boolean hasVariables
private boolean hasVarQueries
private boolean hasVarIndeps
private boolean hasVarDeps
private boolean hasIntervals
int containedTemporalRelations
int hash
private boolean normalized
static final Interval conceptival
public CompoundTerm(Term[] components)
public abstract Symbols.NativeOperator operator()
public abstract CompoundTerm clone()
public static CompoundTerm.ConvRectangle UpdateConvRectangle(Term[] term)
protected void init(Term[] term)
public void invalidateName()
public abstract Term clone(Term[] replaced)
public CompoundTerm cloneDeep()
public static void transformIndependentVariableToDependent(CompoundTerm T)
private static void ReplaceIntervals(CompoundTerm comp)
private static void ExtractIntervals(Memory mem, List<Long> ivals, CompoundTerm comp)
public CompoundTerm cloneDeepVariables()
public int containedTemporalRelations()
containedTemporalRelations
in class Term
public static Term[] termArray(Term... t)
protected CharSequence makeName()
public CharSequence name()
Term
name
in interface AbstractTerm
name
in class Term
protected static CharSequence makeCompoundName(Symbols.NativeOperator op, Term... arg)
op
- the term operatorarg
- the list of termpublic short getComplexity()
getComplexity
in class Term
public boolean isCommutative()
commutative CompoundTerms: Sets, Intersections Commutative Statements: Similarity, Equivalence (except the one with a temporal order) Commutative CompoundStatements: Disjunction, Conjunction (except the one with a temporal order)
public final int size()
public Set<Term> getContainedTerms()
public Term[] cloneTerms(Term... additional)
public Term[] cloneTermsExcept(boolean requireModification, Term[] toRemove)
toRemove
- public static Term[] cloneTermsAppend(Term[] original, Term[] additional)
original
- The original component listpublic Term[] cloneTermsDeep()
public Term[] cloneVariableTermsDeep()
public boolean containsTerm(Term t)
containsTerm
in class Term
t
- The component to be checkedpublic boolean containsTermRecursively(Term target)
containsTermRecursively
in class Term
target
- The term to be searchedpublic Map<Term,Integer> countTermRecursively(Map<Term,Integer> map)
countTermRecursively
in class Term
map
- The count map that will be created to count how often each term occurspublic static Set<Term> addComponentsRecursively(Term t, Set<Term> components)
t
- The termcomponents
- The componentspublic boolean containsAllTermsOf(Term t)
t
- The other termpublic Term setComponent(int index, Term t, Memory memory)
index
- The location of replacementt
- The new componentmemory
- Reference to the memorypublic boolean hasVar()
hasVar
in interface AbstractTerm
hasVar
in class Term
public boolean hasVarIndep()
hasVarIndep
in class Term
public boolean hasVarQuery()
hasVarQuery
in class Term
public boolean hasInterval()
hasInterval
in class Term
public Term applySubstitute(Map<Term,Term> subs)
subs
- public CompoundTerm applySubstituteToCompound(Map<Term,Term> substitute)
public List<TermLink> prepareComponentLinks()
The compound type determines the link type; the component type determines whether to build the link.
public final void addTermsTo(Collection<Term> c)
public int hashCode()
Term
public int compareTo(AbstractTerm that)
compareTo
in interface Comparable<AbstractTerm>
compareTo
in class Term
that
- The Term to be compared with the current Termpublic boolean equals(Object that)
Term
public void setNormalized(boolean b)
public boolean isNormalized()
Copyright © 2020 OpenNARS. All rights reserved.