Spark NLP可视化软件包
spark-nlp-displa的Python项目详细描述
火花nlp显示器
一个用于简单可视化不同类型的Spark NLP注释的库。在
支持的可视化:
- 依赖关系分析器
- 命名实体识别
- 实体解析
- 关系抽取
- 断言状态
完成教程
https://github.com/JohnSnowLabs/spark-nlp-display/blob/main/tutorials/Spark_NLP_Display.ipynb
要求
- 火花nlp
- 伊普顿
- 斯维格瑞特
- 熊猫
- numpy公司
安装
pip install spark-nlp-display
如何使用
依赖关系分析器
^{pr2}$命名实体识别
fromsparknlp_displayimportNerVisualizerner_vis=NerVisualizer()ner_vis.display(pipeline_result[0],#should be the results of a single example, not the complete dataframelabel_col='entities',#specify the entity columndocument_col='document'#specify the document column (default: 'document')labels=['PER']#only allow these labels to be displayed. (default: [] - all labels will be displayed))## To set custom label colors:ner_vis.set_label_colors({'LOC':'#800080','PER':'#77b5fe'})#set label colors by specifying hex codes
实体解析
fromsparknlp_displayimportEntityResolverVisualizerer_vis=EntityResolverVisualizer()er_vis.display(pipeline_result[0],#should be the results of a single example, not the complete dataframelabel_col='entities',#specify the ner result columnresolution_col='resolution'document_col='document'#specify the document column (default: 'document'))## To set custom label colors:er_vis.set_label_colors({'TREATMENT':'#800080','PROBLEM':'#77b5fe'})#set label colors by specifying hex codes
关系抽取
fromsparknlp_displayimportRelationExtractionVisualizerre_vis=RelationExtractionVisualizer()re_vis.display(pipeline_result[0],#should be the results of a single example, not the complete dataframerelation_col='relations',#specify relations columndocument_col='document',#specify document columnshow_relations=True#display relation names on arrows (default: True))
断言状态
fromsparknlp_displayimportAssertionVisualizerassertion_vis=AssertionVisualizer()assertion_vis.display(pipeline_result[0],label_col='entities',#specify the ner result columnassertion_col='assertion'#specify assertion columndocument_col='document'#specify the document column (default: 'document'))## To set custom label colors:assertion_vis.set_label_colors({'TREATMENT':'#008080','problem':'#800080'})#set label colors by specifying hex codes
标签:
- 项目
标签: