oneword
index
/usr/home/andreas/laac/oneword.py

        OVERVIEW
 
# Important data structures:
# - Dictionary with words as keys, and lists tuples (amount, framehash) as
#   values
eg. associations['ball'] = { _frameXYZ : 0.45, _frameABC : 0.33, ...} 
 
# - Dictionary with framehashes as keys, and the real frames as values
frameindex[hash1234] = _frameXYZ
 
#Initialization functions
readcorpus()
parseutterances()
 
#Learn Functions:
createsubframes() <-- formerly known as 'abstractions'
associations() <-- formerly known as 'speech'
 
#Print functions
printframe()
printprop()
printsituation()
frametostr() # string representation of a frame, ordered canonically
 
#Demonstration:
done in main() (when running standalone)

 
Modules
       
math
xml.dom.minidom

 
Functions
       
abst(frame)
adultutterances(frame)
return utterances as strings (hacky code)
associate(utterances, meanings, associations, method=0)
compute scoring between words and frames
if the method argument > 0 unrelated frames
will have their associations decreased.
correctassociations(associations, wordcount, meaningcounters)
do some math to correct associatons
derivemeanings(situation, frameindex)
for a given situation, return a list of derived meanings.
elementiterator(tag, frame)
iterator over elements with a specific tag in a frame
framehash(frame)
generate a hash value of a frame, by converting it to a string
representation and hashing that. The conversion is used to do a
"deep" conversion, instead of just comparing object references.
frames(frame)
frametostr(frame, nesting=0, removename=False)
make 'human readable' string of a frame, for both pretty-printing
and finding duplicates.
id(frame)
main()
then read words from stdin and find matching frames
(if this file is not called directly, main() will be ignored).
makehashes(meanings, frameindex)
### Section Auxilary Functions
oneword(xmldoc)
parse corpus and generate derived frames,
parameter: use: xmldoc = minidom.parse("corpus.xml").documentElement
return: a tuple (associations, frameindex)
parseutterances(situation, associations, method='default')
Create a list of single words of all the adult utterances combined,
after stripping unwanted characters. If seperate utterances are needed
change this.  As this is the oneword stage, sentence boundaries are
currently meaningless.
printframe(frame)
printsituation(situation)
print a situation's description, frames and utterances
properties(frame)
updatemeaningcounters(meanings, meaningcounters)
increment count of the occurrences of the meaning-frames.
these will be used to correct scores later on.

 
Data
        argv = ['/usr/local/bin/pydoc', '-w', './oneword.py']
stdin = <open file '<stdin>', mode 'r'>