You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Kevin Jackson <fo...@gmail.com> on 2007/05/01 11:14:11 UTC

Accessing BayesianAnalysisFeeder through Java

Hi all,

We are using James (svn trunk), and we have a tomcat server with a web
UI to our mail stored in postgres.  I'd like to be able to add a
"report spam" button to our web UI that will use the James Bayesian
Analysis Feeder to analyse the mail message.

We have a JSF front end, so adding a button is ok, but I want to know
how to access the feeder directly via Java instead of resending the
message to the server with a X-isSpam = 1.00 type header attached.

If anyone has an idea about how to do this with the James Mailet API
I'd greatly appreciate your input.

Thanks,
Kev

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: Accessing BayesianAnalysisFeeder through Java

Posted by Kevin Jackson <fo...@gmail.com>.
Hi,

> You have to use the JDBCBayesianAnalyzer class.
> It is abstract because you have to implement the logging method.
>
> This is done usually via anonymous classes:
>
> /**
>  * The JDBCBayesianAnalyzer class that does all the work.
>  */
> private JDBCBayesianAnalyzer analyzer = new JDBCBayesianAnalyzer() {
>     protected void delegatedLog(String logString) {
>         log("BayesianAnalysisFeeder: " + logString);
>     }
> };

Ok, this seems reasonable.

>
> If you look at BayesianAnalysisFeeder mailet sources you will see
> exactly how it instantiate the analyzer and how it calls it.
>

Ok, I will check out that code.

> You have to init the sql queries (there is an xml file declaring how the
> needed sql queries look like), then you can call
>                  analyzer.addSpam()+analyzer.updateSpamTokens() or
> analyzer.addHam()+analyzer.updateHamTokens();
>

Based on this, my understanding is that if I write the code using the
JDBCBayesianAnalyzer, then basically I can communicate between my
webapp (mail UI) and James via the database tables.  If this is the
case then that is the perfect way for me to proceed.  I had thought
that I would have to create a new email message and set the header to
X-isSpamProbability=1.00 then send to some random address with the
spam as an attachment, but this way is *much* easier.

Thanks for your help,
Kev

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: Accessing BayesianAnalysisFeeder through Java

Posted by Stefano Bagnara <ap...@bago.org>.
You have to use the JDBCBayesianAnalyzer class.
It is abstract because you have to implement the logging method.

This is done usually via anonymous classes:

/**
 * The JDBCBayesianAnalyzer class that does all the work.
 */
private JDBCBayesianAnalyzer analyzer = new JDBCBayesianAnalyzer() {
    protected void delegatedLog(String logString) {
        log("BayesianAnalysisFeeder: " + logString);
    }
};

If you look at BayesianAnalysisFeeder mailet sources you will see
exactly how it instantiate the analyzer and how it calls it.

You have to init the sql queries (there is an xml file declaring how the
needed sql queries look like), then you can call
                 analyzer.addSpam()+analyzer.updateSpamTokens() or
analyzer.addHam()+analyzer.updateHamTokens();

Stefano

Kevin Jackson ha scritto:
> Hi all,
> 
> We are using James (svn trunk), and we have a tomcat server with a web
> UI to our mail stored in postgres.  I'd like to be able to add a
> "report spam" button to our web UI that will use the James Bayesian
> Analysis Feeder to analyse the mail message.
> 
> We have a JSF front end, so adding a button is ok, but I want to know
> how to access the feeder directly via Java instead of resending the
> message to the server with a X-isSpam = 1.00 type header attached.
> 
> If anyone has an idea about how to do this with the James Mailet API
> I'd greatly appreciate your input.
> 
> Thanks,
> Kev



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org