Eclipse에서 sbt 어셈블리를 사용하여 프로젝트를 빌드하고 있습니다. 많은 충돌이 있었기 때문에 매우 크고 복잡한 build.sbt 파일이 있습니다.Apache Tika 1.16 TXTParser sbt 빌드에서 문자 인코딩을 감지하지 못했습니다.
tika 1.16의 PDF, OOXML 및 OpenDocument 파서를 사용하는 모든 것이 pdf, pptx, odt 및 docx 파일에 대해 올바르게 작동합니다. 내 스칼라 코드에서
org.apache.tika.exception.TikaException: Failed to detect the character encoding of a document
at org.apache.tika.detect.AutoDetectReader.detect(AutoDetectReader.java:77)
at org.apache.tika.detect.AutoDetectReader.<init>(AutoDetectReader.java:108)
at org.apache.tika.detect.AutoDetectReader.<init>(AutoDetectReader.java:114)
at org.apache.tika.parser.txt.TXTParser.parse(TXTParser.java:79)`
이 라인에서 : 나는 TXTParser 나는 다음과 같은 오류가 사용 txt 파일 (UTF-8 인코딩)를 구문 분석 할 때 그러나
val content = theParser.parse(stream.open(), chandler, meta, pContext)
이 스트림은 어디 PortableDataStream, chandler는 새로운 BodyContentHandler이며, meta는 새로운 Metadata이며, pContext는 새로운 ParseContext입니다. 내 스칼라 코드에서
org.apache.jena.shared.SyntaxError: unknown
at org.apache.jena.rdf.model.impl.NTripleReader.read(NTripleReader.java:73)
at org.apache.jena.rdf.model.impl.NTripleReader.read(NTripleReader.java:58)
at org.apache.jena.rdf.model.impl.ModelCom.read(ModelCom.java:305)
이 라인에서 : 나는 AutoDetectParser를 사용하는 경우
대신 나는 다음과 같은 오류가
스트림 InputStream를입니다val response = model.read(stream, null, "N-TRIPLES")
.
나는이 문제가 Tika의 빈 응답 때문이라고 생각합니다. (그래서 같은 문제입니다.)
나는 이것이 아마도 지나치게 복잡한 build.sbt 파일의 종속성 문제 일 것이라고 확신하지만 많은 시간 동안 노력한 후에 필자는 분명 도움이 필요하다.
하나의 긍정적 인 점은 txt 파일을 입력하지 않으면 모든 것이 완벽하게 작동하기 때문에 이것이 내 마지막 문제 일 가능성이 높습니다!
이scalaVersion := "2.11.8"
version := "1.0.0"
name := "crawldocs"
conflictManager := ConflictManager.strict
mainClass in assembly := Some("com.addlesee.crawling.CrawlHiccup")
libraryDependencies ++= Seq(
"org.apache.tika" % "tika-core" % "1.16",
"org.apache.tika" % "tika-parsers" % "1.16" excludeAll(
ExclusionRule(organization = "*", name = "guava")
),
"com.blazegraph" % "bigdata-core" % "2.0.0" excludeAll(
ExclusionRule(organization = "*", name = "collection-0.7"),
ExclusionRule(organization = "*", name = "commons-cli"),
ExclusionRule(organization = "*", name = "commons-codec"),
ExclusionRule(organization = "*", name = "commons-csv"),
ExclusionRule(organization = "*", name = "commons-io"),
ExclusionRule(organization = "*", name = "commons-lang3"),
ExclusionRule(organization = "*", name = "commons-logging"),
ExclusionRule(organization = "*", name = "httpclient"),
ExclusionRule(organization = "*", name = "httpclient-cache"),
ExclusionRule(organization = "*", name = "httpcore"),
ExclusionRule(organization = "*", name = "httpmime"),
ExclusionRule(organization = "*", name = "jackson-annotations"),
ExclusionRule(organization = "*", name = "jackson-core"),
ExclusionRule(organization = "*", name = "jackson-databind"),
ExclusionRule(organization = "*", name = "jcl-over-slf4j"),
ExclusionRule(organization = "*", name = "jena-cmds"),
ExclusionRule(organization = "*", name = "jena-rdfconnection"),
ExclusionRule(organization = "*", name = "jena-tdb"),
ExclusionRule(organization = "*", name = "jsonld-java"),
ExclusionRule(organization = "*", name = "libthrift"),
ExclusionRule(organization = "*", name = "log4j"),
ExclusionRule(organization = "*", name = "slf4j-api"),
ExclusionRule(organization = "*", name = "slf4j-log4j12"),
ExclusionRule(organization = "*", name = "xercesImpl"),
ExclusionRule(organization = "*", name = "xml-apis")
),
"org.scalaj" %% "scalaj-http" % "2.3.0",
"org.apache.jena" % "apache-jena" % "3.4.0" excludeAll(
ExclusionRule(organization = "*", name = "commons-cli"),
ExclusionRule(organization = "*", name = "commons-codec"),
ExclusionRule(organization = "*", name = "commons-csv"),
ExclusionRule(organization = "*", name = "commons-lang3"),
ExclusionRule(organization = "*", name = "httpclient"),
ExclusionRule(organization = "*", name = "httpclient-cache"),
ExclusionRule(organization = "*", name = "httpcore"),
ExclusionRule(organization = "*", name = "jackson-core"),
ExclusionRule(organization = "*", name = "jackson-databind"),
ExclusionRule(organization = "*", name = "jcl-over-slf4j"),
ExclusionRule(organization = "*", name = "jena-rdfconnection"),
ExclusionRule(organization = "*", name = "slf4j-api")
),
"org.apache.jena" % "apache-jena-libs" % "3.4.0" excludeAll(
ExclusionRule(organization = "*", name = "commons-cli"),
ExclusionRule(organization = "*", name = "commons-codec"),
ExclusionRule(organization = "*", name = "commons-csv"),
ExclusionRule(organization = "*", name = "commons-lang3"),
ExclusionRule(organization = "*", name = "httpclient"),
ExclusionRule(organization = "*", name = "httpclient-cache"),
ExclusionRule(organization = "*", name = "httpcore"),
ExclusionRule(organization = "*", name = "jackson-core"),
ExclusionRule(organization = "*", name = "jackson-databind"),
ExclusionRule(organization = "*", name = "jcl-over-slf4j"),
ExclusionRule(organization = "*", name = "jena-rdfconnection"),
ExclusionRule(organization = "*", name = "slf4j-api")
),
"org.noggit" % "noggit" % "0.6",
"com.typesafe.scala-logging" %% "scala-logging" % "3.7.2" excludeAll(
ExclusionRule(organization = "*", name = "slf4j-api")
),
"org.apache.spark" % "spark-core_2.11" % "2.2.0" excludeAll(
ExclusionRule(organization = "*", name = "breeze_2.11"),
ExclusionRule(organization = "*", name = "hadoop-hdfs"),
ExclusionRule(organization = "*", name = "hadoop-annotations"),
ExclusionRule(organization = "*", name = "hadoop-common"),
ExclusionRule(organization = "*", name = "hadoop-mapreduce-client-app"),
ExclusionRule(organization = "*", name = "hadoop-mapreduce-client-common"),
ExclusionRule(organization = "*", name = "hadoop-mapreduce-client-core"),
ExclusionRule(organization = "*", name = "hadoop-mapreduce-client-jobclient"),
ExclusionRule(organization = "*", name = "hadoop-mapreduce-client-shuffle"),
ExclusionRule(organization = "*", name = "hadoop-yarn-api"),
ExclusionRule(organization = "*", name = "hadoop-yarn-client"),
ExclusionRule(organization = "*", name = "hadoop-yarn-common"),
ExclusionRule(organization = "*", name = "hadoop-yarn-server-common"),
ExclusionRule(organization = "*", name = "hadoop-yarn-server-web-proxy"),
ExclusionRule(organization = "*", name = "activation"),
ExclusionRule(organization = "*", name = "hive-exec"),
ExclusionRule(organization = "*", name = "scala-compiler"),
ExclusionRule(organization = "*", name = "spire_2.11"),
ExclusionRule(organization = "*", name = "commons-compress"),
ExclusionRule(organization = "*", name = "slf4j-api"),
ExclusionRule(organization = "*", name = "guava"),
ExclusionRule(organization = "*", name = "commons-codec"),
ExclusionRule(organization = "*", name = "commons-io"),
ExclusionRule(organization = "*", name = "gson"),
ExclusionRule(organization = "*", name = "httpclient"),
ExclusionRule(organization = "*", name = "zookeeper"),
ExclusionRule(organization = "*", name = "jettison"),
ExclusionRule(organization = "*", name = "jackson-core"),
ExclusionRule(organization = "*", name = "httpcore"),
ExclusionRule(organization = "*", name = "bcprov-jdk15on"),
ExclusionRule(organization = "*", name = "jul-to-slf4j"),
ExclusionRule(organization = "*", name = "jcl-over-slf4j"),
ExclusionRule(organization = "*", name = "commons-cli"),
ExclusionRule(organization = "*", name = "slf4j-log4j12"),
ExclusionRule(organization = "*", name = "curator-framework")
),
"org.scala-lang" % "scala-xml" % "2.11.0-M4",
"org.apache.hadoop" % "hadoop-mapreduce-client-core" % "2.7.3" excludeAll(
ExclusionRule(organization = "*", name = "commons-codec"),
ExclusionRule(organization = "*", name = "commons-cli"),
ExclusionRule(organization = "*", name = "slf4j-api"),
ExclusionRule(organization = "*", name = "commons-io"),
ExclusionRule(organization = "*", name = "jettison"),
ExclusionRule(organization = "*", name = "avro"),
ExclusionRule(organization = "*", name = "commons-compress"),
ExclusionRule(organization = "*", name = "slf4j-log4j12"),
ExclusionRule(organization = "*", name = "netty")
),
"org.apache.hadoop" % "hadoop-common" % "2.7.3" excludeAll(
ExclusionRule(organization = "*", name = "commons-codec"),
ExclusionRule(organization = "*", name = "commons-cli"),
ExclusionRule(organization = "*", name = "slf4j-api"),
ExclusionRule(organization = "*", name = "commons-math3"),
ExclusionRule(organization = "*", name = "commons-io"),
ExclusionRule(organization = "*", name = "jets3t"),
ExclusionRule(organization = "*", name = "gson"),
ExclusionRule(organization = "*", name = "avro"),
ExclusionRule(organization = "*", name = "httpclient"),
ExclusionRule(organization = "*", name = "zookeeper"),
ExclusionRule(organization = "*", name = "commons-compress"),
ExclusionRule(organization = "*", name = "slf4j-log4j12"),
ExclusionRule(organization = "*", name = "commons-net"),
ExclusionRule(organization = "*", name = "curator-recipes"),
ExclusionRule(organization = "*", name = "jsr305")
)
)
assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case x => MergeStrategy.first
}
당신의 파일을 처리 할 수 있습니다 : 내 build.sbt의 하단에 다음 assemblyMergeStrategy 내 문제를 해결? 그게 Tika 버그인지 또는 프로젝트에서 Tika를 어떻게 사용하는지에 대한 문제입니다. – Gagravarr
Eclipse 프로젝트에서 tika-app 및 tika-parsers 독립 실행 형 jar 파일을 빌드 경로에 넣었습니다. 그 완벽하게 작동 ... 내 build.sbt tika - 응용 프로그램 종속성을 가지고 시도했다 그러나 문제를 기억할 수 없습니다. 나는 다시 시험해 화요일에 여기에 올릴 것이다. (나는 집에서 만든 병을 시험 할 수없는 서비스가 필요하다.) 귀하의 회신에 감사드립니다! – GoBuildAngus
MergeStrategy.concat은 "META-INF/service/* (나는 sbt를 사용하지 않습니다)에 대한 올바른 것 같습니다 . – AndyS