c

com.johnsnowlabs.nlp.annotators.ner

NerConverterInternal

class NerConverterInternal extends AnnotatorApproach[NerConverterInternalModel]

Converts a IOB or IOB2 representation of NER to a user-friendly one, by associating the tokens of recognized entities and their label. Chunks with no associated entity (tagged "O") are filtered. See also Inside–outside–beginning (tagging) for more information.

Example

The output of a MedicalNerModel follows the Annotator schema and looks like this after the transformation.

result.selectExpr("explode(ner_result)").show(5, false)
+--------------------------------------------------------------------------+
|col                                                                       |
+--------------------------------------------------------------------------+
|{named_entity, 3, 3, O, {word -> A, confidence -> 0.994}, []}             |
|{named_entity, 5, 15, B-Age, {word -> 63-year-old, confidence -> 1.0}, []}|
|{named_entity, 17, 19, B-Gender, {word -> man, confidence -> 0.9858}, []} |
|{named_entity, 21, 28, O, {word -> presents, confidence -> 0.9952}, []}   |
|{named_entity, 30, 31, O, {word -> to, confidence -> 0.7063}, []}         |
+--------------------------------------------------------------------------+

After the converter is used:

result.selectExpr("explode(ner_converter_result)").show(5, false)
+-----------------------------------------------------------------------------------+
|col                                                                                |
+-----------------------------------------------------------------------------------+
|{chunk, 5, 15, 63-year-old, {entity -> Age, sentence -> 0, chunk -> 0}, []}        |
|{chunk, 17, 19, man, {entity -> Gender, sentence -> 0, chunk -> 1}, []}            |
|{chunk, 64, 72, recurrent, {entity -> Modifier, sentence -> 0, chunk -> 2}, []}    |
|{chunk, 98, 107, cellulitis, {entity -> Diagnosis, sentence -> 0, chunk -> 3}, []} |
|{chunk, 110, 119, pneumonias, {entity -> Diagnosis, sentence -> 0, chunk -> 4}, []}|
+-----------------------------------------------------------------------------------+
See also

MedicalNerModel

Linear Supertypes
AnnotatorApproach[NerConverterInternalModel], CanBeLazy, DefaultParamsWritable, MLWritable, HasOutputAnnotatorType, HasOutputAnnotationCol, HasInputAnnotationCols, Estimator[NerConverterInternalModel], PipelineStage, Logging, Params, Serializable, Serializable, Identifiable, AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. NerConverterInternal
  2. AnnotatorApproach
  3. CanBeLazy
  4. DefaultParamsWritable
  5. MLWritable
  6. HasOutputAnnotatorType
  7. HasOutputAnnotationCol
  8. HasInputAnnotationCols
  9. Estimator
  10. PipelineStage
  11. Logging
  12. Params
  13. Serializable
  14. Serializable
  15. Identifiable
  16. AnyRef
  17. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new NerConverterInternal()
  2. new NerConverterInternal(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. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  5. def _fit(dataset: Dataset[_], recursiveStages: Option[PipelineModel]): NerConverterInternalModel
    Attributes
    protected
    Definition Classes
    AnnotatorApproach
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def beforeTraining(spark: SparkSession): Unit
    Definition Classes
    AnnotatorApproach
  8. val blackList: StringArrayParam
  9. final def checkSchema(schema: StructType, inputAnnotatorType: String): Boolean
    Attributes
    protected
    Definition Classes
    HasInputAnnotationCols
  10. final def clear(param: Param[_]): NerConverterInternal.this.type
    Definition Classes
    Params
  11. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  12. final def copy(extra: ParamMap): Estimator[NerConverterInternalModel]
    Definition Classes
    AnnotatorApproach → Estimator → PipelineStage → Params
  13. def copyValues[T <: Params](to: T, extra: ParamMap): T
    Attributes
    protected
    Definition Classes
    Params
  14. final def defaultCopy[T <: Params](extra: ParamMap): T
    Attributes
    protected
    Definition Classes
    Params
  15. val description: String
    Definition Classes
    NerConverterInternal → AnnotatorApproach
  16. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  18. def explainParam(param: Param[_]): String
    Definition Classes
    Params
  19. def explainParams(): String
    Definition Classes
    Params
  20. final def extractParamMap(): ParamMap
    Definition Classes
    Params
  21. final def extractParamMap(extra: ParamMap): ParamMap
    Definition Classes
    Params
  22. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  23. final def fit(dataset: Dataset[_]): NerConverterInternalModel
    Definition Classes
    AnnotatorApproach → Estimator
  24. def fit(dataset: Dataset[_], paramMaps: Seq[ParamMap]): Seq[NerConverterInternalModel]
    Definition Classes
    Estimator
    Annotations
    @Since( "2.0.0" )
  25. def fit(dataset: Dataset[_], paramMap: ParamMap): NerConverterInternalModel
    Definition Classes
    Estimator
    Annotations
    @Since( "2.0.0" )
  26. def fit(dataset: Dataset[_], firstParamPair: ParamPair[_], otherParamPairs: ParamPair[_]*): NerConverterInternalModel
    Definition Classes
    Estimator
    Annotations
    @Since( "2.0.0" ) @varargs()
  27. final def get[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  28. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  29. final def getDefault[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  30. def getInputCols: Array[String]
    Definition Classes
    HasInputAnnotationCols
  31. def getLazyAnnotator: Boolean
    Definition Classes
    CanBeLazy
  32. final def getOrDefault[T](param: Param[T]): T
    Definition Classes
    Params
  33. final def getOutputCol: String
    Definition Classes
    HasOutputAnnotationCol
  34. def getParam(paramName: String): Param[Any]
    Definition Classes
    Params
  35. def getThreshold: Float

    Get the Confidence threshold

  36. val greedyMode: BooleanParam

    Whether to ignore B tags for contiguous tokens of same entity same

  37. final def hasDefault[T](param: Param[T]): Boolean
    Definition Classes
    Params
  38. def hasParam(paramName: String): Boolean
    Definition Classes
    Params
  39. lazy val hasThreshold: Boolean
  40. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  41. def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  42. def initializeLogIfNecessary(isInterpreter: Boolean): Unit
    Attributes
    protected
    Definition Classes
    Logging
  43. val inputAnnotatorTypes: Array[String]

    Input Annotator Type : DOCUMENT, TOKEN, NAMED_ENTITY

    Input Annotator Type : DOCUMENT, TOKEN, NAMED_ENTITY

    Definition Classes
    NerConverterInternal → HasInputAnnotationCols
  44. final val inputCols: StringArrayParam
    Attributes
    protected
    Definition Classes
    HasInputAnnotationCols
  45. final def isDefined(param: Param[_]): Boolean
    Definition Classes
    Params
  46. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  47. final def isSet(param: Param[_]): Boolean
    Definition Classes
    Params
  48. def isTraceEnabled(): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  49. val lazyAnnotator: BooleanParam
    Definition Classes
    CanBeLazy
  50. def log: Logger
    Attributes
    protected
    Definition Classes
    Logging
  51. def logDebug(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  52. def logDebug(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  53. def logError(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  54. def logError(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  55. def logInfo(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  56. def logInfo(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  57. def logName: String
    Attributes
    protected
    Definition Classes
    Logging
  58. def logTrace(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  59. def logTrace(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  60. def logWarning(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  61. def logWarning(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  62. def msgHelper(schema: StructType): String
    Attributes
    protected
    Definition Classes
    HasInputAnnotationCols
  63. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  64. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  65. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  66. def onTrained(model: NerConverterInternalModel, spark: SparkSession): Unit
    Definition Classes
    AnnotatorApproach
  67. val optionalInputAnnotatorTypes: Array[String]
    Definition Classes
    HasInputAnnotationCols
  68. val outputAnnotatorType: AnnotatorType

    Output Annotator Type : CHUNK

    Output Annotator Type : CHUNK

    Definition Classes
    NerConverterInternal → HasOutputAnnotatorType
  69. final val outputCol: Param[String]
    Attributes
    protected
    Definition Classes
    HasOutputAnnotationCol
  70. lazy val params: Array[Param[_]]
    Definition Classes
    Params
  71. val preservePosition: BooleanParam

    Whether to preserve the original position of the tokens in the original document or use the modified tokens

  72. val replaceDictResource: ExternalResourceParam
  73. val replaceLabels: CustomLabels
  74. def save(path: String): Unit
    Definition Classes
    MLWritable
    Annotations
    @Since( "1.6.0" ) @throws( ... )
  75. final def set(paramPair: ParamPair[_]): NerConverterInternal.this.type
    Attributes
    protected
    Definition Classes
    Params
  76. final def set(param: String, value: Any): NerConverterInternal.this.type
    Attributes
    protected
    Definition Classes
    Params
  77. final def set[T](param: Param[T], value: T): NerConverterInternal.this.type
    Definition Classes
    Params
  78. def setBlackList(list: String*): NerConverterInternal.this.type

    If defined, list of entities to ignore.

    If defined, list of entities to ignore. The rest will be processed. Do not include IOB prefix on labels

  79. final def setDefault(paramPairs: ParamPair[_]*): NerConverterInternal.this.type
    Attributes
    protected
    Definition Classes
    Params
  80. final def setDefault[T](param: Param[T], value: T): NerConverterInternal.this.type
    Attributes
    protected
    Definition Classes
    Params
  81. def setGreedyMode(value: Boolean): NerConverterInternal.this.type

    Whether to ignore B tags for contiguous tokens of same entity same

  82. final def setInputCols(value: String*): NerConverterInternal.this.type
    Definition Classes
    HasInputAnnotationCols
  83. def setInputCols(value: Array[String]): NerConverterInternal.this.type
    Definition Classes
    HasInputAnnotationCols
  84. def setLazyAnnotator(value: Boolean): NerConverterInternal.this.type
    Definition Classes
    CanBeLazy
  85. final def setOutputCol(value: String): NerConverterInternal.this.type
    Definition Classes
    HasOutputAnnotationCol
  86. def setPreservePosition(value: Boolean): NerConverterInternal.this.type

    Whether to preserve the original position of the tokens in the original document or use the modified tokens

  87. def setReplaceDictResource(path: String, readAs: Format = ReadAs.TEXT, options: Map[String, String] = Map("delimiter" -> ",")): NerConverterInternal.this.type
  88. def setReplaceDictResource(path: ExternalResource): NerConverterInternal.this.type
  89. def setReplaceLabels(labels: Map[String, String]): NerConverterInternal.this.type
  90. def setThreshold(value: Float): NerConverterInternal.this.type

    Set the Confidence threshold

  91. def setWhiteList(list: String*): NerConverterInternal.this.type

    If defined, list of entities to ignore.

    If defined, list of entities to ignore. The rest will be processed. Do not include IOB prefix on labels

  92. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  93. val threshold: FloatParam

    Confidence threshold

  94. def toString(): String
    Definition Classes
    Identifiable → AnyRef → Any
  95. def train(dataset: Dataset[_], recursivePipeline: Option[PipelineModel]): NerConverterInternalModel
    Definition Classes
    NerConverterInternal → AnnotatorApproach
  96. def transformReplaceDict(replaceDict: Array[(String, String)]): Map[String, String]
  97. final def transformSchema(schema: StructType): StructType
    Definition Classes
    AnnotatorApproach → PipelineStage
  98. def transformSchema(schema: StructType, logging: Boolean): StructType
    Attributes
    protected
    Definition Classes
    PipelineStage
    Annotations
    @DeveloperApi()
  99. val uid: String
    Definition Classes
    NerConverterInternal → Identifiable
  100. def validate(schema: StructType): Boolean
    Attributes
    protected
    Definition Classes
    AnnotatorApproach
  101. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  102. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  103. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  104. val whiteList: StringArrayParam

    If defined, list of entities to process.

    If defined, list of entities to process. The rest will be ignored. Does not include IOB prefix on labels

  105. def write: MLWriter
    Definition Classes
    DefaultParamsWritable → MLWritable

Inherited from AnnotatorApproach[NerConverterInternalModel]

Inherited from CanBeLazy

Inherited from DefaultParamsWritable

Inherited from MLWritable

Inherited from HasOutputAnnotatorType

Inherited from HasOutputAnnotationCol

Inherited from HasInputAnnotationCols

Inherited from Estimator[NerConverterInternalModel]

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

Annotator types

Required input and expected output annotator types

Members

Parameter setters