RE: [Classifier4j-devel] Training and Classifying
Status: Beta
Brought to you by:
nicklothian
From: Neil G. <np...@nt...> - 2004-05-18 10:44:02
|
Hi Nick, Thanks for the reply, however there is still a problem. The following outlines how I am trying to access the data I have trained in the "word_probability" table. I wish to classify the String 'contents' against the data in the "word_probability" table: DriverMangerJDBCConnectionManager cm = new DriverMangerJDBCConnectionManager(connString, user, pw); JDBCWordsDataSource wds = new JDBCWordsDataSource(cm); ITokenizer tokenizer = new DefaultTokenizer(); IClassifier classifier = new BayesianClassifier(wds, tokenizer); classifier.classify(contents); I get a system error message saying: net.sf.classifier4J.bayesian.WordsDataSourceException: Problem creating table and Caused by: java.sql.SQLException: ERROR: Relation 'word_probability' already exists It seems as if the JDBCWordsDataSource constructor is always trying to create a table, when I just want to be able to read from the existing table! I am using a Postgres SQL database. I would very much appreciate you providing some code which enables me to read from the "word_probability" table and then use the standard methods to classify an unknown string. Regards Neil > -----Original Message----- > From: cla...@li... [mailto:classifier4j- > dev...@li...] On Behalf Of Nick Lothian > Sent: 18 May 2004 00:11 > To: 'cla...@li...' > Subject: RE: [Classifier4j-devel] Training and Classifying > > > > > Hi Nick, > > > > The problem I am having is as follows: > > > > I wish to classify an unknown article against trained data, > > which is in > > the "word_probability" table. > > > > So, to do this I must use BayesianClassifier as follows: > > > > 1. Create an instance of JDBCWordsDataSource > > 2. Create a new instance of BayesianClassifier, passing the > > JDBCWordsDataSource to the constructor > > 3. Call BayesianClassifier.classify(String) > > > > However, by creating an instance of JDBCWordsDataSource (1), the > > constructor for this method creates a new table. > > ------ which I do not want because I will have to delete the table > > containing all my trained data. > > > > Well that would be bad! > > Fortunatly you are incorrect about the constructor: JDBCWordsDataSource > detects is the table already exists, and if the table does exist it > doesn't > create it - see > <http://classifier4j.sourceforge.net/xref/net/sf/classifier4J/bayesian/J DB > CW > ordsDataSource.html#235> > > (Note that there is a bug in the 0.5 version of Classifer4J here if you > are > using MySQL on Unix - the table names are case sensitive. Get the CVS > version). > > If you are actually seeing this behaviour (the table being dropped) could > you please give more details about the database you are using, etc. > > > > What I want is to be able to retrieve my trained data (in a > > JDBCWordsDataSource??), then classify the new article against > > this data. > > > > How can I do this? I would very much appreciate some sample code. > > > > It sounds like you are on the right track. Let me know if you try this and > it doesn't work. > > Nick > > > ------------------------------------------------------- > This SF.Net email is sponsored by: SourceForge.net Broadband > Sign-up now for SourceForge Broadband and get the fastest > 6.0/768 connection for only $19.95/mo for the first 3 months! > http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click > _______________________________________________ > Classifier4j-devel mailing list > Cla...@li... > https://lists.sourceforge.net/lists/listinfo/classifier4j-devel |