System.out.println("Usage: java org.apache.nutch.searcher.Summarizer <textfile> <queryStr>");
return;
}
Configuration conf = NutchConfiguration.create();
Summarizer s = new BasicSummarizer(conf);
//
// Parse the args
//
File textFile = new File(argv[0]);
StringBuffer queryBuf = new StringBuffer();
for (int i = 1; i < argv.length; i++) {
queryBuf.append(argv[i]);
queryBuf.append(" ");
}
//
// Load the text file into a single string.
//
StringBuffer body = new StringBuffer();
BufferedReader in = new BufferedReader(new FileReader(textFile));
try {
System.out.println("About to read " + textFile + " from " + in);
String str = in.readLine();
while (str != null) {
body.append(str);
str = in.readLine();
}
} finally {
in.close();
}
// Convert the query string into a proper Query
Query query = Query.parse(queryBuf.toString(), conf);
System.out.println("Summary: '" + s.getSummary(body.toString(), query) + "'");
}