package webraveler.plugin; import java.util.*; import webraveler.http.HTTPRequest; import webraveler.http.HTTPResponse; /** * */ public class TextSummaryPlugin extends webraveler.ravel.RavelerPlugin { /* variables */ /*constructors*/ public TextSummaryPlugin () { mimeTypes.add("text/html"); } /*methods*/ public void setDefaultAttributes () { attributes = new Hashtable(); name = "TextSummaryPlugin"; } public boolean initialize () { return true; }//initialize() public HTTPRequest execute (HTTPRequest request, Hashtable attributes) { return request; }//execute() public HTTPResponse execute (HTTPResponse response, Hashtable attributes) { return response; // System.out.println("TextSummary!!!!!!!!!!!!!!!!!!!!!!"); // // /* find "
" tags, and get 15 words from that point. put all the
// * gathered summaries, and put 'em in a vector. at the end of the page,
// * do an InsertAtTop operation with the text in the vector, and return
// * the modified response */
// if (response.htmlPage == null) {
// return response;
// }//if
// Vector paragraphs = response.htmlPage.getParagraphs();
// int count = 0;
// int size = paragraphs.size();
// Vector summaryVec = new Vector();
// while ( count < size ) {
// StringBuffer summaryText = new StringBuffer();
// StringTokenizer tokenizer = new StringTokenizer((String)paragraphs.elementAt(count++)," ");
// int words = 0;
// while ( words++ < 30 && tokenizer.hasMoreTokens()) {
// String token = (String)tokenizer.nextToken();
// token.replaceAll("\t"," ");
// token.replaceAll("\n"," ");
// summaryText.append(token+" ");
// }//while
// summaryVec.add(summaryText);
// }//while
//
// /* insert a summary of the paragraphs in the bottom of the html page */
// count = 0;
// size = summaryVec.size();
// StringBuffer textToInsert = new StringBuffer();
// textToInsert.append("