sparknlp.base.graph_finisher#

Contains classes for the GraphFinisher.

Module Contents#

Classes#

GraphFinisher

Helper class to convert the knowledge graph from GraphExtraction into a

class GraphFinisher[source]#

Helper class to convert the knowledge graph from GraphExtraction into a generic format, such as RDF.

Input Annotation types

Output Annotation type

NONE

NONE

Parameters:
inputCol

Name of input annotation column

outputCol

Name of finisher output column

cleanAnnotations

Whether to remove all the existing annotation columns, by default True

outputAsArray

Whether to generate an Array with the results, by default True

Examples

This is a continuation of the example of GraphExtraction. To see how the graph is extracted, see the documentation of that class.

>>> graphFinisher = GraphFinisher() \
...     .setInputCol("graph") \
...     .setOutputCol("graph_finished")
...     .setOutputAsArray(False)
>>> finishedResult = graphFinisher.transform(result)
>>> finishedResult.select("text", "graph_finished").show(truncate=False)
+-----------------------------------------------------+-----------------------------------------------------------------------+
|text                                                 |graph_finished                                                         |
+-----------------------------------------------------+-----------------------------------------------------------------------+
|You and John prefer the morning flight through Denver|[[(prefer,nsubj,morning), (morning,flat,flight), (flight,flat,Denver)]]|
+-----------------------------------------------------+-----------------------------------------------------------------------+
setInputCol(value)[source]#

Sets name of input annotation column.

Parameters:
valuestr

Name of input annotation column.

setOutputCol(value)[source]#

Sets name of finisher output column.

Parameters:
valuestr

Name of finisher output column.

setCleanAnnotations(value)[source]#

Sets whether to remove all the existing annotation columns, by default True.

Parameters:
valuebool

Whether to remove all the existing annotation columns, by default True.

setOutputAsArray(value)[source]#

Sets whether to generate an Array with the results, by default True.

Parameters:
valuebool

Whether to generate an Array with the results, by default True.