Command-line access. User may add URLs via a flat text file or the structured DMOZ file. By default, we ignore Adult material (as categorized by DMOZ).
(String argv[])
| 366 | * by DMOZ). |
| 367 | */ |
| 368 | public static void main(String argv[]) throws Exception { |
| 369 | if (argv.length < 1) { |
| 370 | System.err |
| 371 | .println("Usage: DmozParser <dmoz_file> [-subset <subsetDenominator>] [-includeAdultMaterial] [-skew skew] [-snippet] [-topicFile <topic list file>] [-topic <topic> [-topic <topic> [...]]]"); |
| 372 | return; |
| 373 | } |
| 374 | |
| 375 | // |
| 376 | // Parse the command line, figure out what kind of |
| 377 | // URL file we need to load |
| 378 | // |
| 379 | int subsetDenom = 1; |
| 380 | int skew = 0; |
| 381 | String dmozFile = argv[0]; |
| 382 | boolean includeAdult = false; |
| 383 | boolean snippet = false; |
| 384 | Pattern topicPattern = null; |
| 385 | Vector<String> topics = new Vector<String>(); |
| 386 | |
| 387 | Configuration conf = NutchConfiguration.create(); |
| 388 | store = StorageUtils.createWebStore(conf, String.class, WebPage.class); |
| 389 | FileSystem fs = FileSystem.get(conf); |
| 390 | try { |
| 391 | for (int i = 1; i < argv.length; i++) { |
| 392 | if ("-includeAdultMaterial".equals(argv[i])) { |
| 393 | includeAdult = true; |
| 394 | } else if ("-subset".equals(argv[i])) { |
| 395 | subsetDenom = Integer.parseInt(argv[i + 1]); |
| 396 | i++; |
| 397 | } else if ("-topic".equals(argv[i])) { |
| 398 | topics.addElement(argv[i + 1]); |
| 399 | i++; |
| 400 | } else if ("-topicFile".equals(argv[i])) { |
| 401 | addTopicsFromFile(argv[i + 1], topics); |
| 402 | i++; |
| 403 | } else if ("-skew".equals(argv[i])) { |
| 404 | skew = Integer.parseInt(argv[i + 1]); |
| 405 | i++; |
| 406 | } else if ("-snippet".equals(argv[i])) { |
| 407 | snippet = true; |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | DmozParser parser = new DmozParser(); |
| 412 | |
| 413 | if (!topics.isEmpty()) { |
| 414 | String regExp = new String("^("); |
| 415 | int j = 0; |
| 416 | for (; j < topics.size() - 1; ++j) { |
| 417 | regExp = regExp.concat(topics.get(j)); |
| 418 | regExp = regExp.concat("|"); |
| 419 | } |
| 420 | regExp = regExp.concat(topics.get(j)); |
| 421 | regExp = regExp.concat(").*"); |
| 422 | LOG.info("Topic selection pattern = " + regExp); |
| 423 | topicPattern = Pattern.compile(regExp); |
| 424 | } |
| 425 |
nothing calls this directly
no test coverage detected