// the Object class
Object{
string lemma
list<Object> branches
static Object* obj_pool //points to main obj_pool
read()
Object* find(string)
substitute()
}
Object::read(){
if ( obj = obj_pool->find_match(lemma) !=NULL ){
substitute(obj)
}
for (obj= branches.begin ->end){
obj->read()
}
}
main(){
Object obj_pool; obj_pool.load() // load previously built obj_pool
Object sentence = "man eat meat"
sentence->read()
}
// the sentence object starts out as:
sentence{
br= man' eat' meat'
}
// man' = object in sentence, man = object in main object_pool
// they have the same lemma (man)
man'{ man{
br= eat' meat' br = is person //nouns
} is animal
is human
eat //verbs
work
}
// call sentence->read(), which calls
// man'->read() -> substitute() in person':
// sentence object becomes:
sentence {
br= man' eat' meat'
person'
}
person{ person'{
br= is human br = eat' meat'
is individual }
is someone
is man
}
// now call man'->read():eat'->read()
eat{ eat'{
br=food br= meat'
a meal }
}
//skip eat, assume no change
man'->read():eat'->read():meat'->read()
meat'{ meat{
br= "" br= is food
} is muscle
}
// meat substitutes in food
// this is the state of the sentence object
// after the call to sentence->read()
sentence {
br= man' eat' meat'
person' eat' food'
}
// A call to sentence->read() produces
// the following recursive calls
man'->read()
man'->read():eat'->read()
man'->read():eat'->read():meat'->read()
man'->read():eat'->read():food'->read()
person'->read()
person'->read():eat'->read()
person'->read():eat'->read():meat'->read()
person'->read():eat'->read():food'->read()
//-----------------------------------------------------------------------
// introduce a truth function. Will search sequences in tree
// for matching sequence stored in obj_pool (by definition true)
sentence->truth(&obj_pool)
Object::truth(o_pool*){
for (obj= branches.begin ->end){ //loop over branches
obj1 = o_pool->find_match(obj->lemma)
if ( obj1 ==NULL ) continue
retval= obj->truth(obj1)
if (retval == true) return true
}
return false
}
sentence {
br= man' eat' meat'
person' eat' food'
}
man'{ man{
br= eat' meat' br = is person //nouns
} is animal
is human
eat //verbs
work
}
person'{ person{
br= eat' meat' br= is human
} is individual
is someone
eat food
}
sentence->truth(&obj_pool)
returns true if any of:
- man eat meat
- man eat food
- person eat meat
- person eat food
these sequences are stored in the 'man' or 'person' object in the main object_pool.
"person eat food" is in "person" in the main obj_pool, so sentence(man eat meat) is
found to be true, or -understood-
//----------------------------------------------------------------------------
The substitute() function
sentence {
br= man' eat' meat'
}
man'{ man{
br= eat' meat' br = is person //nouns
} is animal
is human
is carnivore
eat //verbs
work
}
// man substitutes in 'person' into sentence
sentence {
br= man' eat' meat'
person' eat' meat'
}
// person gets its own sequence " eat' meat' " in its branches list
// the two eat' objects are separate instances
// substituting in occurs when the original sentence is not understood
// (stored in obj_pool)
// simplest substitution is top noun in 'man' branches list.
// allows for combinatorial search of nearby concepts.
// more complex substitution algorithms possible
// 2nd order substitution:
sentence {
br= man' eat' meat'
}
man'{ man{
br= eat' meat' br = is person //nouns
} is animal
is human
is carnivore
eat //verbs
work
}
person{ animal{ carnivore{
br= is human br= ... br = ...
is individual eat food eat meat
is someone } }
is man
}
Object::search(Object* obj){
//called as
//man'->search(&man)
for (target_obj= obj->branches.begin ->end){ //loop over man branches
obj1 = obj_pool->find_lemma(target_object->lemma) //find person, animal,... in
// main object pool.
for (obj2= branches.begin ->end){ //loop over man' branches
match( obj1, obj2 ) // returns metric
// carnivore has best match
substitute (best match/highest metric)
}
//sentence becomes:
sentence {
br= man' eat' meat'
carnivore' eat' meat'
}
Generalization
I see the
person: 50
man: 40
human: 10
I speak to
person
someone
individual
man
two generalization objects
G1{ G2{
br = person br= person
man someone
human individual
} man
}
A Generalization is a grouping of two or more words. These groupings form in the sequence tree of the raw words.
For G1, the words "I see the" are the called the root of G1.
When the Generalization is formed, link all object_pool objects (G1=person, man, human) together:
person{ man{ human{
br= ... br= ... br = ...
is man' is person' is person'
is human' is human' is man'
G1' G1' G1'
} } }
A G1 object is made and put in the object_pool. The objects in G1 are all given G1' objects.
The input sentence data is then re read and the object_pool re-accumulated. When an object belonging to G1 is encountered, G1 is combinatorially inserted:
I see person, The man talk becomes:
I see person The man talk
I see G1 The G1 talk
This allows the main G1 object (in object_pool) and all G1' objects (in trees of object_pool objects) to accumulate branches. G1 will accumulate branches from every where its objects appear, not just in the data used to form G1.
New generalizations can then form with G1 as part of the root.