【问题标题】:how to extract contextual data from tables to train custom named entity recognizer?如何从表中提取上下文数据来训练自定义命名实体识别器?
【发布时间】:2019-11-18 18:41:07
【问题描述】:

我有包含表格的文档,我想提取上下文信息(例如句子或任何其他形式),以便我可以标记它们并构建命名实体识别器。

有谁知道我们如何构建上下文训练数据来训练命名实体识别器,或者我们如何注释表格数据来训练命名实体识别器。

【问题讨论】:

    标签: python-3.x scikit-learn nlp named-entity-recognition data-extraction


    【解决方案1】:

    您可以尝试使用 Spacy 构建客户 NER。该脚本可以根据您的需要进行调整。

    Spacy NER 格式:[https://dataturks.com/help/dataturks-ner-json-to-spacy-train.php]

    如果您有一个非常固定的 PDF 布局,您可以将它们转换为文本并使用此工具进行注释。这免费提供了类似于 Prodigy 的注释体验。

    Doccano 注释工具:[https://github.com/chakki-works/doccano]

    【讨论】:

      【解决方案2】:

      spacy-annotator 可以很好地解决您的问题。

      它允许您使用 ipywidgets 在文本中注释自定义实体。
      此外,注释器以 nlp 库 spaCy 喜欢的格式生成输出。

      注解示例:

      import pandas as pd
      import re
      from spacy_annotator.pandas_annotations import annotate as pd_annotate
      
      # Data
      df = pd.DataFrame.from_dict({'full_text' : ['New York is lovely but Milan is amazing!']})
      
      # Annotations
      pd_dd = pd_annotate(df,
                  col_text = 'full_text',     # Column in pandas dataframe containing text to be labelled
                  labels = ['GPE', 'PERSON'], # List of labels
                  sample_size=1,              # Size of the sample to be labelled
                  delimiter='~',              # Delimiter to separate entities in GUI
                  model = None,               # spaCy model for noisy pre-labelling
                  regex_flags=re.IGNORECASE   # One (or more) regex flags to be applied when searching for entities in text
                  )
      
      # Example output
      pd_dd['annotations'][0]
      

      【讨论】:

        猜你喜欢
        • 2011-10-20
        • 1970-01-01
        • 1970-01-01
        • 2019-01-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-06-22
        • 2019-12-16
        相关资源
        最近更新 更多