⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bayesian.java

📁 complete bayesian spam filter (java source code)
💻 JAVA
字号:
/* Daniel Shiffman               *//* Bayesian Spam Filter Example  *//* Programming from A to Z       *//* Spring 2006                   *//* http://www.shiffman.net       *//* daniel.shiffman@nyu.edu       */// Main driver programpackage bayes;import java.io.*;import a2z.*;public class Bayesian {	public static void main (String args[]) {		try {						// Create a new SpamFilter Object			SpamFilter filter = new SpamFilter();						// Train spam with a file of spam e-mails			filter.trainSpam("spam.txt");			// Train spam with a file of regular e-mails			filter.trainGood("good.txt");			// We are finished adding words so finalize the results			filter.finalizeTraining();									for (int i = 1; i < 4; i++) {				// Read in a text file				A2ZFileReader fr = new A2ZFileReader("messages/mail" + i + ".txt");				String stuff = fr.getContent();								// Ask the filter to analyze it				boolean spam = filter.analyze(stuff);								// Print results				if (spam) System.out.println("I do believe this message is spam!");				else System.out.println("I do believe this is a genuine message!");			}					} catch (IOException e) {			e.printStackTrace();		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -