Packages

class DateNormalizer extends AnnotatorModel[DateNormalizer] with HasSimpleAnnotate[DateNormalizer]

Try to normalize dates in chunks annotations. The expected format for the date will be YYYY/MM/DD. If the date is normalized then field normalized in metadata will be true else will be false.

Example

Define a pipeline with 2 different NER models with a ChunkMergeApproach at the end

val df = Seq(("08/02/2018"),("11/2018"),("11/01/2018"),("next monday"),("today"),("next week")).toDF("text")

val documentAssembler = new DocumentAssembler().setInputCol("text").setOutputCol("document")

val chunksDF = documentAssembler
                          .transform(df)
                          .mapAnnotationsCol[Seq[Annotation]]("document",
                                                              "chunk_date",
                                                               CHUNK,
                                                          (aa:Seq[Annotation]) =>
                                                            aa.map( ann => ann.copy(annotatorType = CHUNK)
)
)
val dateNormalizerModel = new DateNormalizer()
        .setInputCols("chunk_date")
        .setOutputCol("date")
        .setAnchorDateDay(15)
        .setAnchorDateMonth(3)
        .setAnchorDateYear(2000)
val dateDf = dateNormalizerModel.transform(chunksDF)

Show results

dateDf.select("chunk_date.result","text").show()
  +-------------+-----------+
  |       result|       text|
  +-------------+-----------+
  | [08/02/2018]| 08/02/2018|
  |    [11/2018]|    11/2018|
  | [11/01/2018]| 11/01/2018|
  |[next monday]|next monday|
  |      [today]|      today|
  |  [next week]|  next week|
  +-------------+-----------+
Linear Supertypes
HasSimpleAnnotate[DateNormalizer], AnnotatorModel[DateNormalizer], CanBeLazy, RawAnnotator[DateNormalizer], HasOutputAnnotationCol, HasInputAnnotationCols, HasOutputAnnotatorType, ParamsAndFeaturesWritable, HasFeatures, DefaultParamsWritable, MLWritable, Model[DateNormalizer], Transformer, PipelineStage, Logging, Params, Serializable, Serializable, Identifiable, AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. DateNormalizer
  2. HasSimpleAnnotate
  3. AnnotatorModel
  4. CanBeLazy
  5. RawAnnotator
  6. HasOutputAnnotationCol
  7. HasInputAnnotationCols
  8. HasOutputAnnotatorType
  9. ParamsAndFeaturesWritable
  10. HasFeatures
  11. DefaultParamsWritable
  12. MLWritable
  13. Model
  14. Transformer
  15. PipelineStage
  16. Logging
  17. Params
  18. Serializable
  19. Serializable
  20. Identifiable
  21. AnyRef
  22. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

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

    uid

    a unique identifier for the instantiated AnnotatorModel

Type Members

  1. type AnnotationContent = Seq[Row]
    Attributes
    protected
    Definition Classes
    AnnotatorModel
  2. 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. def _transform(dataset: Dataset[_], recursivePipeline: Option[PipelineModel]): DataFrame
    Attributes
    protected
    Definition Classes
    AnnotatorModel
  10. def afterAnnotate(dataset: DataFrame): DataFrame
    Attributes
    protected
    Definition Classes
    AnnotatorModel
  11. val anchorDateDay: Param[Int]

    Add an anchor day for the relative dates such as a day after tomorrow (Default: -1).

    Add an anchor day for the relative dates such as a day after tomorrow (Default: -1). By default it will use the current day. The first day of the month has value 1.

  12. val anchorDateMonth: Param[Int]

    Add an anchor month for the relative dates such as a day after tomorrow (Default: -1).

    Add an anchor month for the relative dates such as a day after tomorrow (Default: -1). By default it will use the current month. Month values start from 1, so 1 stands for January.

  13. val anchorDateYear: Param[Int]

    Add an anchor year for the relative dates such as a day after tomorrow (Default: -1).

    Add an anchor year for the relative dates such as a day after tomorrow (Default: -1). If it is not set, the by default it will use the current year. Example: 2021

  14. def annotate(annotations: Seq[Annotation]): Seq[Annotation]
    Definition Classes
    DateNormalizer → HasSimpleAnnotate
  15. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  16. def beforeAnnotate(dataset: Dataset[_]): Dataset[_]
    Attributes
    protected
    Definition Classes
    AnnotatorModel
  17. def calculateAnchorCalendar(): Calendar
    Attributes
    protected
  18. final def checkSchema(schema: StructType, inputAnnotatorType: String): Boolean
    Attributes
    protected
    Definition Classes
    HasInputAnnotationCols
  19. final def clear(param: Param[_]): DateNormalizer.this.type
    Definition Classes
    Params
  20. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  21. def copy(extra: ParamMap): DateNormalizer
    Definition Classes
    RawAnnotator → Model → Transformer → PipelineStage → Params
  22. def copyValues[T <: Params](to: T, extra: ParamMap): T
    Attributes
    protected
    Definition Classes
    Params
  23. final def defaultCopy[T <: Params](extra: ParamMap): T
    Attributes
    protected
    Definition Classes
    Params
  24. val defaultReplacementDay: Param[Int]

    Defines which value to use for creating the Day Value when original Date-Entity has no Day Information.

    Defines which value to use for creating the Day Value when original Date-Entity has no Day Information. Defaults to 15.

  25. val defaultReplacementMonth: Param[Int]

    Defines which value to use for creating the Month Value when original Date-Entity has no Day Information.

    Defines which value to use for creating the Month Value when original Date-Entity has no Day Information. Defaults to 6.

  26. val defaultReplacementYear: Param[Int]

    Defines which value to use for creating the Year Value when original Date-Entity has no Day Information.

    Defines which value to use for creating the Year Value when original Date-Entity has no Day Information. Defaults to 2020.

  27. def dfAnnotate: UserDefinedFunction
    Definition Classes
    HasSimpleAnnotate
  28. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  29. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  30. def explainParam(param: Param[_]): String
    Definition Classes
    Params
  31. def explainParams(): String
    Definition Classes
    Params
  32. def extraValidate(structType: StructType): Boolean
    Attributes
    protected
    Definition Classes
    RawAnnotator
  33. def extraValidateMsg: String
    Attributes
    protected
    Definition Classes
    RawAnnotator
  34. final def extractParamMap(): ParamMap
    Definition Classes
    Params
  35. final def extractParamMap(extra: ParamMap): ParamMap
    Definition Classes
    Params
  36. val features: ArrayBuffer[Feature[_, _, _]]
    Definition Classes
    HasFeatures
  37. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  38. def get[T](feature: StructFeature[T]): Option[T]
    Attributes
    protected
    Definition Classes
    HasFeatures
  39. def get[K, V](feature: MapFeature[K, V]): Option[Map[K, V]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  40. def get[T](feature: SetFeature[T]): Option[Set[T]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  41. def get[T](feature: ArrayFeature[T]): Option[Array[T]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  42. final def get[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  43. def getAnchorDateDay: Int

  44. def getAnchorDateMonth: Int

  45. def getAnchorDateYear: Int

  46. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  47. final def getDefault[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  48. def getDefaultReplacementDay: Int
  49. def getDefaultReplacementMonth: Int
  50. def getDefaultReplacementYear: Int
  51. def getInputCols: Array[String]
    Definition Classes
    HasInputAnnotationCols
  52. def getLazyAnnotator: Boolean
    Definition Classes
    CanBeLazy
  53. final def getOrDefault[T](param: Param[T]): T
    Definition Classes
    Params
  54. final def getOutputCol: String
    Definition Classes
    HasOutputAnnotationCol
  55. def getOutputDateformat(): String
  56. def getParam(paramName: String): Param[Any]
    Definition Classes
    Params
  57. final def hasDefault[T](param: Param[T]): Boolean
    Definition Classes
    Params
  58. def hasParam(paramName: String): Boolean
    Definition Classes
    Params
  59. def hasParent: Boolean
    Definition Classes
    Model
  60. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  61. def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  62. def initializeLogIfNecessary(isInterpreter: Boolean): Unit
    Attributes
    protected
    Definition Classes
    Logging
  63. val inputAnnotatorTypes: Array[String]
    Definition Classes
    DateNormalizer → HasInputAnnotationCols
  64. final val inputCols: StringArrayParam
    Attributes
    protected
    Definition Classes
    HasInputAnnotationCols
  65. final def isDefined(param: Param[_]): Boolean
    Definition Classes
    Params
  66. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  67. final def isSet(param: Param[_]): Boolean
    Definition Classes
    Params
  68. def isTraceEnabled(): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  69. val lazyAnnotator: BooleanParam
    Definition Classes
    CanBeLazy
  70. def log: Logger
    Attributes
    protected
    Definition Classes
    Logging
  71. def logDebug(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  72. def logDebug(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  73. def logError(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  74. def logError(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  75. def logInfo(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  76. def logInfo(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  77. def logName: String
    Attributes
    protected
    Definition Classes
    Logging
  78. def logTrace(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  79. def logTrace(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  80. def logWarning(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  81. def logWarning(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  82. def msgHelper(schema: StructType): String
    Attributes
    protected
    Definition Classes
    HasInputAnnotationCols
  83. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  84. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  85. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  86. def onWrite(path: String, spark: SparkSession): Unit
    Attributes
    protected
    Definition Classes
    ParamsAndFeaturesWritable
  87. val optionalInputAnnotatorTypes: Array[String]
    Definition Classes
    HasInputAnnotationCols
  88. val outputAnnotatorType: AnnotatorType
    Definition Classes
    DateNormalizer → HasOutputAnnotatorType
  89. final val outputCol: Param[String]
    Attributes
    protected
    Definition Classes
    HasOutputAnnotationCol
  90. val outputDateFormat: Param[String]

    Select what output format should I use By default it will use the current day.

    Select what output format should I use By default it will use the current day. The first day of the month has value 1.

  91. lazy val params: Array[Param[_]]
    Definition Classes
    Params
  92. var parent: Estimator[DateNormalizer]
    Definition Classes
    Model
  93. def save(path: String): Unit
    Definition Classes
    MLWritable
    Annotations
    @Since( "1.6.0" ) @throws( ... )
  94. def set[T](feature: StructFeature[T], value: T): DateNormalizer.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  95. def set[K, V](feature: MapFeature[K, V], value: Map[K, V]): DateNormalizer.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  96. def set[T](feature: SetFeature[T], value: Set[T]): DateNormalizer.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  97. def set[T](feature: ArrayFeature[T], value: Array[T]): DateNormalizer.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  98. final def set(paramPair: ParamPair[_]): DateNormalizer.this.type
    Attributes
    protected
    Definition Classes
    Params
  99. final def set(param: String, value: Any): DateNormalizer.this.type
    Attributes
    protected
    Definition Classes
    Params
  100. final def set[T](param: Param[T], value: T): DateNormalizer.this.type
    Definition Classes
    Params
  101. def setAnchorDateDay(value: Int): DateNormalizer.this.type

  102. def setAnchorDateMonth(value: Int): DateNormalizer.this.type

  103. def setAnchorDateYear(value: Int): DateNormalizer.this.type

  104. def setDefault[T](feature: StructFeature[T], value: () ⇒ T): DateNormalizer.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  105. def setDefault[K, V](feature: MapFeature[K, V], value: () ⇒ Map[K, V]): DateNormalizer.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  106. def setDefault[T](feature: SetFeature[T], value: () ⇒ Set[T]): DateNormalizer.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  107. def setDefault[T](feature: ArrayFeature[T], value: () ⇒ Array[T]): DateNormalizer.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  108. final def setDefault(paramPairs: ParamPair[_]*): DateNormalizer.this.type
    Attributes
    protected
    Definition Classes
    Params
  109. final def setDefault[T](param: Param[T], value: T): DateNormalizer.this.type
    Attributes
    protected[org.apache.spark.ml]
    Definition Classes
    Params
  110. def setDefaultReplacementDay(value: Int): DateNormalizer.this.type
  111. def setDefaultReplacementMonth(value: Int): DateNormalizer.this.type
  112. def setDefaultReplacementYear(value: Int): DateNormalizer.this.type
  113. final def setInputCols(value: String*): DateNormalizer.this.type
    Definition Classes
    HasInputAnnotationCols
  114. def setInputCols(value: Array[String]): DateNormalizer.this.type
    Definition Classes
    HasInputAnnotationCols
  115. def setLazyAnnotator(value: Boolean): DateNormalizer.this.type
    Definition Classes
    CanBeLazy
  116. final def setOutputCol(value: String): DateNormalizer.this.type
    Definition Classes
    HasOutputAnnotationCol
  117. def setOutputDateformat(value: String): DateNormalizer.this.type

  118. def setParent(parent: Estimator[DateNormalizer]): DateNormalizer
    Definition Classes
    Model
  119. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  120. def toString(): String
    Definition Classes
    Identifiable → AnyRef → Any
  121. final def transform(dataset: Dataset[_]): DataFrame
    Definition Classes
    AnnotatorModel → Transformer
  122. def transform(dataset: Dataset[_], paramMap: ParamMap): DataFrame
    Definition Classes
    Transformer
    Annotations
    @Since( "2.0.0" )
  123. def transform(dataset: Dataset[_], firstParamPair: ParamPair[_], otherParamPairs: ParamPair[_]*): DataFrame
    Definition Classes
    Transformer
    Annotations
    @Since( "2.0.0" ) @varargs()
  124. final def transformSchema(schema: StructType): StructType
    Definition Classes
    RawAnnotator → PipelineStage
  125. def transformSchema(schema: StructType, logging: Boolean): StructType
    Attributes
    protected
    Definition Classes
    PipelineStage
    Annotations
    @DeveloperApi()
  126. val uid: String
    Definition Classes
    DateNormalizer → Identifiable
  127. def validate(schema: StructType): Boolean
    Attributes
    protected
    Definition Classes
    RawAnnotator
  128. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  129. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  130. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  131. def wrapColumnMetadata(col: Column): Column
    Attributes
    protected
    Definition Classes
    RawAnnotator
  132. def write: MLWriter
    Definition Classes
    ParamsAndFeaturesWritable → DefaultParamsWritable → MLWritable

Inherited from HasSimpleAnnotate[DateNormalizer]

Inherited from AnnotatorModel[DateNormalizer]

Inherited from CanBeLazy

Inherited from RawAnnotator[DateNormalizer]

Inherited from HasOutputAnnotationCol

Inherited from HasInputAnnotationCols

Inherited from HasOutputAnnotatorType

Inherited from ParamsAndFeaturesWritable

Inherited from HasFeatures

Inherited from DefaultParamsWritable

Inherited from MLWritable

Inherited from Model[DateNormalizer]

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

Members

Parameter setters

Parameter getters