class documentation

class pyNiall: (source)

View In Hierarchy

Undocumented

Method __init__ Undocumented
Method cleanup cleanup method to commit all unwritten entries to the database
Method learn learn the words from msg
Method reply learn msg and find a reply to it
Instance Variable cur Undocumented
Instance Variable db Undocumented
Method _addEndRelation adds a relation, that a sentence can end with word
Method _addRelation adds a relation between word1 and word2
Method _createRandomSentence recursive function to create a random sentence
Method _createReply reply to a message
Method _getWordRank rank a word by propabiltity of occurance
Method _rankWord rank a word by length and probability
def __init__(self, dbname): (source)

Undocumented

def cleanup(self): (source)

cleanup method to commit all unwritten entries to the database

def learn(self, msg): (source)

learn the words from msg

learns the new words from msg, and add the new relations between the words.

Parameters
msg:stringthe message
def reply(self, msg): (source)

learn msg and find a reply to it

Parameters
msg:stringthe message

Undocumented

Undocumented

def _addEndRelation(self, word): (source)

adds a relation, that a sentence can end with word

Parameters
word:stringthe word
def _addRelation(self, word1, word2): (source)

adds a relation between word1 and word2

add a relation, that word1 can be followed by word2

Parameters
word1:stringthe first word
word2:stringthe second word
def _createRandomSentence(self, index, sentence, forward=True): (source)

recursive function to create a random sentence

Parameters
index:intdatabase-index of the last/first word
sentence:stringthe sentence so far
forward:boolappend or prepend? forward=True appends to the sentence
def _createReply(self, msg): (source)

reply to a message

use msg to create an appropriate reply. first the function tries to identify the most important word. then it grows the answer forward and backwards around the word

Parameters
msg:stringthe msg to reply to
def _getWordRank(self, word): (source)

rank a word by propabiltity of occurance

Parameters
word:stringthe word
Returns
floatUndocumented
def _rankWord(self, word): (source)

rank a word by length and probability

Parameters
word:stringthe word
Returns
floatUndocumented