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
- Grouped
- Alphabetic
- By Inheritance
- Finisher
- DefaultParamsWritable
- MLWritable
- Transformer
- PipelineStage
- Logging
- Params
- Serializable
- Serializable
- Identifiable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
$[T](param: Param[T]): T
- Attributes
- protected
- Definition Classes
- Params
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
val
annotationSplitSymbol: Param[String]
Character separating annotations (Default:
@
) -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
val
cleanAnnotations: BooleanParam
Whether to remove annotation columns (Default:
true
) -
final
def
clear(param: Param[_]): Finisher.this.type
- Definition Classes
- Params
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
copy(extra: ParamMap): Transformer
- Definition Classes
- Finisher → Transformer → PipelineStage → Params
-
def
copyValues[T <: Params](to: T, extra: ParamMap): T
- Attributes
- protected
- Definition Classes
- Params
-
final
def
defaultCopy[T <: Params](extra: ParamMap): T
- Attributes
- protected
- Definition Classes
- Params
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
explainParam(param: Param[_]): String
- Definition Classes
- Params
-
def
explainParams(): String
- Definition Classes
- Params
-
final
def
extractParamMap(): ParamMap
- Definition Classes
- Params
-
final
def
extractParamMap(extra: ParamMap): ParamMap
- Definition Classes
- Params
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
get[T](param: Param[T]): Option[T]
- Definition Classes
- Params
-
def
getAnnotationSplitSymbol: String
Character separating annotations (Default:
#
) -
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
getCleanAnnotations: Boolean
Whether to remove annotation columns (Default:
true
) -
final
def
getDefault[T](param: Param[T]): Option[T]
- Definition Classes
- Params
-
def
getIncludeMetadata: Boolean
Annotation metadata format (Default:
false
) -
def
getInputCols: Array[String]
Name of finisher output cols
-
final
def
getOrDefault[T](param: Param[T]): T
- Definition Classes
- Params
-
def
getOutputAsArray: Boolean
Finisher generates an Array with the results instead of string (Default:
true
) -
def
getOutputCols: Array[String]
Name of input annotation cols
-
def
getParam(paramName: String): Param[Any]
- Definition Classes
- Params
-
def
getValueSplitSymbol: String
Character separating annotations (Default:
#
) -
final
def
hasDefault[T](param: Param[T]): Boolean
- Definition Classes
- Params
-
def
hasParam(paramName: String): Boolean
- Definition Classes
- Params
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
val
includeMetadata: BooleanParam
Annotation metadata format (Default:
false
) -
def
initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
- Attributes
- protected
- Definition Classes
- Logging
-
def
initializeLogIfNecessary(isInterpreter: Boolean): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
val
inputCols: StringArrayParam
Name of input annotation cols
-
final
def
isDefined(param: Param[_]): Boolean
- Definition Classes
- Params
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
isSet(param: Param[_]): Boolean
- Definition Classes
- Params
-
def
isTraceEnabled(): Boolean
- Attributes
- protected
- Definition Classes
- Logging
-
def
log: Logger
- Attributes
- protected
- Definition Classes
- Logging
-
def
logDebug(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logDebug(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logError(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logError(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logInfo(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logInfo(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logName: String
- Attributes
- protected
- Definition Classes
- Logging
-
def
logTrace(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logTrace(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logWarning(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logWarning(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
val
outputAsArray: BooleanParam
Finisher generates an Array with the results instead of string (Default:
true
) -
val
outputCols: StringArrayParam
Name of finisher output cols
-
lazy val
params: Array[Param[_]]
- Definition Classes
- Params
-
val
parseEmbeddingsVectors: BooleanParam
Whether to include embeddings vectors in the process (Default:
false
) -
def
save(path: String): Unit
- Definition Classes
- MLWritable
- Annotations
- @Since( "1.6.0" ) @throws( ... )
-
final
def
set(paramPair: ParamPair[_]): Finisher.this.type
- Attributes
- protected
- Definition Classes
- Params
-
final
def
set(param: String, value: Any): Finisher.this.type
- Attributes
- protected
- Definition Classes
- Params
-
final
def
set[T](param: Param[T], value: T): Finisher.this.type
- Definition Classes
- Params
-
def
setAnnotationSplitSymbol(value: String): Finisher.this.type
Character separating annotations (Default:
#
) -
def
setCleanAnnotations(value: Boolean): Finisher.this.type
Whether to remove annotation columns (Default:
true
) -
final
def
setDefault(paramPairs: ParamPair[_]*): Finisher.this.type
- Attributes
- protected
- Definition Classes
- Params
-
final
def
setDefault[T](param: Param[T], value: T): Finisher.this.type
- Attributes
- protected[org.apache.spark.ml]
- Definition Classes
- Params
-
def
setIncludeMetadata(value: Boolean): Finisher.this.type
Annotation metadata format (Default:
false
) -
def
setInputCols(value: String*): Finisher.this.type
Name of input annotation cols
-
def
setInputCols(value: Array[String]): Finisher.this.type
Name of input annotation cols
-
def
setOutputAsArray(value: Boolean): Finisher.this.type
Finisher generates an Array with the results instead of string (Default:
true
) -
def
setOutputCols(value: String*): Finisher.this.type
Name of finisher output cols
-
def
setOutputCols(value: Array[String]): Finisher.this.type
Name of finisher output cols
-
def
setValueSplitSymbol(value: String): Finisher.this.type
Character separating annotations (Default:
#
) -
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- Identifiable → AnyRef → Any
-
def
transform(dataset: Dataset[_]): Dataset[Row]
- Definition Classes
- Finisher → Transformer
-
def
transform(dataset: Dataset[_], paramMap: ParamMap): DataFrame
- Definition Classes
- Transformer
- Annotations
- @Since( "2.0.0" )
-
def
transform(dataset: Dataset[_], firstParamPair: ParamPair[_], otherParamPairs: ParamPair[_]*): DataFrame
- Definition Classes
- Transformer
- Annotations
- @Since( "2.0.0" ) @varargs()
-
def
transformSchema(schema: StructType): StructType
- Definition Classes
- Finisher → PipelineStage
-
def
transformSchema(schema: StructType, logging: Boolean): StructType
- Attributes
- protected
- Definition Classes
- PipelineStage
- Annotations
- @DeveloperApi()
-
val
uid: String
- Definition Classes
- Finisher → Identifiable
-
val
valueSplitSymbol: Param[String]
Character separating annotations (Default:
#
) -
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
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.