Entity recognition

From aifinlab/FinClaw · View interactive version

Entity recognition is an AI agent skill from the GitHub repository aifinlab/FinClaw. 用于金融文本中实体识别的原子技能,包括公司主体、金融产品、监管机构、关键人物等实体类型的识别和抽取。适用于公告解析、报告分析、风险监控和合规检查等金融场景。

How to use this skill

Skill file

实体识别 Skill

数据来源

本 Skill 支持多种金融文本数据输入,核心数据来源包括:

1. 金融文档类型

2. 文本格式支持

3. 实体字典与规则库

说明:本 Skill 主要基于规则和字典匹配进行实体识别,对于复杂语境下的实体消歧和关系抽取能力有限。建议结合上下文分析和人工复核使用。


功能

本 Skill 提供全面的金融实体识别能力,涵盖四大类实体类型:

1. 主体实体识别

2. 产品实体识别

3. 数值实体识别

4. 事件实体识别

5. 高级处理功能


使用示例

1. 安装依赖

pip install -r requirements.txt

2. 基础使用

# 识别文本中的实体
python scripts/recognize_entities.py --input announcement.txt --output entities.json

# 指定识别的实体类型
python scripts/recognize_entities.py --input report.txt --output companies.json --entity-type company

# 使用自定义实体字典
python scripts/recognize_entities.py --input text.txt --output results.json --dictionary custom_dict.csv

3. 批量处理

# 批量处理多个文件
python scripts/batch_recognize.py --input-dir ./documents --output-dir ./results --format json

# 处理PDF文档(需先转换为文本)
python scripts/process_pdf.py --input document.pdf --output text.txt
python scripts/recognize_entities.py --input text.txt --output entities.json

4. 高级配置

# 设置置信度阈值
python scripts/recognize_entities.py --input text.txt --output results.json --confidence-threshold 0.8

# 启用实体消歧
python scripts/recognize_entities.py --input text.txt --output results.json --disambiguation true

# 导出可视化结果
python scripts/recognize_entities.py --input text.txt --output visualization.html --format html

5. 输出示例

{
  "document_id": "announcement_20250315_001",
  "source_file": "announcement.txt",
  "processing_time": "2025-03-15T17:50:00",
  "entities": [
    {
      "text": "贵州茅台酒股份有限公司",
      "type": "company",
      "subtype": "listed_company",
      "normalized_name": "贵州茅台",
      "stock_code": "600519",
      "confidence": 0.95,
      "position": {
        "start": 120,
        "end": 130,
        "sentence": "贵州茅台酒股份有限公司发布2024年度报告"
      },
      "attributes": {
        "industry": "白酒制造",
        "exchange": "上海证券交易所"
      }
    },
    {
      "text": "人民币100亿元",
      "type": "amount",
      "subtype": "rmb_amount",
      "normalized_value": 10000000000,
      "currency": "CNY",
      "confidence": 0.98,
      "position": {
        "start": 250,
        "end": 260,
        "sentence": "公司拟向全体股东每10股派发现金红利人民币100亿元"
      }
    },
    {
      "text": "中国证券监督管理委员会",
      "type": "regulatory_body",
      "subtype": "securities_regulator",
      "normalized_name": "证监会",
      "abbreviation": "CSRC",
      "confidence": 0.99,
      "position": {
        "start": 350,
        "end": 365,
        "sentence": "根据中国证券监督管理委员会的相关规定"
      }
    }
  ],
  "statistics": {
    "total_entities": 45,
    "by_type": {
      "company": 12,
      "amount": 8,
      "date": 10,
      "regulatory_body": 3,
      "person": 7,
      "product": 5
    },
    "average_confidence": 0.92
  },
  "relationships": [
    {
      "source": "贵州茅台",
      "target": "丁雄军",
      "relation": "chairman_of",
      "confidence": 0.88,
      "evidence": "丁雄军先生担任贵州茅台酒股份有限公司董事长"
    }
  ]
}

注意事项与限制

1. 识别准确性

2. 上下文依赖

3. 领域适应性

4. 性能考虑

5. 使用限制

6. 合规要求


参考资料

License

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.