You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2020/10/07 18:03:55 UTC
[tika] branch main updated (0844dce -> fd2f43d)
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git.
from 0844dce Move new test files to 2.x folder, doh!
new 9dfccde add -C/--content cli option using WriteOutContentHandler (#312)
new fd2f43d TIKA-3044 -- swap -C --content for -A and --text-all
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../src/main/java/org/apache/tika/cli/TikaCLI.java | 18 +++++++++++++++---
.../src/test/java/org/apache/tika/cli/TikaCLITest.java | 14 ++++++++++++++
2 files changed, 29 insertions(+), 3 deletions(-)
[tika] 02/02: TIKA-3044 -- swap -C --content for -A and --text-all
Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git
commit fd2f43d7c55fab430e817a947e14b8d06ab0612f
Author: tallison <ta...@apache.org>
AuthorDate: Wed Oct 7 13:54:23 2020 -0400
TIKA-3044 -- swap -C --content for -A and --text-all
---
tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java | 12 ++++++------
tika-app/src/test/java/org/apache/tika/cli/TikaCLITest.java | 6 +++---
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java b/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java
index 216f9c6..a3cb9b3 100644
--- a/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java
+++ b/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java
@@ -266,7 +266,7 @@ public class TikaCLI {
}
};
- private final OutputType CONTENT = new OutputType() {
+ private final OutputType TEXT_ALL = new OutputType() {
@Override
protected ContentHandler getContentHandler(
OutputStream output, Metadata metadata) throws Exception {
@@ -447,8 +447,8 @@ public class TikaCLI {
type = TEXT;
} else if (arg.equals("-T") || arg.equals("--text-main")) {
type = TEXT_MAIN;
- } else if (arg.equals("-C") || arg.equals("--content")) {
- type = CONTENT;
+ } else if (arg.equals("-A") || arg.equals("--text-all")) {
+ type = TEXT_ALL;
} else if (arg.equals("-m") || arg.equals("--metadata")) {
type = METADATA;
} else if (arg.equals("-l") || arg.equals("--language")) {
@@ -572,9 +572,9 @@ public class TikaCLI {
out.println("");
out.println(" -x or --xml Output XHTML content (default)");
out.println(" -h or --html Output HTML content");
- out.println(" -t or --text Output plain text content");
- out.println(" -T or --text-main Output plain text content (main content only)");
- out.println(" -C or --content Output all text content");
+ out.println(" -t or --text Output plain text content (body)");
+ out.println(" -T or --text-main Output plain text content (main content only via boilerpipe handler)");
+ out.println(" -A or --text-all Output all text content");
out.println(" -m or --metadata Output only metadata");
out.println(" -j or --json Output metadata in JSON");
out.println(" -y or --xmp Output metadata in XMP");
diff --git a/tika-app/src/test/java/org/apache/tika/cli/TikaCLITest.java b/tika-app/src/test/java/org/apache/tika/cli/TikaCLITest.java
index 955433e..12371f4 100644
--- a/tika-app/src/test/java/org/apache/tika/cli/TikaCLITest.java
+++ b/tika-app/src/test/java/org/apache/tika/cli/TikaCLITest.java
@@ -154,13 +154,13 @@ public class TikaCLITest {
}
/**
- * Tests -C option of the cli
+ * Tests -A option of the cli
*
* @throws Exception
*/
@Test
- public void testContentOutput() throws Exception{
- String[] params = {"-C", resourcePrefix + "testJsonMultipleInts.html"};
+ public void testContentAllOutput() throws Exception{
+ String[] params = {"-A", resourcePrefix + "testJsonMultipleInts.html"};
TikaCLI.main(params);
String out = outContent.toString(UTF_8.name());
assertTrue(out.contains("this is a title"));
[tika] 01/02: add -C/--content cli option using
WriteOutContentHandler (#312)
Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git
commit 9dfccdebdc02fc18bb94badaa8a71f93c3b26690
Author: Alexander Klimetschek <ak...@adobe.com>
AuthorDate: Wed Oct 7 10:47:33 2020 -0700
add -C/--content cli option using WriteOutContentHandler (#312)
---
tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java | 14 +++++++++++++-
.../src/test/java/org/apache/tika/cli/TikaCLITest.java | 14 ++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java b/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java
index 7a3a30c..216f9c6 100644
--- a/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java
+++ b/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java
@@ -105,6 +105,7 @@ import org.apache.tika.sax.BodyContentHandler;
import org.apache.tika.sax.ContentHandlerFactory;
import org.apache.tika.sax.ExpandedTitleContentHandler;
import org.apache.tika.sax.RecursiveParserWrapperHandler;
+import org.apache.tika.sax.WriteOutContentHandler;
import org.apache.tika.xmp.XMPMetadata;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -264,7 +265,15 @@ public class TikaCLI {
return new BoilerpipeContentHandler(getOutputWriter(output, encoding));
}
};
-
+
+ private final OutputType CONTENT = new OutputType() {
+ @Override
+ protected ContentHandler getContentHandler(
+ OutputStream output, Metadata metadata) throws Exception {
+ return new WriteOutContentHandler(getOutputWriter(output, encoding));
+ }
+ };
+
private final OutputType METADATA = new OutputType() {
@Override
protected ContentHandler getContentHandler(
@@ -438,6 +447,8 @@ public class TikaCLI {
type = TEXT;
} else if (arg.equals("-T") || arg.equals("--text-main")) {
type = TEXT_MAIN;
+ } else if (arg.equals("-C") || arg.equals("--content")) {
+ type = CONTENT;
} else if (arg.equals("-m") || arg.equals("--metadata")) {
type = METADATA;
} else if (arg.equals("-l") || arg.equals("--language")) {
@@ -563,6 +574,7 @@ public class TikaCLI {
out.println(" -h or --html Output HTML content");
out.println(" -t or --text Output plain text content");
out.println(" -T or --text-main Output plain text content (main content only)");
+ out.println(" -C or --content Output all text content");
out.println(" -m or --metadata Output only metadata");
out.println(" -j or --json Output metadata in JSON");
out.println(" -y or --xmp Output metadata in XMP");
diff --git a/tika-app/src/test/java/org/apache/tika/cli/TikaCLITest.java b/tika-app/src/test/java/org/apache/tika/cli/TikaCLITest.java
index 0a0ae17..955433e 100644
--- a/tika-app/src/test/java/org/apache/tika/cli/TikaCLITest.java
+++ b/tika-app/src/test/java/org/apache/tika/cli/TikaCLITest.java
@@ -154,6 +154,20 @@ public class TikaCLITest {
}
/**
+ * Tests -C option of the cli
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testContentOutput() throws Exception{
+ String[] params = {"-C", resourcePrefix + "testJsonMultipleInts.html"};
+ TikaCLI.main(params);
+ String out = outContent.toString(UTF_8.name());
+ assertTrue(out.contains("this is a title"));
+ assertTrue(out.contains("body"));
+ }
+
+ /**
* Tests -f option of the cli
*
* @throws Exception