Apache Nutch is an extensible and scalable web crawler
NUTCH-801 Remove RTF and MP3 parse plugins
Julien Nioche20f24db16576
diff --git a/CHANGES.txt b/CHANGES.txtindex 73e084c13..2a6303e1c 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -2,6 +2,8 @@ Nutch Change LogUnreleased Changes+* NUTCH-801 Remove RTF and MP3 parse plugins (jnioche)+* NUTCH-798 Upgrade to SOLR1.4 and its dependencies (jnioche)* NUTCH-799 SOLRIndexer to commit once all reducers have finished (jnioche)diff --git a/conf/parse-plugins.xml b/conf/parse-plugins.xmlindex 387e0c022..2cf6f0c92 100644--- a/conf/parse-plugins.xml+++ b/conf/parse-plugins.xml@@ -124,13 +124,11 @@</mimeType><mimeType name="text/richtext">- <plugin id="parse-rtf" />- <plugin id="parse-msword" />+ <plugin id="parse-tika" /></mimeType><mimeType name="text/rtf">- <plugin id="parse-rtf" />- <plugin id="parse-msword" />+ <plugin id="parse-tika" /></mimeType><mimeType name="text/sgml">@@ -198,8 +196,6 @@<alias name="parse-html"extension-id="org.apache.nutch.parse.html.HtmlParser" /><alias name="parse-js" extension-id="JSParser" />- <alias name="parse-mp3"- extension-id="org.apache.nutch.parse.mp3.MP3Parser" /><alias name="parse-msexcel"extension-id="org.apache.nutch.parse.msexcel.MSExcelParser" /><alias name="parse-mspowerpoint"@@ -212,10 +208,8 @@extension-id="org.apache.nutch.parse.pdf.PdfParser" /><alias name="parse-rss"extension-id="org.apache.nutch.parse.rss.RSSParser" />- <alias name="feed"- extension-id="org.apache.nutch.parse.feed.FeedParser" />- <alias name="parse-rtf"- extension-id="org.apache.nutch.parse.rtf.RTFParseFactory" />+ <alias name="feed"+ extension-id="org.apache.nutch.parse.feed.FeedParser" /><alias name="parse-swf"extension-id="org.apache.nutch.parse.swf.SWFParser" /><alias name="parse-text"diff --git a/src/plugin/build.xml b/src/plugin/build.xmlindex e5a8a862b..7aa83f6aa 100755--- a/src/plugin/build.xml+++ b/src/plugin/build.xml@@ -52,14 +52,12 @@<ant dir="parse-ext" target="deploy"/><ant dir="parse-html" target="deploy"/><ant dir="parse-js" target="deploy"/>- <!-- <ant dir="parse-mp3" target="deploy"/> --><ant dir="parse-msexcel" target="deploy"/><ant dir="parse-mspowerpoint" target="deploy"/><ant dir="parse-msword" target="deploy"/><ant dir="parse-oo" target="deploy"/><ant dir="parse-pdf" target="deploy"/><ant dir="parse-rss" target="deploy"/>- <!-- <ant dir="parse-rtf" target="deploy"/> --><ant dir="parse-swf" target="deploy"/><ant dir="parse-text" target="deploy"/><ant dir="parse-tika" target="deploy"/>diff --git a/src/plugin/parse-mp3/build.xml b/src/plugin/parse-mp3/build.xmldeleted file mode 100755index 9e13ae503..000000000--- a/src/plugin/parse-mp3/build.xml+++ /dev/null@@ -1,27 +0,0 @@-<?xml version="1.0"?>-<!--- Licensed to the Apache Software Foundation (ASF) under one or more- contributor license agreements. See the NOTICE file distributed with- this work for additional information regarding copyright ownership.- The ASF licenses this file to You under the Apache License, Version 2.0- (the "License"); you may not use this file except in compliance with- the License. You may obtain a copy of the License at-- http://www.apache.org/licenses/LICENSE-2.0-- Unless required by applicable law or agreed to in writing, software- distributed under the License is distributed on an "AS IS" BASIS,- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- See the License for the specific language governing permissions and- limitations under the License.--->-<project name="parse-mp3" default="jar-core">-- <import file="../build-plugin.xml"/>-- <!-- for junit test -->- <mkdir dir="${build.test}/data"/>- <copy file="sample/postgresql-id3v1.mp3" todir="${build.test}/data"/>- <copy file="sample/postgresql-id3v2.mp3" todir="${build.test}/data"/>- <copy file="sample/postgresql-none.mp3" todir="${build.test}/data"/>-</project>diff --git a/src/plugin/parse-mp3/plugin.xml b/src/plugin/parse-mp3/plugin.xmldeleted file mode 100755index dfd90a1bd..000000000--- a/src/plugin/parse-mp3/plugin.xml+++ /dev/null@@ -1,46 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<!--- Licensed to the Apache Software Foundation (ASF) under one or more- contributor license agreements. See the NOTICE file distributed with- this work for additional information regarding copyright ownership.- The ASF licenses this file to You under the Apache License, Version 2.0- (the "License"); you may not use this file except in compliance with- the License. You may obtain a copy of the License at-- http://www.apache.org/licenses/LICENSE-2.0-- Unless required by applicable law or agreed to in writing, software- distributed under the License is distributed on an "AS IS" BASIS,- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- See the License for the specific language governing permissions and- limitations under the License.--->-<plugin- version="1.0.0"- provider-name="nutch.org"- id="parse-mp3"- name="MP3 Parse Plug-in">-- <runtime>- <library name="parse-mp3.jar">- <export name="*"/>- </library>- <library name="jid3lib-0.5.1.jar"/>- </runtime>-- <requires>- <import plugin="nutch-extensionpoints"/>- </requires>-- <extension point="org.apache.nutch.parse.Parser"- id="org.apache.nutch.parse.mp3"- name="MP3Parse">-- <implementation class="org.apache.nutch.parse.mp3.MP3Parser"- id="org.apache.nutch.parse.mp3.MP3Parser">- <parameter name="pathSuffix" value="mp3"/>- <parameter name="contentType" value="audio/mpeg"/>- </implementation>- </extension>--</plugin>diff --git a/src/plugin/parse-mp3/sample/README.txt b/src/plugin/parse-mp3/sample/README.txtdeleted file mode 100644index 037ef6a7e..000000000--- a/src/plugin/parse-mp3/sample/README.txt+++ /dev/null@@ -1,11 +0,0 @@-Andy Hedges--Orginal MP3 from postgreSQL.org--./postgresql-id3v1.mp3: A short MP3 file with ID3v1 tags added with kid3-./postgresql-id3v2.mp3: A short MP3 file with ID3v2 tags added with kid3-./postgresql-none.mp3: A short MP3 file with no ID3 tags of any kind-./test.mp3: A corrupt MP3 file that has been truncated half way through the ID3v2 frames- (not used in any test as yet).--Used for junit test by ./src/test/org/apache/nutch/parse/mp3/TestMP3Parser.javadiff --git a/src/plugin/parse-mp3/sample/postgresql-id3v1.mp3 b/src/plugin/parse-mp3/sample/postgresql-id3v1.mp3deleted file mode 100644index 6d392210b..000000000Binary files a/src/plugin/parse-mp3/sample/postgresql-id3v1.mp3 and /dev/null differdiff --git a/src/plugin/parse-mp3/sample/postgresql-id3v2.mp3 b/src/plugin/parse-mp3/sample/postgresql-id3v2.mp3deleted file mode 100644index 3cbd56ab1..000000000Binary files a/src/plugin/parse-mp3/sample/postgresql-id3v2.mp3 and /dev/null differdiff --git a/src/plugin/parse-mp3/sample/postgresql-none.mp3 b/src/plugin/parse-mp3/sample/postgresql-none.mp3deleted file mode 100644index 8bd983e80..000000000Binary files a/src/plugin/parse-mp3/sample/postgresql-none.mp3 and /dev/null differdiff --git a/src/plugin/parse-mp3/sample/test.mp3 b/src/plugin/parse-mp3/sample/test.mp3deleted file mode 100644index d8ab515a6..000000000Binary files a/src/plugin/parse-mp3/sample/test.mp3 and /dev/null differdiff --git a/src/plugin/parse-mp3/src/java/org/apache/nutch/parse/mp3/MP3Parser.java b/src/plugin/parse-mp3/src/java/org/apache/nutch/parse/mp3/MP3Parser.javadeleted file mode 100644index 40b4ae495..000000000--- a/src/plugin/parse-mp3/src/java/org/apache/nutch/parse/mp3/MP3Parser.java+++ /dev/null@@ -1,152 +0,0 @@-/**- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--package org.apache.nutch.parse.mp3;--// JDK imports-import java.io.File;-import java.io.FileOutputStream;-import java.io.IOException;-import java.net.MalformedURLException;-import java.util.Iterator;--// Java ID3 Tag imports-import org.farng.mp3.MP3File;-import org.farng.mp3.TagException;-import org.farng.mp3.id3.AbstractID3v2;-import org.farng.mp3.id3.AbstractID3v2Frame;-import org.farng.mp3.id3.ID3v1;-import org.farng.mp3.object.AbstractMP3Object;--// Hadoop imports-import org.apache.hadoop.conf.Configuration;--// Nutch imports-import org.apache.nutch.metadata.Metadata;-import org.apache.nutch.parse.ParseData;-import org.apache.nutch.parse.ParseImpl;-import org.apache.nutch.parse.ParseResult;-import org.apache.nutch.parse.ParseStatus;-import org.apache.nutch.parse.Parser;-import org.apache.nutch.protocol.Content;--/**- * A parser for MP3 audio files- *- * @author Andy Hedges- */-public class MP3Parser implements Parser {-- private MetadataCollector metadataCollector;- private Configuration conf;-- public ParseResult getParse(Content content) {-- ParseResult parse = null;- byte[] raw = content.getContent();- File tmp = null;-- try {- tmp = File.createTempFile("nutch", ".mp3");- FileOutputStream fos = new FileOutputStream(tmp);- fos.write(raw);- fos.close();- MP3File mp3 = new MP3File(tmp);-- if (mp3.hasID3v2Tag()) {- parse = getID3v2Parse(mp3, content.getMetadata(), content);- } else if (mp3.hasID3v1Tag()) {- parse = getID3v1Parse(mp3, content.getMetadata(), content);- } else {- return new ParseStatus().getEmptyParseResult(content.getUrl(),- getConf());- }- } catch (IOException e) {- return new ParseStatus().getEmptyParseResult(content.getUrl(),- getConf());- } catch (TagException e) {- return new ParseStatus().getEmptyParseResult(content.getUrl(),- getConf());- } finally {- tmp.delete();- }-- return parse;- }-- private ParseResult getID3v1Parse(MP3File mp3, Metadata contentMeta,- Content content) throws MalformedURLException {-- ID3v1 tag = mp3.getID3v1Tag();- metadataCollector.notifyProperty("TALB-Text", tag.getAlbum());- metadataCollector.notifyProperty("TPE1-Text", tag.getArtist());- metadataCollector.notifyProperty("COMM-Text", tag.getComment());- metadataCollector.notifyProperty("TCON-Text", "(" + tag.getGenre()- + ")");- metadataCollector.notifyProperty("TIT2-Text", tag.getTitle());- metadataCollector.notifyProperty("TYER-Text", tag.getYear());- ParseData parseData = new ParseData(ParseStatus.STATUS_SUCCESS,- metadataCollector.getTitle(), metadataCollector.getOutlinks(),- contentMeta, metadataCollector.getData());- ParseResult parseResult = ParseResult.createParseResult(content- .getUrl(),- new ParseImpl(metadataCollector.getText(), parseData));-- return parseResult;- }-- public ParseResult getID3v2Parse(MP3File mp3, Metadata contentMeta,- Content content) throws IOException {-- AbstractID3v2 tag = mp3.getID3v2Tag();- Iterator it = tag.iterator();- while (it.hasNext()) {- AbstractID3v2Frame frame = (AbstractID3v2Frame) it.next();- String name = frame.getIdentifier().trim();- if (!name.equals("APIC")) {- Iterator itBody = frame.getBody().iterator();- while (itBody.hasNext()) {- AbstractMP3Object mp3Obj = (AbstractMP3Object) itBody- .next();- String bodyName = mp3Obj.getIdentifier();- if (!bodyName.equals("Picture data")) {- String bodyValue = mp3Obj.getValue().toString();- metadataCollector.notifyProperty(name + "-" + bodyName,- bodyValue);- }- }- }- }- ParseData parseData = new ParseData(ParseStatus.STATUS_SUCCESS,- metadataCollector.getTitle(), metadataCollector.getOutlinks(),- contentMeta, metadataCollector.getData());- ParseResult parseResult = ParseResult.createParseResult(content- .getUrl(),- new ParseImpl(metadataCollector.getText(), parseData));-- return parseResult;- }-- public void setConf(Configuration conf) {- this.conf = conf;- this.metadataCollector = new MetadataCollector(conf);- }-- public Configuration getConf() {- return this.conf;- }-}diff --git a/src/plugin/parse-mp3/src/java/org/apache/nutch/parse/mp3/MetadataCollector.java b/src/plugin/parse-mp3/src/java/org/apache/nutch/parse/mp3/MetadataCollector.javadeleted file mode 100644index 7f7aec97d..000000000--- a/src/plugin/parse-mp3/src/java/org/apache/nutch/parse/mp3/MetadataCollector.java+++ /dev/null@@ -1,108 +0,0 @@-/**- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--package org.apache.nutch.parse.mp3;--import org.apache.nutch.parse.Outlink;-import org.apache.hadoop.conf.Configuration;--import java.net.MalformedURLException;-import java.util.ArrayList;-import org.apache.nutch.metadata.Metadata;--/**- * This class allows meta data to be collected and manipulated- * @author Andy Hedges- */-public class MetadataCollector {-- private Metadata metadata = new Metadata();- private String title = null;- private String artist = null;- private String album = null;- private ArrayList<Outlink> links = new ArrayList<Outlink>();- private String text = "";- private Configuration conf;-- public MetadataCollector(Configuration conf) {- this.conf = conf;- }-- public void notifyProperty(String name, String value) throws MalformedURLException {- if (name.equals("TIT2-Text"))- setTitle(value);- if (name.equals("TALB-Text"))- setAlbum(value);- if (name.equals("TPE1-Text"))- setArtist(value);-- if (name.indexOf("URL Link") > -1) {- links.add(new Outlink(value, ""));- } else if (name.indexOf("Text") > -1) {- text += value + "\n";- }-- metadata.set(name, value);- }-- public Metadata getData() {- return metadata;- }-- public Outlink[] getOutlinks() {- return (Outlink[]) links.toArray(new Outlink[links.size()]);- }-- public String getTitle() {- String text = "";- if (title != null) {- text = title;- }- if (album != null) {- if (!text.equals("")) {- text += " - " + album;- } else {- text = album;- }- }- if (artist != null) {- if (!text.equals("")) {- text += " - " + artist;- } else {- text = artist;- }- }- return text;- }-- public void setTitle(String title) {- this.title = title;- }-- public void setArtist(String artist) {- this.artist = artist;- }-- public void setAlbum(String album) {- this.album = album;- }-- public String getText() {- return text;- }--}diff --git a/src/plugin/parse-mp3/src/java/org/apache/nutch/parse/mp3/package.html b/src/plugin/parse-mp3/src/java/org/apache/nutch/parse/mp3/package.htmldeleted file mode 100644index 4879ac217..000000000--- a/src/plugin/parse-mp3/src/java/org/apache/nutch/parse/mp3/package.html+++ /dev/null@@ -1,5 +0,0 @@-<html>-<body>-<p>A MP3 parsing plugin.</p><p></p>-</body>-</html>diff --git a/src/plugin/parse-mp3/src/test/org/apache/nutch/parse/mp3/TestMP3Parser.java b/src/plugin/parse-mp3/src/test/org/apache/nutch/parse/mp3/TestMP3Parser.javadeleted file mode 100644index 0e4cc7056..000000000--- a/src/plugin/parse-mp3/src/test/org/apache/nutch/parse/mp3/TestMP3Parser.java+++ /dev/null@@ -1,140 +0,0 @@-/**- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--package org.apache.nutch.parse.mp3;--import org.apache.hadoop.conf.Configuration;-import org.apache.hadoop.io.Text;-import org.apache.nutch.crawl.CrawlDatum;-import org.apache.nutch.metadata.Metadata;-import org.apache.nutch.parse.Parse;-import org.apache.nutch.parse.ParseException;-import org.apache.nutch.parse.ParseUtil;-import org.apache.nutch.protocol.Content;-import org.apache.nutch.protocol.Protocol;-import org.apache.nutch.protocol.ProtocolException;-import org.apache.nutch.protocol.ProtocolFactory;-import org.apache.nutch.util.NutchConfiguration;--import junit.framework.TestCase;--/**- * Unit tests for TestMP3Parser. (Adapted from John Xing msword unit tests).- *- * @author Andy Hedges- */-public class TestMP3Parser extends TestCase {-- private String fileSeparator = System.getProperty("file.separator");- // This system property is defined in ./src/plugin/build-plugin.xml- private String sampleDir = System.getProperty("test.data", ".");- // Make sure sample files are copied to "test.data" as specified in- // ./src/plugin/parse-mp3/build.xml during plugin compilation.- // Check ./src/plugin/parse-mp3/sample/README.txt for what they are.- private String id3v1 = "postgresql-id3v1.mp3";- private String id3v2 = "postgresql-id3v2.mp3";- private String none = "postgresql-none.mp3";-- public TestMP3Parser(String name) {- super(name);- }-- protected void setUp() {- }-- protected void tearDown() {- }-- public void testId3v2() throws ProtocolException, ParseException {-- String urlString;- Protocol protocol;- Content content;- Parse parse;-- Configuration conf = NutchConfiguration.create();- urlString = "file:" + sampleDir + fileSeparator + id3v2;- protocol = new ProtocolFactory(conf).getProtocol(urlString);- content = protocol.getProtocolOutput(new Text(urlString), new CrawlDatum())- .getContent();- parse = new ParseUtil(conf).parseByExtensionId("parse-mp3", content).get(urlString);- Metadata metadata = parse.getData().getParseMeta();- assertEquals("postgresql comment id3v2", metadata.get("COMM-Text"));- assertEquals("postgresql composer id3v2", metadata.get("TCOM-Text"));- assertEquals("02", metadata.get("TRCK-Text"));- assertEquals("http://localhost/", metadata.get("WCOP-URL Link"));- assertEquals("postgresql artist id3v2", metadata.get("TPE1-Text"));- assertEquals("(28)", metadata.get("TCON-Text"));- assertEquals("2004", metadata.get("TYER-Text"));- assertEquals("postgresql title id3v2", metadata.get("TIT2-Text"));- assertEquals("postgresql album id3v2", metadata.get("TALB-Text"));- assertEquals("postgresql encoded by id3v2", metadata.get("TENC-Text"));-- assertEquals("postgresql title id3v2 - "- + "postgresql album id3v2 - "- + "postgresql artist id3v2", parse.getData().getTitle());- assertEquals("http://localhost/", parse.getData().getOutlinks()[0].getToUrl());-- }-- public void testId3v1() throws ProtocolException, ParseException {-- String urlString;- Protocol protocol;- Content content;- Parse parse;-- Configuration conf = NutchConfiguration.create();- urlString = "file:" + sampleDir + fileSeparator + id3v1;- protocol = new ProtocolFactory(conf).getProtocol(urlString);- content = protocol.getProtocolOutput(new Text(urlString), new CrawlDatum())- .getContent();- parse = new ParseUtil(conf).parseByExtensionId("parse-mp3", content).get(urlString);-- Metadata metadata = parse.getData().getParseMeta();- assertEquals("postgresql comment id3v1", metadata.get("COMM-Text"));- assertEquals("postgresql artist id3v1", metadata.get("TPE1-Text"));- assertEquals("(28)", metadata.get("TCON-Text"));- assertEquals("2004", metadata.get("TYER-Text"));- assertEquals("postgresql title id3v1", metadata.get("TIT2-Text"));- assertEquals("postgresql album id3v1", metadata.get("TALB-Text"));-- assertEquals("postgresql title id3v1 - "- + "postgresql album id3v1 - "- + "postgresql artist id3v1", parse.getData().getTitle());-- }-- public void testNone() throws ProtocolException, ParseException {- String urlString;- Protocol protocol;- Content content;- Parse parse;-- Configuration conf = NutchConfiguration.create();- urlString = "file:" + sampleDir + fileSeparator + none;- protocol = new ProtocolFactory(conf).getProtocol(urlString);- content = protocol.getProtocolOutput(new Text(urlString), new CrawlDatum())- .getContent();- parse = new ParseUtil(conf).parseByExtensionId("parse-mp3", content).get(urlString);-// Metadata metadata = parse.getData().getParseMeta();- if (parse.getData().getStatus().isSuccess()) {- fail("Expected ParseException");- }- }--}diff --git a/src/plugin/parse-rtf/README.txt b/src/plugin/parse-rtf/README.txtdeleted file mode 100644index 0a9eacf8d..000000000--- a/src/plugin/parse-rtf/README.txt+++ /dev/null@@ -1,47 +0,0 @@-Prereqs: JDK 1.4+ and javacc version 3.2+--This document describes how to create rtf-parser.jar file as used by Nutch.--Source files are contained in:--http://www.cobase.cs.ucla.edu/pub/javacc/rtf_parser_src.jar--Create a new directory with the following files in:-- LICENCE- RTFParser.jj- RTFParserDelegate.java--cd into this new directory create a src directory-- $mkdir src--copy RTFParser.jj RTFParserDelegate.java into this src directory-- $cp RTFParser.jj RTFParserDelegate.java src/--now cd into this src directory and generate the javacc classes for the parser-and then cd out again-- $cd src- $javacc RTFParser.jj- $cd ..--now compile all the source and generated files-- $javac -d . src/*.java--(optional) remove the generated source-- $rm -rf src # (optional)--finally create the jar archive of all the salient files-- $jar -cvf rtf-parser.jar com/ LICENCE RTFParser*----Andy Hedges--Credits:--Thanks to Eric Friedman for writing this javacc grammar file.-diff --git a/src/plugin/parse-rtf/build.xml b/src/plugin/parse-rtf/build.xmldeleted file mode 100755index 3598c808a..000000000--- a/src/plugin/parse-rtf/build.xml+++ /dev/null@@ -1,72 +0,0 @@-<?xml version="1.0"?>-<!--- Licensed to the Apache Software Foundation (ASF) under one or more- contributor license agreements. See the NOTICE file distributed with- this work for additional information regarding copyright ownership.- The ASF licenses this file to You under the Apache License, Version 2.0- (the "License"); you may not use this file except in compliance with- the License. You may obtain a copy of the License at-- http://www.apache.org/licenses/LICENSE-2.0-- Unless required by applicable law or agreed to in writing, software- distributed under the License is distributed on an "AS IS" BASIS,- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- See the License for the specific language governing permissions and- limitations under the License.--->-<project name="parse-rtf" default="jar">-- <import file="../build-plugin.xml"/>-- <!-- Build compilation dependencies -->- <target name="deps-jar">- <ant target="compile-core" inheritall="false" dir="${nutch.root}"/>- </target>-- <!-- Deploy Unit test dependencies -->- <target name="deps-test">- <ant target="deploy" inheritall="false" dir="../nutch-extensionpoints"/>- <ant target="deploy" inheritall="false" dir="../protocol-file"/>- </target>--- <property name="rtf-src.jar" value="tmp/rtf_parser_src.jar"/>- <property name="rtf-parser.jar" value="lib/rtf-parser.jar"/>-- <available file="${rtf-src.jar}" property="rtf-src.jar.available"/>- <available file="${rtf-parser.jar}" property="rtf-parser.available"/>-- <target name="download-rtf-src" unless="rtf-src.jar.available">- <mkdir dir="tmp"/>- <get src="http://www.cobase.cs.ucla.edu/pub/javacc/rtf_parser_src.jar"- dest="tmp/rtf_parser_src.jar"/>- </target>-- <target name="build-rtf-parser"- depends="download-rtf-src"- unless="rtf-parser.available">- <unjar src="${rtf-src.jar}"- dest="tmp"/>- <javacc target="tmp/rtf/RTFParser.jj"- javacchome="${javacc.home}">- </javacc>-- <mkdir dir="tmp/classes"/>- <javac srcdir="tmp" destdir="tmp/classes"/>- <jar destfile="${rtf-parser.jar}" basedir="tmp/classes"/>- <delete>- <fileset dir="tmp">- <exclude name="*.jar"/>- </fileset>- </delete>- </target>-- <target name="init-plugin" depends="build-rtf-parser">-- <!-- for junit test -->- <mkdir dir="${build.test}/data"/>- <copy file="sample/test.rtf" todir="${build.test}/data"/>-- </target>-</project>diff --git a/src/plugin/parse-rtf/plugin.xml b/src/plugin/parse-rtf/plugin.xmldeleted file mode 100755index 601aec148..000000000--- a/src/plugin/parse-rtf/plugin.xml+++ /dev/null@@ -1,45 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<!--- Licensed to the Apache Software Foundation (ASF) under one or more- contributor license agreements. See the NOTICE file distributed with- this work for additional information regarding copyright ownership.- The ASF licenses this file to You under the Apache License, Version 2.0- (the "License"); you may not use this file except in compliance with- the License. You may obtain a copy of the License at-- http://www.apache.org/licenses/LICENSE-2.0-- Unless required by applicable law or agreed to in writing, software- distributed under the License is distributed on an "AS IS" BASIS,- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- See the License for the specific language governing permissions and- limitations under the License.--->-<plugin- version="1.0.0"- provider-name="nutch.org"- id="parse-rtf"- name="RTF Parse Plug-in">-- <runtime>- <library name="parse-rtf.jar">- <export name="*"/>- </library>- <library name="rtf-parser.jar"/>- </runtime>-- <requires>- <import plugin="nutch-extensionpoints"/>- </requires>-- <extension point="org.apache.nutch.parse.Parser"- id="org.apache.nutch.parse.rtf"- name="RTFParse">- <implementation class="org.apache.nutch.parse.rtf.RTFParseFactory"- id="org.apache.nutch.parse.rtf.RTFParseFactory">- <parameter name="pathSuffix" value="rtf"/>- <parameter name="contentType" value="application/rtf"/>- </implementation>- </extension>--</plugin>diff --git a/src/plugin/parse-rtf/sample/README.txt b/src/plugin/parse-rtf/sample/README.txtdeleted file mode 100644index f47a471c9..000000000--- a/src/plugin/parse-rtf/sample/README.txt+++ /dev/null@@ -1,6 +0,0 @@--./test.rtf: A short rtf file created with OpenOffice.org contain the text unquoted--"The quick brown fox jumps over the lazy dog"---- Andy Hedges\ No newline at end of filediff --git a/src/plugin/parse-rtf/sample/test.rtf b/src/plugin/parse-rtf/sample/test.rtfdeleted file mode 100644index c67a6c8e1..000000000--- a/src/plugin/parse-rtf/sample/test.rtf+++ /dev/null@@ -1,17 +0,0 @@-{\rtf1\ansi\deff1\adeflang1025-{\fonttbl{\f0\froman\fprq2\fcharset0 Times;}{\f1\froman\fprq2\fcharset0 Times New Roman;}{\f2\fmodern\fprq1\fcharset0 Courier New;}{\f3\froman\fprq2\fcharset0 Times New Roman;}{\f4\fnil\fprq2\fcharset0 Interface User;}{\f5\fnil\fprq2\fcharset0 Lucidasans;}{\f6\fnil\fprq0\fcharset0 Lucidasans;}}-{\colortbl;\red0\green0\blue0;\red0\green0\blue128;\red128\green128\blue128;}-{\stylesheet{\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af5\afs24\lang255\ltrch\dbch\af4\afs24\langfe255\loch\f1\fs24\lang1033\snext1 Default;}-{\s2\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\afs24\lang255\ltrch\dbch\afs24\langfe255\loch\f1\fs24\lang1033\sbasedon1\snext2 Text body;}-{\s3\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af6\afs24\lang255\ltrch\dbch\af1\afs24\langfe255\loch\f1\fs24\lang1033\sbasedon2\snext3 List;}-{\s4\sb120\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af6\afs20\lang255\ai\ltrch\dbch\afs20\langfe255\ai\loch\f1\fs20\lang1033\i\sbasedon1\snext4 Caption;}-{\s5\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af6\afs24\lang255\ltrch\dbch\afs24\langfe255\loch\f1\fs24\lang1033\sbasedon1\snext5 Index;}-{\*\cs7\cf0\rtlch\af2\afs24\lang255\ltrch\dbch\af2\afs24\langfe255\loch\f2\fs24\lang1033 Teletype;}-{\*\cs8\cf2\ul\rtlch\afs24\lang255\ltrch\dbch\afs24\langfe255\loch\fs24\lang1033 Internet Link;}-}-{\info{\title test rft document}{\subject tests}{\creatim\yr2004\mo9\dy20\hr19\min36}{\revtim\yr1601\mo1\dy1\hr0\min0}{\printim\yr1601\mo1\dy1\hr0\min0}{\comment StarWriter}{\vern6450}}\deftab709-{\*\pgdsctbl-{\pgdsc0\pgdscuse195\pgwsxn11905\pghsxn16837\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\pgdscnxt0 Default;}}-{\*\pgdscno0}\paperh16837\paperw11905\margl1800\margr1800\margt1440\margb1440\sectd\sbknone\pgwsxn11905\pghsxn16837\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc-\pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\ql\rtlch\af5\afs24\lang255\ltrch\dbch\af4\afs24\langfe255\loch\f1\fs24\lang1033{\loch\f2\fs24\lang1033\i0\b0\*\cs7\cf0\rtlch\ltrch\dbch\loch\f2\fs24\lang1033 The quick brown fox jumps over the lazy dog}-\par }\ No newline at end of filediff --git a/src/plugin/parse-rtf/src/java/org/apache/nutch/parse/rtf/RTFParseFactory.java b/src/plugin/parse-rtf/src/java/org/apache/nutch/parse/rtf/RTFParseFactory.javadeleted file mode 100644index ad960578f..000000000--- a/src/plugin/parse-rtf/src/java/org/apache/nutch/parse/rtf/RTFParseFactory.java+++ /dev/null@@ -1,97 +0,0 @@-/**- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */-package org.apache.nutch.parse.rtf;--// JDK imports-import java.io.ByteArrayInputStream;-import java.io.InputStreamReader;-import java.io.Reader;--// Hadoop imports-import org.apache.hadoop.conf.Configuration;--// Nutch imports-import org.apache.nutch.metadata.DublinCore;-import org.apache.nutch.metadata.Metadata;-import org.apache.nutch.parse.OutlinkExtractor;-import org.apache.nutch.parse.Parse;-import org.apache.nutch.parse.ParseData;-import org.apache.nutch.parse.ParseImpl;-import org.apache.nutch.parse.ParseStatus;-import org.apache.nutch.parse.Parser;-import org.apache.nutch.protocol.Content;--// RTF Parser imports-import com.etranslate.tm.processing.rtf.ParseException;-import com.etranslate.tm.processing.rtf.RTFParser;---/**- * A parser for RTF documents- *- * @author Andy Hedges- */-public class RTFParseFactory implements Parser {-- private Configuration conf;-- public Parse getParse(Content content) {- byte[] raw = content.getContent();- Reader reader = new InputStreamReader(new ByteArrayInputStream(raw));- RTFParserDelegateImpl delegate = new RTFParserDelegateImpl();- RTFParser rtfParser = null;- rtfParser = RTFParser.createParser(reader);- rtfParser.setNewLine("\n");- rtfParser.setDelegate(delegate);-- try {- rtfParser.parse();- } catch (ParseException e) {- return new ParseStatus(ParseStatus.FAILED,- ParseStatus.FAILED_EXCEPTION,- e.toString()).getEmptyParse(conf);- }-- Metadata metadata = new Metadata();- metadata.setAll(delegate.getMetaData());- String title = metadata.get(DublinCore.TITLE);-- if (title != null) {- metadata.remove(DublinCore.TITLE);- } else {- title = "";- }-- String text = delegate.getText();-- return new ParseImpl(text,- new ParseData(ParseStatus.STATUS_SUCCESS,- title,- OutlinkExtractor- . getOutlinks(text, this.conf),- content.getMetadata(),- metadata));- }-- public void setConf(Configuration conf) {- this.conf = conf;- }-- public Configuration getConf() {- return this.conf;- }-}diff --git a/src/plugin/parse-rtf/src/java/org/apache/nutch/parse/rtf/RTFParserDelegateImpl.java b/src/plugin/parse-rtf/src/java/org/apache/nutch/parse/rtf/RTFParserDelegateImpl.javadeleted file mode 100644index 9434befaa..000000000--- a/src/plugin/parse-rtf/src/java/org/apache/nutch/parse/rtf/RTFParserDelegateImpl.java+++ /dev/null@@ -1,132 +0,0 @@-/**- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--package org.apache.nutch.parse.rtf;--// RTF Parser imports-import com.etranslate.tm.processing.rtf.RTFParserDelegate;--// JDK imports-import java.util.Arrays;-import java.util.List;-import java.util.Properties;--// Nutch imports-import org.apache.nutch.metadata.DublinCore;-import org.apache.nutch.metadata.Office;---/**- * A parser delegate for handling rtf events.- * @author Andy Hedges- */-public class RTFParserDelegateImpl implements RTFParserDelegate {-- String tabs = "";- Properties metadata = new Properties();-- String[] META_NAMES_TEXT = {- DublinCore.TITLE,- DublinCore.SUBJECT,- Office.AUTHOR,- "manager",- "company",- "operator",- "category",- Office.KEYWORDS,- Office.COMMENTS,- "doccomm",- "hlinkbase"- };-- String[] META_NAMES_DATE = {- "creatim",- "creatim",- "printim",- "buptim"- };-- String metaName = "";- List metaNamesText = Arrays.asList(META_NAMES_TEXT);- List metaNamesDate = Arrays.asList(META_NAMES_DATE);- boolean isMetaTextValue = false;- boolean isMetaDateValue = false;- String content = "";- boolean justOpenedGroup = false;- boolean ignoreMode = false;-- public void text(String text, String style, int context) {- justOpenedGroup = false;- if (isMetaTextValue && context == IN_INFO) {- metadata.setProperty(metaName, text);- isMetaTextValue = false;- } else if (context == IN_DOCUMENT && !ignoreMode) {- content += text;- }- }-- public void controlSymbol(String controlSymbol, int context) {- if("\\*".equals(controlSymbol) && justOpenedGroup){- ignoreMode = true;- }- justOpenedGroup = false;- }-- public void controlWord(String controlWord, int value, int context) {- justOpenedGroup = false;- controlWord = controlWord.substring(1);- switch (context) {- case IN_INFO:- if (metaNamesText.contains(controlWord)) {- isMetaTextValue = true;- metaName = controlWord;- } else if (metaNamesDate.contains(controlWord)) {- //TODO: collect up the dates- }- break;- case IN_DOCUMENT:- //System.out.println(controlWord);- break;- }- }-- public void openGroup(int depth) {- justOpenedGroup = true;- }-- public void closeGroup(int depth) {- justOpenedGroup = false;- ignoreMode = false;- }-- public void styleList(List styles) {- }-- public void startDocument() {- }-- public void endDocument() {- }-- public String getText() {- return content;- }-- public Properties getMetaData() {- return metadata;- }-}diff --git a/src/plugin/parse-rtf/src/java/org/apache/nutch/parse/rtf/package.html b/src/plugin/parse-rtf/src/java/org/apache/nutch/parse/rtf/package.htmldeleted file mode 100644index 301dc547b..000000000--- a/src/plugin/parse-rtf/src/java/org/apache/nutch/parse/rtf/package.html+++ /dev/null@@ -1,5 +0,0 @@-<html>-<body>-<p>A RTF parsing plugin.</p><p></p>-</body>-</html>diff --git a/src/plugin/parse-rtf/src/test/org/apache/nutch/parse/rtf/TestRTFParser.java b/src/plugin/parse-rtf/src/test/org/apache/nutch/parse/rtf/TestRTFParser.javadeleted file mode 100644index fcd240f29..000000000--- a/src/plugin/parse-rtf/src/test/org/apache/nutch/parse/rtf/TestRTFParser.java+++ /dev/null@@ -1,92 +0,0 @@-/**- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--package org.apache.nutch.parse.rtf;--// JUnit imports-import junit.framework.TestCase;--// Nutch imports-import org.apache.nutch.crawl.CrawlDatum;-import org.apache.nutch.metadata.DublinCore;-import org.apache.nutch.metadata.Metadata;-import org.apache.nutch.parse.Parse;-import org.apache.nutch.parse.ParseUtil;-import org.apache.nutch.parse.ParseException;-import org.apache.nutch.protocol.Content;-import org.apache.nutch.protocol.Protocol;-import org.apache.nutch.protocol.ProtocolException;-import org.apache.nutch.protocol.ProtocolFactory;-import org.apache.nutch.util.NutchConfiguration;--// Hadoop imports-import org.apache.hadoop.conf.Configuration;-import org.apache.hadoop.io.Text;---/**- * Unit tests for TestRTFParser. (Adapted from John Xing msword unit tests).- *- * @author Andy Hedges- */-public class TestRTFParser extends TestCase {-- private String fileSeparator = System.getProperty("file.separator");- // This system property is defined in ./src/plugin/build-plugin.xml- private String sampleDir = System.getProperty("test.data", ".");- // Make sure sample files are copied to "test.data" as specified in- // ./src/plugin/parse-rtf/build.xml during plugin compilation.- // Check ./src/plugin/parse-rtf/sample/README.txt for what they are.- private String rtfFile = "test.rtf";-- public TestRTFParser(String name) {- super(name);- }-- protected void setUp() {- }-- protected void tearDown() {- }-- public void testIt() throws ProtocolException, ParseException {-- String urlString;- Protocol protocol;- Content content;- Parse parse;-- Configuration conf = NutchConfiguration.create();- urlString = "file:" + sampleDir + fileSeparator + rtfFile;- protocol = new ProtocolFactory(conf).getProtocol(urlString);- content = protocol.getProtocolOutput(new Text(urlString), new CrawlDatum())- .getContent();- parse = new ParseUtil(conf).parseByExtensionId("parse-rtf", content);- String text = parse.getText();- assertEquals("The quick brown fox jumps over the lazy dog", text.trim());-- String title = parse.getData().getTitle();- Metadata meta = parse.getData().getParseMeta();- assertEquals("test rft document", title);- assertEquals("tests", meta.get(DublinCore.SUBJECT));---- }---}