c

com.johnsnowlabs.reader

ReaderAssembler

class ReaderAssembler extends Transformer with DefaultParamsWritable with HasOutputAnnotatorType with HasOutputAnnotationCol with HasBinaryReaderProperties with HasTextReaderProperties with HasReaderContent

The ReaderAssembler annotator provides a unified interface for combining multiple Spark NLP readers (such as Reader2Doc, Reader2Table, and Reader2Image) into a single, configurable component. It automatically orchestrates the execution of different readers based on input type, configured priorities, and fallback strategies allowing you to handle diverse content formats without manually chaining multiple readers in your pipeline.

ReaderAssembler simplifies the process of building flexible pipelines capable of ingesting and processing documents, tables, and images in a consistent way. It handles reader selection, ordering, and fault-tolerance internally, ensuring that pipelines remain concise, robust, and easy to maintain.

Example

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

val readerAssembler = new ReaderAssembler()
  .setContentType("text/html")
  .setContentPath(s"$htmlFilesDirectory/table-image.html")
  .setOutputCol("document")

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

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

resultDf.show()
+--------+--------------------+--------------------+--------------------+---------+
|fileName|       document_text|      document_table|      document_image|exception|
+--------+--------------------+--------------------+--------------------+---------+
|    null|[{document, 0, 26...|[{document, 0, 50...|[{image, , 5, 5, ...|     null|
+--------+--------------------+--------------------+--------------------+---------+

This annotator is especially useful when working with heterogeneous input data — for example, when a dataset includes PDFs, spreadsheets, and images — allowing Spark NLP to automatically invoke the appropriate reader for each file type while preserving a unified schema in the output.

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ReaderAssembler
  2. HasReaderContent
  3. HasTagsReaderProperties
  4. HasXmlReaderProperties
  5. HasHTMLReaderProperties
  6. HasReaderProperties
  7. HasTextReaderProperties
  8. HasBinaryReaderProperties
  9. HasPowerPointProperties
  10. HasPdfReaderProperties
  11. HasExcelReaderProperties
  12. HasEmailReaderProperties
  13. ParamsAndFeaturesWritable
  14. HasFeatures
  15. HasOutputAnnotationCol
  16. HasOutputAnnotatorType
  17. DefaultParamsWritable
  18. MLWritable
  19. Transformer
  20. PipelineStage
  21. Logging
  22. Params
  23. Serializable
  24. Serializable
  25. Identifiable
  26. AnyRef
  27. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ReaderAssembler()
  2. new ReaderAssembler(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[_], filePath: String, badExt: String): DataFrame
    Definition Classes
    ReaderAssemblerHasReaderContent
  15. val cellSeparator: Param[String]
    Definition Classes
    HasExcelReaderProperties
  16. final def clear(param: Param[_]): ReaderAssembler.this.type
    Definition Classes
    Params
  17. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @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
    ReaderAssembler → 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: Any): Boolean
    Definition Classes
    AnyRef → Any
  26. val excludeNonText: BooleanParam
  27. def explainParam(param: Param[_]): String
    Definition Classes
    Params
  28. def explainParams(): String
    Definition Classes
    Params
  29. val explodeDocs: BooleanParam
    Definition Classes
    HasReaderProperties
  30. final def extractParamMap(): ParamMap
    Definition Classes
    Params
  31. final def extractParamMap(extra: ParamMap): ParamMap
    Definition Classes
    Params
  32. val features: ArrayBuffer[Feature[_, _, _]]
    Definition Classes
    HasFeatures
  33. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  34. val flattenOutput: BooleanParam
    Definition Classes
    HasReaderProperties
  35. def get[T](feature: StructFeature[T]): Option[T]
    Attributes
    protected
    Definition Classes
    HasFeatures
  36. def get[K, V](feature: MapFeature[K, V]): Option[Map[K, V]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  37. def get[T](feature: SetFeature[T]): Option[Set[T]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  38. def get[T](feature: ArrayFeature[T]): Option[Array[T]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  39. final def get[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  40. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  41. def getContentType: String
    Definition Classes
    HasReaderContent
  42. final def getDefault[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  43. val getFileName: UserDefinedFunction
    Definition Classes
    HasReaderContent
  44. final def getInputCol: String
    Definition Classes
    HasReaderProperties
  45. final def getOrDefault[T](param: Param[T]): T
    Definition Classes
    Params
  46. final def getOutputCol: String

    Gets annotation column name going to generate

    Gets annotation column name going to generate

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

    Excludes rows that are not text data.

    Excludes rows that are not text data. e.g. tables

  116. def setExplodeDocs(value: Boolean): ReaderAssembler.this.type
    Definition Classes
    HasReaderProperties
  117. def setFlattenOutput(value: Boolean): ReaderAssembler.this.type
    Definition Classes
    HasReaderProperties
  118. def setGroupBrokenParagraphs(value: Boolean): ReaderAssembler.this.type
    Definition Classes
    HasTextReaderProperties
  119. def setHeaders(value: Map[String, String]): ReaderAssembler.this.type
    Definition Classes
    HasHTMLReaderProperties
  120. def setHeadersPython(headers: Map[String, String]): ReaderAssembler.this.type
    Definition Classes
    HasHTMLReaderProperties
  121. def setIgnoreExceptions(value: Boolean): ReaderAssembler.this.type
    Definition Classes
    HasReaderProperties
  122. def setIncludePageBreaks(value: Boolean): ReaderAssembler.this.type
    Definition Classes
    HasReaderProperties
  123. def setIncludeSlideNotes(value: Boolean): ReaderAssembler.this.type
    Definition Classes
    HasPowerPointProperties
  124. def setIncludeTitleTag(value: Boolean): ReaderAssembler.this.type
    Definition Classes
    HasHTMLReaderProperties
  125. def setInferTableStructure(value: Boolean): ReaderAssembler.this.type
    Definition Classes
    HasReaderProperties
  126. final def setInputCol(value: String): ReaderAssembler.this.type
    Definition Classes
    HasReaderProperties
  127. def setMaxLineCount(value: Int): ReaderAssembler.this.type
    Definition Classes
    HasTextReaderProperties
  128. def setOnlyLeafNodes(value: Boolean): ReaderAssembler.this.type
    Definition Classes
    HasXmlReaderProperties
  129. final def setOutputCol(value: String): ReaderAssembler.this.type

    Overrides annotation column name when transforming

    Overrides annotation column name when transforming

    Definition Classes
    HasOutputAnnotationCol
  130. def setOutputFormat(value: String): ReaderAssembler.this.type
    Definition Classes
    HasHTMLReaderProperties
  131. def setParagraphSplit(value: String): ReaderAssembler.this.type
    Definition Classes
    HasTextReaderProperties
  132. def setPromptTemplate(value: String): ReaderAssembler.this.type
  133. def setShortLineWordThreshold(value: Int): ReaderAssembler.this.type
    Definition Classes
    HasTextReaderProperties
  134. def setStoreContent(value: Boolean): ReaderAssembler.this.type
    Definition Classes
    HasReaderProperties
  135. def setThreshold(value: Double): ReaderAssembler.this.type
    Definition Classes
    HasTextReaderProperties
  136. def setTimeout(value: Int): ReaderAssembler.this.type
    Definition Classes
    HasHTMLReaderProperties
  137. def setTitleFontSize(value: Int): ReaderAssembler.this.type
    Definition Classes
    HasReaderProperties
  138. def setTitleLengthSize(value: Int): ReaderAssembler.this.type
    Definition Classes
    HasTextReaderProperties
  139. def setTitleThreshold(value: Double): ReaderAssembler.this.type
    Definition Classes
    HasPdfReaderProperties
  140. def setUserMessage(value: String): ReaderAssembler.this.type
  141. def setXmlKeepTags(value: Boolean): ReaderAssembler.this.type
    Definition Classes
    HasXmlReaderProperties
  142. val shortLineWordThreshold: Param[Int]
    Definition Classes
    HasTextReaderProperties
  143. val storeContent: Param[Boolean]
    Definition Classes
    HasReaderProperties
  144. val supportedTypes: Map[String, (String, Boolean)]
    Definition Classes
    ReaderAssemblerHasReaderContent
  145. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  146. val threshold: Param[Double]
    Definition Classes
    HasTextReaderProperties
  147. val timeout: Param[Int]
    Definition Classes
    HasHTMLReaderProperties
  148. val titleFontSize: Param[Int]
    Definition Classes
    HasReaderProperties
  149. val titleLengthSize: Param[Int]
    Definition Classes
    HasTextReaderProperties
  150. val titleThreshold: Param[Double]
    Definition Classes
    HasPdfReaderProperties
  151. def toString(): String
    Definition Classes
    Identifiable → AnyRef → Any
  152. def transform(dataset: Dataset[_]): DataFrame
    Definition Classes
    ReaderAssembler → Transformer
  153. def transform(dataset: Dataset[_], paramMap: ParamMap): DataFrame
    Definition Classes
    Transformer
    Annotations
    @Since( "2.0.0" )
  154. def transform(dataset: Dataset[_], firstParamPair: ParamPair[_], otherParamPairs: ParamPair[_]*): DataFrame
    Definition Classes
    Transformer
    Annotations
    @Since( "2.0.0" ) @varargs()
  155. def transformSchema(schema: StructType): StructType
    Definition Classes
    ReaderAssembler → PipelineStage
  156. def transformSchema(schema: StructType, logging: Boolean): StructType
    Attributes
    protected
    Definition Classes
    PipelineStage
    Annotations
    @DeveloperApi()
  157. val uid: String
    Definition Classes
    ReaderAssembler → Identifiable
  158. val userMessage: Param[String]
  159. def validateRequiredParameters(): Unit
    Attributes
    protected
  160. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  161. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  162. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  163. def write: MLWriter
    Definition Classes
    ParamsAndFeaturesWritable → DefaultParamsWritable → MLWritable
  164. val xmlKeepTags: Param[Boolean]
    Definition Classes
    HasXmlReaderProperties

Inherited from HasReaderContent

Inherited from HasTagsReaderProperties

Inherited from HasXmlReaderProperties

Inherited from HasHTMLReaderProperties

Inherited from HasReaderProperties

Inherited from HasTextReaderProperties

Inherited from HasBinaryReaderProperties

Inherited from HasPowerPointProperties

Inherited from HasPdfReaderProperties

Inherited from HasExcelReaderProperties

Inherited from HasEmailReaderProperties

Inherited from ParamsAndFeaturesWritable

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 Serializable

Inherited from Identifiable

Inherited from AnyRef

Inherited from Any

Ungrouped