Re: [Classifier4j-devel] Training and Classifying
Status: Beta
Brought to you by:
nicklothian
From: Nick L. <ni...@ma...> - 2004-05-18 11:48:46
|
Neil Gandhi wrote: >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. > > > The code you have is exactly correct. As previously noted, Classifier4J has been tested with MySQL & HSQLDB. PostgreSQL _should_ work fine with it, provided the JDBC driver supports the database metadata functionality correctly. Is PostgreSQL case sensitive with respect to table names? If so there was a bug we fixed after the 0.5 release that may effect you. Get the latest version from CVS, (or do the change yourself: see <http://cvs.sourceforge.net/viewcvs.py/classifier4j/Classifier4J/src/java/net/sf/classifier4J/bayesian/JDBCWordsDataSource.java?r1=1.13&r2=1.14>) If that doesn't help, can please send the result set returned from the following code: DatabaseMetaData dbm = con.getMetaData(); ResultSet rs = dbm.getTables(null, null, "word_probability", null); Nick |