class Finisher extends Transformer with DefaultParamsWritable

Converts annotation results into a format that easier to use. It is useful to extract the results from Spark NLP Pipelines. The Finisher outputs annotation(s) values into String.

For more extended examples on document pre-processing see the Examples.

Example

import spark.implicits._
import com.johnsnowlabs.nlp.pretrained.PretrainedPipeline
import com.johnsnowlabs.nlp.Finisher

val data = Seq((1, "New York and New Jersey aren't that far apart actually.")).toDF("id", "text")

// Extracts Named Entities amongst other things
val pipeline = PretrainedPipeline("explain_document_dl")

val finisher = new Finisher().setInputCols("entities").setOutputCols("output")
val explainResult = pipeline.transform(data)

explainResult.selectExpr("explode(entities)").show(false)
+------------------------------------------------------------------------------------------------------------------------------------------------------+
|entities                                                                                                                                              |
+------------------------------------------------------------------------------------------------------------------------------------------------------+
|[[chunk, 0, 7, New York, [entity -> LOC, sentence -> 0, chunk -> 0], []], [chunk, 13, 22, New Jersey, [entity -> LOC, sentence -> 0, chunk -> 1], []]]|
+------------------------------------------------------------------------------------------------------------------------------------------------------+

val result = finisher.transform(explainResult)
result.select("output").show(false)
+----------------------+
|output                |
+----------------------+
|[New York, New Jersey]|
+----------------------+
See also

EmbeddingsFinisher for finishing embeddings

Linear Supertypes
DefaultParamsWritable, MLWritable, Transformer, PipelineStage, Logging, Params, Serializable, Serializable, Identifiable, AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. Finisher
  2. DefaultParamsWritable
  3. MLWritable
  4. Transformer
  5. PipelineStage
  6. Logging
  7. Params
  8. Serializable
  9. Serializable
  10. Identifiable
  11. AnyRef
  12. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

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

    uid

    required uid for storing annotator to disk

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. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  5. val annotationSplitSymbol: Param[String]

    Character separating annotations (Default: @)

  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. val cleanAnnotations: BooleanParam

    Whether to remove annotation columns (Default: true)

  8. final def clear(param: Param[_]): Finisher.this.type
    Definition Classes
    Params
  9. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  10. def copy(extra: ParamMap): Transformer
    Definition Classes
    Finisher → Transformer → PipelineStage → Params
  11. def copyValues[T <: Params](to: T, extra: ParamMap): T
    Attributes
    protected
    Definition Classes
    Params
  12. final def defaultCopy[T <: Params](extra: ParamMap): T
    Attributes
    protected
    Definition Classes
    Params
  13. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  15. def explainParam(param: Param[_]): String
    Definition Classes
    Params
  16. def explainParams(): String
    Definition Classes
    Params
  17. final def extractParamMap(): ParamMap
    Definition Classes
    Params
  18. final def extractParamMap(extra: ParamMap): ParamMap
    Definition Classes
    Params
  19. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  20. final def get[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  21. def getAnnotationSplitSymbol: String

    Character separating annotations (Default: #)

  22. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  23. def getCleanAnnotations: Boolean

    Whether to remove annotation columns (Default: true)

  24. final def getDefault[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  25. def getIncludeMetadata: Boolean

    Annotation metadata format (Default: false)

  26. def getInputCols: Array[String]

    Name of finisher output cols

  27. final def getOrDefault[T](param: Param[T]): T
    Definition Classes
    Params
  28. def getOutputAsArray: Boolean

    Finisher generates an Array with the results instead of string (Default: true)

  29. def getOutputCols: Array[String]

    Name of input annotation cols

  30. def getParam(paramName: String): Param[Any]
    Definition Classes
    Params
  31. def getValueSplitSymbol: String

    Character separating annotations (Default: #)

  32. final def hasDefault[T](param: Param[T]): Boolean
    Definition Classes
    Params
  33. def hasParam(paramName: String): Boolean
    Definition Classes
    Params
  34. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  35. val includeMetadata: BooleanParam

    Annotation metadata format (Default: false)

  36. def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  37. def initializeLogIfNecessary(isInterpreter: Boolean): Unit
    Attributes
    protected
    Definition Classes
    Logging
  38. val inputCols: StringArrayParam

    Name of input annotation cols

  39. final def isDefined(param: Param[_]): Boolean
    Definition Classes
    Params
  40. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  41. final def isSet(param: Param[_]): Boolean
    Definition Classes
    Params
  42. def isTraceEnabled(): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  43. def log: Logger
    Attributes
    protected
    Definition Classes
    Logging
  44. def logDebug(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  45. def logDebug(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  46. def logError(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  47. def logError(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  48. def logInfo(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  49. def logInfo(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  50. def logName: String
    Attributes
    protected
    Definition Classes
    Logging
  51. def logTrace(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  52. def logTrace(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  53. def logWarning(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  54. def logWarning(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  55. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  56. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  57. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  58. val outputAsArray: BooleanParam

    Finisher generates an Array with the results instead of string (Default: true)

  59. val outputCols: StringArrayParam

    Name of finisher output cols

  60. lazy val params: Array[Param[_]]
    Definition Classes
    Params
  61. val parseEmbeddingsVectors: BooleanParam

    Whether to include embeddings vectors in the process (Default: false)

  62. def save(path: String): Unit
    Definition Classes
    MLWritable
    Annotations
    @Since( "1.6.0" ) @throws( ... )
  63. final def set(paramPair: ParamPair[_]): Finisher.this.type
    Attributes
    protected
    Definition Classes
    Params
  64. final def set(param: String, value: Any): Finisher.this.type
    Attributes
    protected
    Definition Classes
    Params
  65. final def set[T](param: Param[T], value: T): Finisher.this.type
    Definition Classes
    Params
  66. def setAnnotationSplitSymbol(value: String): Finisher.this.type

    Character separating annotations (Default: #)

  67. def setCleanAnnotations(value: Boolean): Finisher.this.type

    Whether to remove annotation columns (Default: true)

  68. final def setDefault(paramPairs: ParamPair[_]*): Finisher.this.type
    Attributes
    protected
    Definition Classes
    Params
  69. final def setDefault[T](param: Param[T], value: T): Finisher.this.type
    Attributes
    protected[org.apache.spark.ml]
    Definition Classes
    Params
  70. def setIncludeMetadata(value: Boolean): Finisher.this.type

    Annotation metadata format (Default: false)

  71. def setInputCols(value: String*): Finisher.this.type

    Name of input annotation cols

  72. def setInputCols(value: Array[String]): Finisher.this.type

    Name of input annotation cols

  73. def setOutputAsArray(value: Boolean): Finisher.this.type

    Finisher generates an Array with the results instead of string (Default: true)

  74. def setOutputCols(value: String*): Finisher.this.type

    Name of finisher output cols

  75. def setOutputCols(value: Array[String]): Finisher.this.type

    Name of finisher output cols

  76. def setValueSplitSymbol(value: String): Finisher.this.type

    Character separating annotations (Default: #)

  77. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  78. def toString(): String
    Definition Classes
    Identifiable → AnyRef → Any
  79. def transform(dataset: Dataset[_]): Dataset[Row]
    Definition Classes
    Finisher → Transformer
  80. def transform(dataset: Dataset[_], paramMap: ParamMap): DataFrame
    Definition Classes
    Transformer
    Annotations
    @Since( "2.0.0" )
  81. def transform(dataset: Dataset[_], firstParamPair: ParamPair[_], otherParamPairs: ParamPair[_]*): DataFrame
    Definition Classes
    Transformer
    Annotations
    @Since( "2.0.0" ) @varargs()
  82. def transformSchema(schema: StructType): StructType
    Definition Classes
    Finisher → PipelineStage
  83. def transformSchema(schema: StructType, logging: Boolean): StructType
    Attributes
    protected
    Definition Classes
    PipelineStage
    Annotations
    @DeveloperApi()
  84. val uid: String
    Definition Classes
    Finisher → Identifiable
  85. val valueSplitSymbol: Param[String]

    Character separating annotations (Default: #)

  86. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  87. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  88. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  89. def write: MLWriter
    Definition Classes
    DefaultParamsWritable → MLWritable

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

Parameters

A list of (hyper-)parameter keys this annotator can take. Users can set and get the parameter values through setters and getters, respectively.

Members

Parameter setters

Parameter getters