class Reader2Image extends Transformer with DefaultParamsWritable with HasOutputAnnotatorType with HasOutputAnnotationCol with HasBinaryReaderProperties with HasReaderContent

The Reader2Image annotator allows you to use the reading files with images more smoothly within existing Spark NLP workflows, enabling seamless reuse of your pipelines. Reader2Image can be used for extracting structured image content from various document types using Spark NLP readers. It supports reading from many files types and returns parsed output as a structured Spark DataFrame.

Supported formats include HTML and Markdown

Example

import com.johnsnowlabs.reader.Reader2Image
import com. johnsnowlabs.nlp.base.DocumentAssembler
import org.apache.spark.ml.Pipeline

val reader2Image = new Reader2Image()
  .setContentType("text/html")
  .setContentPath("./example-images.html")
  .setOutputCol("image")

val pipeline = new Pipeline()
  .setStages(Array(reader2Image))

val pipelineModel = pipeline.fit(emptyDataSet)
val resultDf = pipelineModel.transform(emptyDataSet)

resultDf.show()
+-------------------+--------------------+
|           fileName|               image|
+-------------------+--------------------+
|example-images.html|[{image, example-...|
|example-images.html|[{image, example-...|
+-------------------+--------------------+

resultDf.printSchema()

root
 |-- fileName: string (nullable = true)
 |-- image: array (nullable = false)
 |    |-- element: struct (containsNull = true)
 |    |    |-- annotatorType: string (nullable = true)
 |    |    |-- origin: string (nullable = true)
 |    |    |-- height: integer (nullable = false)
 |    |    |-- width: integer (nullable = false)
 |    |    |-- nChannels: integer (nullable = false)
 |    |    |-- mode: integer (nullable = false)
 |    |    |-- result: binary (nullable = true)
 |    |    |-- metadata: map (nullable = true)
 |    |    |    |-- key: string
 |    |    |    |-- value: string (valueContainsNull = true)
 |    |    |-- text: string (nullable = true)
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Reader2Image
  2. HasReaderContent
  3. HasTagsReaderProperties
  4. HasXmlReaderProperties
  5. HasHTMLReaderProperties
  6. HasReaderProperties
  7. HasBinaryReaderProperties
  8. HasPowerPointProperties
  9. HasPdfReaderProperties
  10. HasExcelReaderProperties
  11. HasEmailReaderProperties
  12. ParamsAndFeaturesWritable
  13. HasFeatures
  14. HasOutputAnnotationCol
  15. HasOutputAnnotatorType
  16. DefaultParamsWritable
  17. MLWritable
  18. Transformer
  19. PipelineStage
  20. Logging
  21. Params
  22. Serializable
  23. Identifiable
  24. AnyRef
  25. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new Reader2Image()
  2. new Reader2Image(uid: String)

Type Members

  1. type AnnotatorType = String
    Definition Classes
    HasOutputAnnotatorType

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def $[T](param: Param[T]): T
    Attributes
    protected
    Definition Classes
    Params
  4. def $$[T](feature: StructFeature[T]): T
    Attributes
    protected
    Definition Classes
    HasFeatures
  5. def $$[K, V](feature: MapFeature[K, V]): Map[K, V]
    Attributes
    protected
    Definition Classes
    HasFeatures
  6. def $$[T](feature: SetFeature[T]): Set[T]
    Attributes
    protected
    Definition Classes
    HasFeatures
  7. def $$[T](feature: ArrayFeature[T]): Array[T]
    Attributes
    protected
    Definition Classes
    HasFeatures
  8. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  9. val addAttachmentContent: Param[Boolean]
    Definition Classes
    HasEmailReaderProperties
  10. def afterAnnotate(dataset: DataFrame): DataFrame
  11. val appendCells: Param[Boolean]
    Definition Classes
    HasExcelReaderProperties
  12. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  13. def buildEmptyDataFrame(dataset: Dataset[_]): DataFrame
    Definition Classes
    HasReaderContent
  14. def buildErrorDataFrame(dataset: Dataset[_], contentPath: String, ext: String): DataFrame
    Definition Classes
    HasReaderContent
  15. val cellSeparator: Param[String]
    Definition Classes
    HasExcelReaderProperties
  16. final def clear(param: Param[_]): Reader2Image.this.type
    Definition Classes
    Params
  17. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
  18. val contentPath: Param[String]
    Definition Classes
    HasReaderProperties
  19. val contentType: Param[String]
    Definition Classes
    HasReaderProperties
  20. def copy(extra: ParamMap): Transformer
    Definition Classes
    Reader2Image → Transformer → PipelineStage → Params
  21. def copyValues[T <: Params](to: T, extra: ParamMap): T
    Attributes
    protected
    Definition Classes
    Params
  22. val customPromptTemplate: Param[String]
  23. final def defaultCopy[T <: Params](extra: ParamMap): T
    Attributes
    protected
    Definition Classes
    Params
  24. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  25. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  26. def explainParam(param: Param[_]): String
    Definition Classes
    Params
  27. def explainParams(): String
    Definition Classes
    Params
  28. val explodeDocs: BooleanParam
    Definition Classes
    HasReaderProperties
  29. final def extractParamMap(): ParamMap
    Definition Classes
    Params
  30. final def extractParamMap(extra: ParamMap): ParamMap
    Definition Classes
    Params
  31. val features: ArrayBuffer[Feature[_, _, _]]
    Definition Classes
    HasFeatures
  32. val flattenOutput: BooleanParam
    Definition Classes
    HasReaderProperties
  33. def get[T](feature: StructFeature[T]): Option[T]
    Attributes
    protected
    Definition Classes
    HasFeatures
  34. def get[K, V](feature: MapFeature[K, V]): Option[Map[K, V]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  35. def get[T](feature: SetFeature[T]): Option[Set[T]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  36. def get[T](feature: ArrayFeature[T]): Option[Array[T]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  37. final def get[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  38. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  39. def getContentType: String
    Definition Classes
    HasReaderContent
  40. final def getDefault[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  41. val getFileName: UserDefinedFunction
    Definition Classes
    HasReaderContent
  42. final def getInputCol: String
    Definition Classes
    HasReaderProperties
  43. final def getOrDefault[T](param: Param[T]): T
    Definition Classes
    Params
  44. final def getOutputCol: String

    Gets annotation column name going to generate

    Gets annotation column name going to generate

    Definition Classes
    HasOutputAnnotationCol
  45. def getParam(paramName: String): Param[Any]
    Definition Classes
    Params
  46. final def hasDefault[T](param: Param[T]): Boolean
    Definition Classes
    Params
  47. def hasParam(paramName: String): Boolean
    Definition Classes
    Params
  48. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  49. val headers: Param[Map[String, String]]
    Definition Classes
    HasHTMLReaderProperties
  50. val ignoreExceptions: BooleanParam
    Definition Classes
    HasReaderProperties
  51. val includePageBreaks: Param[Boolean]
    Definition Classes
    HasReaderProperties
  52. val includeSlideNotes: Param[Boolean]
    Definition Classes
    HasPowerPointProperties
  53. val includeTitleTag: Param[Boolean]
    Definition Classes
    HasHTMLReaderProperties
  54. val inferTableStructure: Param[Boolean]
    Definition Classes
    HasReaderProperties
  55. def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  56. def initializeLogIfNecessary(isInterpreter: Boolean): Unit
    Attributes
    protected
    Definition Classes
    Logging
  57. final val inputCol: Param[String]
    Attributes
    protected
    Definition Classes
    HasReaderProperties
  58. final def isDefined(param: Param[_]): Boolean
    Definition Classes
    Params
  59. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  60. final def isSet(param: Param[_]): Boolean
    Definition Classes
    Params
  61. def isTraceEnabled(): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  62. def listAllFilesRecursively(dir: File): Seq[File]
    Definition Classes
    HasReaderContent
  63. def log: Logger
    Attributes
    protected
    Definition Classes
    Logging
  64. def logDebug(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  65. def logDebug(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  66. def logError(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  67. def logError(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  68. def logInfo(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  69. def logInfo(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  70. def logName: String
    Attributes
    protected
    Definition Classes
    Logging
  71. def logTrace(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  72. def logTrace(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  73. def logWarning(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  74. def logWarning(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  75. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  76. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  77. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  78. def onWrite(path: String, spark: SparkSession): Unit
    Attributes
    protected
    Definition Classes
    ParamsAndFeaturesWritable
  79. val onlyLeafNodes: Param[Boolean]
    Definition Classes
    HasXmlReaderProperties
  80. val outputAnnotatorType: AnnotatorType
    Definition Classes
    Reader2ImageHasOutputAnnotatorType
  81. final val outputCol: Param[String]
    Attributes
    protected
    Definition Classes
    HasOutputAnnotationCol
  82. val outputFormat: Param[String]
    Definition Classes
    HasHTMLReaderProperties
  83. lazy val params: Array[Param[_]]
    Definition Classes
    Params
  84. def partitionBuilder: Partition
    Attributes
    protected
  85. def partitionContent(partition: Partition, contentPath: String, isText: Boolean, dataset: Dataset[_]): DataFrame
    Definition Classes
    Reader2ImageHasReaderContent
  86. def partitionContentFromPath(partition: Partition, contentPath: String, isText: Boolean, dataset: Dataset[_]): DataFrame
    Definition Classes
    HasReaderContent
  87. def partitionMixedContent(dataset: Dataset[_], dirPath: String, partitionParams: Map[String, String]): DataFrame
    Definition Classes
    HasReaderContent
  88. def partitionToAnnotation: UserDefinedFunction
  89. val promptTemplate: Param[String]
  90. final val readAsImage: BooleanParam
    Definition Classes
    HasPdfReaderProperties
  91. def retrieveFileName(path: String): String
    Definition Classes
    HasReaderContent
  92. def save(path: String): Unit
    Definition Classes
    MLWritable
    Annotations
    @throws("If the input path already exists but overwrite is not enabled.") @Since("1.6.0")
  93. def set[T](feature: StructFeature[T], value: T): Reader2Image.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  94. def set[K, V](feature: MapFeature[K, V], value: Map[K, V]): Reader2Image.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  95. def set[T](feature: SetFeature[T], value: Set[T]): Reader2Image.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  96. def set[T](feature: ArrayFeature[T], value: Array[T]): Reader2Image.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  97. final def set(paramPair: ParamPair[_]): Reader2Image.this.type
    Attributes
    protected
    Definition Classes
    Params
  98. final def set(param: String, value: Any): Reader2Image.this.type
    Attributes
    protected
    Definition Classes
    Params
  99. final def set[T](param: Param[T], value: T): Reader2Image.this.type
    Definition Classes
    Params
  100. def setAddAttachmentContent(value: Boolean): Reader2Image.this.type
    Definition Classes
    HasEmailReaderProperties
  101. def setAppendCells(value: Boolean): Reader2Image.this.type
    Definition Classes
    HasExcelReaderProperties
  102. def setCellSeparator(value: String): Reader2Image.this.type
    Definition Classes
    HasExcelReaderProperties
  103. def setContentPath(value: String): Reader2Image.this.type
    Definition Classes
    HasReaderProperties
  104. def setContentType(value: String): Reader2Image.this.type
    Definition Classes
    HasReaderProperties
  105. def setCustomPromptTemplate(value: String): Reader2Image.this.type
  106. def setDefault[T](feature: StructFeature[T], value: () => T): Reader2Image.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  107. def setDefault[K, V](feature: MapFeature[K, V], value: () => Map[K, V]): Reader2Image.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  108. def setDefault[T](feature: SetFeature[T], value: () => Set[T]): Reader2Image.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  109. def setDefault[T](feature: ArrayFeature[T], value: () => Array[T]): Reader2Image.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  110. final def setDefault(paramPairs: ParamPair[_]*): Reader2Image.this.type
    Attributes
    protected
    Definition Classes
    Params
  111. final def setDefault[T](param: Param[T], value: T): Reader2Image.this.type
    Attributes
    protected[org.apache.spark.ml]
    Definition Classes
    Params
  112. def setExplodeDocs(value: Boolean): Reader2Image.this.type
    Definition Classes
    HasReaderProperties
  113. def setFlattenOutput(value: Boolean): Reader2Image.this.type
    Definition Classes
    HasReaderProperties
  114. def setHeaders(value: Map[String, String]): Reader2Image.this.type
    Definition Classes
    HasHTMLReaderProperties
  115. def setHeadersPython(headers: Map[String, String]): Reader2Image.this.type
    Definition Classes
    HasHTMLReaderProperties
  116. def setIgnoreExceptions(value: Boolean): Reader2Image.this.type
    Definition Classes
    HasReaderProperties
  117. def setIncludePageBreaks(value: Boolean): Reader2Image.this.type
    Definition Classes
    HasReaderProperties
  118. def setIncludeSlideNotes(value: Boolean): Reader2Image.this.type
    Definition Classes
    HasPowerPointProperties
  119. def setIncludeTitleTag(value: Boolean): Reader2Image.this.type
    Definition Classes
    HasHTMLReaderProperties
  120. def setInferTableStructure(value: Boolean): Reader2Image.this.type
    Definition Classes
    HasReaderProperties
  121. final def setInputCol(value: String): Reader2Image.this.type
    Definition Classes
    HasReaderProperties
  122. def setOnlyLeafNodes(value: Boolean): Reader2Image.this.type
    Definition Classes
    HasXmlReaderProperties
  123. final def setOutputCol(value: String): Reader2Image.this.type

    Overrides annotation column name when transforming

    Overrides annotation column name when transforming

    Definition Classes
    HasOutputAnnotationCol
  124. def setOutputFormat(value: String): Reader2Image.this.type
    Definition Classes
    HasHTMLReaderProperties
  125. def setPromptTemplate(value: String): Reader2Image.this.type
  126. def setStoreContent(value: Boolean): Reader2Image.this.type
    Definition Classes
    HasReaderProperties
  127. def setTimeout(value: Int): Reader2Image.this.type
    Definition Classes
    HasHTMLReaderProperties
  128. def setTitleFontSize(value: Int): Reader2Image.this.type
    Definition Classes
    HasReaderProperties
  129. def setTitleThreshold(value: Double): Reader2Image.this.type
    Definition Classes
    HasPdfReaderProperties
  130. def setUserMessage(value: String): Reader2Image.this.type
  131. def setXmlKeepTags(value: Boolean): Reader2Image.this.type
    Definition Classes
    HasXmlReaderProperties
  132. val storeContent: Param[Boolean]
    Definition Classes
    HasReaderProperties
  133. val supportedTypes: Map[String, (String, Boolean)]
    Definition Classes
    Reader2ImageHasReaderContent
  134. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  135. val timeout: Param[Int]
    Definition Classes
    HasHTMLReaderProperties
  136. val titleFontSize: Param[Int]
    Definition Classes
    HasReaderProperties
  137. val titleThreshold: Param[Double]
    Definition Classes
    HasPdfReaderProperties
  138. def toString(): String
    Definition Classes
    Identifiable → AnyRef → Any
  139. def transform(dataset: Dataset[_]): DataFrame
    Definition Classes
    Reader2Image → Transformer
  140. def transform(dataset: Dataset[_], paramMap: ParamMap): DataFrame
    Definition Classes
    Transformer
    Annotations
    @Since("2.0.0")
  141. def transform(dataset: Dataset[_], firstParamPair: ParamPair[_], otherParamPairs: ParamPair[_]*): DataFrame
    Definition Classes
    Transformer
    Annotations
    @varargs() @Since("2.0.0")
  142. def transformSchema(schema: StructType): StructType
    Definition Classes
    Reader2Image → PipelineStage
  143. def transformSchema(schema: StructType, logging: Boolean): StructType
    Attributes
    protected
    Definition Classes
    PipelineStage
    Annotations
    @DeveloperApi()
  144. val uid: String
    Definition Classes
    Reader2Image → Identifiable
  145. val userMessage: Param[String]
  146. def validateRequiredParameters(): Unit
    Attributes
    protected
  147. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  148. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  149. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  150. def write: MLWriter
    Definition Classes
    ParamsAndFeaturesWritable → DefaultParamsWritable → MLWritable
  151. val xmlKeepTags: Param[Boolean]
    Definition Classes
    HasXmlReaderProperties

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from HasReaderContent

Inherited from HasXmlReaderProperties

Inherited from HasReaderProperties

Inherited from HasPdfReaderProperties

Inherited from HasFeatures

Inherited from HasOutputAnnotationCol

Inherited from HasOutputAnnotatorType

Inherited from DefaultParamsWritable

Inherited from MLWritable

Inherited from Transformer

Inherited from PipelineStage

Inherited from Logging

Inherited from Params

Inherited from Serializable

Inherited from Identifiable

Inherited from AnyRef

Inherited from Any

Ungrouped