implementation of ssttt in hyperspace for newspaper articles

Thomas Michael Hagen <[email protected]> Tue, 28 Jul 2009 11:54:06 +0200
Newsgroups gmane.mail.spam.crm114
Message-ID <[email protected]>
here's my latest implementation of my newspaper article categorizer.
it seems to be working well, and i've seen a 45% accuracy rate very
early on (after human categorization of a couple hundred articles, and
automated learning of a few thousand, based on urls).

there are nine categories:

con(sumer)
sct(science & technology)

cul(ture)
ent(ertainment)

dom(estic)
for(eign)

eco(nomy)
pol(itics)

spo(rts)

plus two fail-categories:

out, which contains stuff written in the wrong language, sports-,
weather- or stock tables, and empty articles.
unc(ertain), which contains anything not covered above.

:try-to-classify: (:length-and-article:)
{
    { #THE CLASSIFICATION PART:
	output /Classifying...\n/
	match (:: :length: :article:) [:length-and-article:]
/([[:digit:]]+)---___---___---(.*)/
	{
	    {
		match [:length:] /^1$/
		output /The article was empty!\n/
		isolate (:stats:) /Best match is out.chs, pR: 1001  \nTotal/
	    }
	    alius
	    {
		isolate (:stats:)
		classify <hyperspace> [:article:] \
			(con.chs cul.chs dom.chs eco.chs \
			ent.chs for.chs pol.chs sct.chs \
			spo.chs | unc.chs out.chs) (:stats:)
	    } # it doesn't matter whether it succeeds or not, we check the
same things anyway:
	}
	match (:: :class-conc:) [:stats:] /(...)\.chs/
	match (:: :pR:) [:stats:] /Best match.*: (.*)  \nTotal/
	{
	    {
		eval /:@::*:pR: > 0.5:/ #SSTTT
		output /Classified confidently as ':*:class-conc:'\n/
		{
		    {
			match [:class-conc:] /unc/ #if confidently uncertain, jump out and
ask for human feedback
		    }
		    alius
		    {
			return
		    }
		}
	    }
	    alius
	    {
		output /Classification NOT confident! Please classify:\n\n/
	    }#maybe compare low conf answer with the url here, and use it if
they are the same - kind of bad source of confidence, tho
	}
    }
    # THE INTERACTION PART:
    isolate (:interaction:) /:*:class-conc::*:article:/
    call /:interact:/ [:*:interaction:] #asking the user for the right topic
    {
	match [:user-feedback:] /^y$/ #if class-conc was correct
	isolate (:user-feedback:) /:*:class-conc:/
    }
    #THE LEARNING PART:
    isolate (:user-feedback-conc-file:) /:*:user-feedback:.chs/
    learn <hyperspace> (:*:user-feedback-conc-file:) [:article:]
    return
}

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july