eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'BayesClassifier':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: BayesClassifier


Inheritance:

   Object
   |
   +--TextClassifier
      |
      +--BayesClassifier

Package:
stx:libbasic2
Category:
Collections-Text-Support
Version:
rev: 1.3 date: 2017/01/24 00:06:35
user: cg
file: BayesClassifier.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
cg

Description:


an initial experiment in bayes text classification.
see BayesClassifierTest
This is possibly unfinished and may need more work.


Instance protocol:

text handling
o  classify: string
assume that it is a regular text.
split first into lines...

o  classify: string asCategory: categoryName

o  tokenProbabilityOf: token inCategory: category
Calculate probability that a `token` belongs to a `category`


Examples:


|b| b := BayesClassifier new. 'teach it positive phrases'. b classify:'amazing, awesome movie!! Yeah!!' asCategory: 'positive'. b classify:'Sweet, this is incredibly, amazing, perfect, great!!' asCategory: 'positive'. 'teach it a negative phrase'. b classify:'terrible, shitty thing. Damn. Sucks!!' asCategory: 'negative'. 'teach it a neutral phrase'. b classify:'I dont really know what to make of this.' asCategory: 'neutral'. 'now test it to see that it correctly categorizes a new document'. self assert:(b classify:'awesome, cool, amazing!! Yay.')= 'positive'.

ST/X 7.1.0.0; WebServer 1.663 at exept.de:8081; Sat, 17 Nov 2018 21:16:34 GMT