fusionkit.bayes
Component Bayes


A Bayesian Filter for ColdFusion. Uses a database for corpus with columns (word varchar(255), ham_count int, spam_count int, category)


properties:
methods: classify, cleanWord*, getStopWords, getTokens, init, isStopWord, learn, learnHam, learnSpam, setStopWords
* - private method

classify
numeric classify ( required string string, string category="1" )

Test a string and returns the probability that it is spam

Output: enabled
Parameters:
   string: string, required, string - a string of text
   category: string, optional, category - group name, user id, etc.

cleanWord*
private string cleanWord ( required string word )

Trims and cleans a word from puncuation

Output: enabled
Parameters:
   word: string, required, word

getStopWords
array getStopWords ( )

returns an array of stop words, or words that are ignored by the filter.

Output: supressed

getTokens
array getTokens ( required string string )

returns an array of words/tokens from a string, omits stopwords

Output: supressed
Parameters:
   string: string, required, string - a string of text

init
void init ( datasource="bayes", numeric maxWordLength="255" )

Output: supressed
Parameters:
   datasource: any, optional, datasource
   maxWordLength: numeric, optional, maxWordLength - The size of the longest word. All words that are bigger than this value will be truncated. Make sure this size is not larger than your 'word' database column.

isStopWord
boolean isStopWord ( required string word )

returns true if a word should be ignored because it is too common or short for instance.

Output: supressed
Parameters:
   word: string, required, word

learn
void learn ( required boolean spam, required string string, string category="1" )

Mark a string of text as spam or ham

Output: supressed
Parameters:
   spam: boolean, required, spam - true if spam false if ham
   string: string, required, string - a string of text
   category: string, optional, category - group name, user id, etc.

learnHam
void learnHam ( required string string, string category="1" )

Marks a string of text as ham (not spam)

Output: supressed
Parameters:
   string: string, required, string - a string of text
   category: string, optional, category - group name, user id, etc.

learnSpam
void learnSpam ( required string string, string category="1" )

Marks a string of text as spam

Output: supressed
Parameters:
   string: string, required, string - a string of text
   category: string, optional, category - group name, user id, etc.

setStopWords
void setStopWords ( required array stopWordsArray )

Sets the stopwords list

Output: supressed
Parameters:
   stopWordsArray: array, required, stopWordsArray


Copyright © 2006 Foundeo Inc. - All Rights Reserved. ColdFusion is a trademark of Adobe Systems Incorporated.