Apache Nutch is an extensible and scalable web crawler
NUTCH-548 - Move URLNormalizer from Outlink to ParseOutputFormat. Contributed by Emmanuel Joke.
Tacettin Guney000ba9534799
diff --git a/CHANGES.txt b/CHANGES.txtindex 2f93ab19f..1844f9642 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -161,6 +161,9 @@ Unreleased changes (1.0-dev)55. NUTCH-547 - Redirection handling: YahooSlurp's algorithm.(dogacan, kubes via dogacan)+56. NUTCH-548 - Move URLNormalizer from Outlink to ParseOutputFormat.+ (Emmanuel Joke via dogacan)+Release 0.9 - 2007-04-021. Changed log4j confiquration to log to stdout on commandlinediff --git a/src/java/org/apache/nutch/parse/Outlink.java b/src/java/org/apache/nutch/parse/Outlink.javaindex 4081ef239..462b8b2e9 100644--- a/src/java/org/apache/nutch/parse/Outlink.java+++ b/src/java/org/apache/nutch/parse/Outlink.java@@ -32,8 +32,8 @@ public class Outlink implements Writable {public Outlink() {}- public Outlink(String toUrl, String anchor, Configuration conf) throws MalformedURLException {- this.toUrl = new URLNormalizers(conf, URLNormalizers.SCOPE_OUTLINK).normalize(toUrl, URLNormalizers.SCOPE_OUTLINK);+ public Outlink(String toUrl, String anchor) throws MalformedURLException {+ this.toUrl = toUrl;if (anchor == null) anchor = "";this.anchor = anchor;}diff --git a/src/java/org/apache/nutch/parse/OutlinkExtractor.java b/src/java/org/apache/nutch/parse/OutlinkExtractor.javaindex cbbc397c3..1e4c93f0d 100644--- a/src/java/org/apache/nutch/parse/OutlinkExtractor.java+++ b/src/java/org/apache/nutch/parse/OutlinkExtractor.java@@ -111,7 +111,7 @@ public class OutlinkExtractor {result = matcher.getMatch();url = result.group(0);try {- outlinks.add(new Outlink(url, anchor, conf));+ outlinks.add(new Outlink(url, anchor));} catch (MalformedURLException mue) {LOG.warn("Invalid url: '" + url + "', skipping.");}diff --git a/src/java/org/apache/nutch/parse/ParseOutputFormat.java b/src/java/org/apache/nutch/parse/ParseOutputFormat.javaindex 69e259f62..221987532 100644--- a/src/java/org/apache/nutch/parse/ParseOutputFormat.java+++ b/src/java/org/apache/nutch/parse/ParseOutputFormat.java@@ -47,8 +47,8 @@ import org.apache.hadoop.util.Progressable;public class ParseOutputFormat implements OutputFormat {private static final Log LOG = LogFactory.getLog(ParseOutputFormat.class);- private URLNormalizers normalizers;private URLFilters filters;+ private URLNormalizers normalizers;private ScoringFilters scfilters;private static class SimpleEntry implements Entry<Text, CrawlDatum> {@@ -82,9 +82,8 @@ public class ParseOutputFormat implements OutputFormat {public RecordWriter getRecordWriter(FileSystem fs, JobConf job,String name, Progressable progress) throws IOException {- this.normalizers = new URLNormalizers(job,- URLNormalizers.SCOPE_OUTLINK);this.filters = new URLFilters(job);+ this.normalizers = new URLNormalizers(job, URLNormalizers.SCOPE_OUTLINK);this.scfilters = new ScoringFilters(job);final int interval = job.getInt("db.fetch.interval.default", 2592000);final boolean ignoreExternalLinks = job.getBoolean("db.ignore.external.links", false);@@ -198,8 +197,8 @@ public class ParseOutputFormat implements OutputFormat {}}try {- // normalizing here is not necessary since outlinks- // are already normalized in Outlink's constructor+ toUrl = normalizers.normalize(toUrl,+ URLNormalizers.SCOPE_OUTLINK); // normalize the urltoUrl = filters.filter(toUrl); // filter the urlif (toUrl == null) {continue;diff --git a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMContentUtils.java b/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMContentUtils.javaindex 0f8d21501..55870dafa 100644--- a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMContentUtils.java+++ b/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMContentUtils.java@@ -403,7 +403,7 @@ public class DOMContentUtils {URL url = (base.toString().indexOf(';') > 0) ?fixEmbeddedParams(base, target) : new URL(base, target);outlinks.add(new Outlink(url.toString(),- linkText.toString().trim(), conf));+ linkText.toString().trim()));} catch (MalformedURLException e) {// don't care}diff --git a/src/plugin/parse-html/src/test/org/apache/nutch/parse/html/TestDOMContentUtils.java b/src/plugin/parse-html/src/test/org/apache/nutch/parse/html/TestDOMContentUtils.javaindex 45a4d99c3..4ecc5f069 100644--- a/src/plugin/parse-html/src/test/org/apache/nutch/parse/html/TestDOMContentUtils.java+++ b/src/plugin/parse-html/src/test/org/apache/nutch/parse/html/TestDOMContentUtils.java@@ -241,55 +241,55 @@ public class TestDOMContentUtils extends TestCase {try {answerOutlinks = new Outlink[][]{{- new Outlink("http://www.nutch.org", "anchor", conf),+ new Outlink("http://www.nutch.org", "anchor"),},{- new Outlink("http://www.nutch.org/", "home", conf),- new Outlink("http://www.nutch.org/docs/bot.html", "bots", conf),+ new Outlink("http://www.nutch.org/", "home"),+ new Outlink("http://www.nutch.org/docs/bot.html", "bots"),},{- new Outlink("http://www.nutch.org/", "separate this", conf),- new Outlink("http://www.nutch.org/docs/ok", "from this", conf),+ new Outlink("http://www.nutch.org/", "separate this"),+ new Outlink("http://www.nutch.org/docs/ok", "from this"),},{- new Outlink("http://www.nutch.org/", "home", conf),- new Outlink("http://www.nutch.org/docs/1", "1", conf),- new Outlink("http://www.nutch.org/docs/2", "2", conf),+ new Outlink("http://www.nutch.org/", "home"),+ new Outlink("http://www.nutch.org/docs/1", "1"),+ new Outlink("http://www.nutch.org/docs/2", "2"),},{- new Outlink("http://www.nutch.org/frames/top.html", "", conf),- new Outlink("http://www.nutch.org/frames/left.html", "", conf),- new Outlink("http://www.nutch.org/frames/invalid.html", "", conf),- new Outlink("http://www.nutch.org/frames/right.html", "", conf),+ new Outlink("http://www.nutch.org/frames/top.html", ""),+ new Outlink("http://www.nutch.org/frames/left.html", ""),+ new Outlink("http://www.nutch.org/frames/invalid.html", ""),+ new Outlink("http://www.nutch.org/frames/right.html", ""),},{- new Outlink("http://www.nutch.org/maps/logo.gif", "", conf),- new Outlink("http://www.nutch.org/index.html", "", conf),- new Outlink("http://www.nutch.org/maps/#bottom", "", conf),- new Outlink("http://www.nutch.org/bot.html", "", conf),- new Outlink("http://www.nutch.org/docs/index.html", "", conf),+ new Outlink("http://www.nutch.org/maps/logo.gif", ""),+ new Outlink("http://www.nutch.org/index.html", ""),+ new Outlink("http://www.nutch.org/maps/#bottom", ""),+ new Outlink("http://www.nutch.org/bot.html", ""),+ new Outlink("http://www.nutch.org/docs/index.html", ""),},{- new Outlink("http://www.nutch.org/index.html", "whitespace test", conf),+ new Outlink("http://www.nutch.org/index.html", "whitespace test"),},{},{- new Outlink("http://www.nutch.org/dummy.jsp", "test2", conf),+ new Outlink("http://www.nutch.org/dummy.jsp", "test2"),},{},{- new Outlink("http://www.nutch.org/;x", "anchor1", conf),- new Outlink("http://www.nutch.org/g;x", "anchor2", conf),- new Outlink("http://www.nutch.org/g;x?y#s", "anchor3", conf)+ new Outlink("http://www.nutch.org/;x", "anchor1"),+ new Outlink("http://www.nutch.org/g;x", "anchor2"),+ new Outlink("http://www.nutch.org/g;x?y#s", "anchor3")},{- new Outlink("http://www.nutch.org/g;something", "anchor1", conf),- new Outlink("http://www.nutch.org/g;something?y#s", "anchor2", conf),- new Outlink("http://www.nutch.org/;something?y=1", "anchor3", conf),- new Outlink("http://www.nutch.org/;something?y=1#s", "anchor4", conf),- new Outlink("http://www.nutch.org/?y=1;somethingelse", "anchor5", conf)+ new Outlink("http://www.nutch.org/g;something", "anchor1"),+ new Outlink("http://www.nutch.org/g;something?y#s", "anchor2"),+ new Outlink("http://www.nutch.org/;something?y=1", "anchor3"),+ new Outlink("http://www.nutch.org/;something?y=1#s", "anchor4"),+ new Outlink("http://www.nutch.org/?y=1;somethingelse", "anchor5")}};diff --git a/src/plugin/parse-js/src/java/org/apache/nutch/parse/js/JSParseFilter.java b/src/plugin/parse-js/src/java/org/apache/nutch/parse/js/JSParseFilter.javaindex 83b36c0b8..9df3cefc4 100644--- a/src/plugin/parse-js/src/java/org/apache/nutch/parse/js/JSParseFilter.java+++ b/src/plugin/parse-js/src/java/org/apache/nutch/parse/js/JSParseFilter.java@@ -236,7 +236,7 @@ public class JSParseFilter implements HtmlParseFilter, Parser {if (LOG.isTraceEnabled()) {LOG.trace(" - outlink from JS: '" + url + "'");}- outlinks.add(new Outlink(url, anchor, getConf()));+ outlinks.add(new Outlink(url, anchor));}} catch (Exception ex) {// if it is a malformed URL we just throw it away and continue with