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raction
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
tags:
|
| 9 |
+
- entity-resolution
|
| 10 |
+
- named-entity-recognition
|
| 11 |
+
- company-data
|
| 12 |
+
- embeddings
|
| 13 |
+
- sqlite
|
| 14 |
+
- vector-search
|
| 15 |
+
size_categories:
|
| 16 |
+
- 1M<n<10M
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# Entity References Database
|
| 20 |
+
|
| 21 |
+
A pre-built SQLite database with vector embeddings for organization/entity resolution. Used by the [corp-extractor](https://pypi.org/project/corp-extractor/) library for fast entity qualification via embedding similarity search.
|
| 22 |
+
|
| 23 |
+
## Overview
|
| 24 |
+
|
| 25 |
+
This database contains organization records from multiple authoritative sources, each with:
|
| 26 |
+
- Organization name (canonical)
|
| 27 |
+
- Source identifier (LEI, CIK, UK Company Number, Wikidata QID)
|
| 28 |
+
- Entity type classification (business, nonprofit, government, etc.)
|
| 29 |
+
- Vector embeddings for semantic search (768-dim, using [embeddinggemma-300m](https://huggingface.co/google/embeddinggemma-300m))
|
| 30 |
+
|
| 31 |
+
## Data Sources
|
| 32 |
+
|
| 33 |
+
| Source | Records | Identifier | Description |
|
| 34 |
+
|--------|---------|------------|-------------|
|
| 35 |
+
| GLEIF | ~3.2M | LEI (Legal Entity Identifier) | Global legal entities from the LEI system |
|
| 36 |
+
| SEC Edgar | ~100K+ | CIK (Central Index Key) | US SEC-registered filers |
|
| 37 |
+
| Companies House | ~5M | UK Company Number | UK registered companies |
|
| 38 |
+
| Wikidata | Variable | Wikidata QID | Notable organizations from Wikidata |
|
| 39 |
+
|
| 40 |
+
## Entity Types
|
| 41 |
+
|
| 42 |
+
Organizations are classified into the following types:
|
| 43 |
+
|
| 44 |
+
| Category | Types |
|
| 45 |
+
|----------|-------|
|
| 46 |
+
| Business | `business`, `fund`, `branch` |
|
| 47 |
+
| Non-profit | `nonprofit`, `ngo`, `foundation`, `trade_union` |
|
| 48 |
+
| Government | `government`, `international_org`, `political_party` |
|
| 49 |
+
| Other | `educational`, `research`, `healthcare`, `media`, `sports`, `religious`, `unknown` |
|
| 50 |
+
|
| 51 |
+
## Database Variants
|
| 52 |
+
|
| 53 |
+
| File | Description | Use Case |
|
| 54 |
+
|------|-------------|----------|
|
| 55 |
+
| `entities.db` | Full database with complete source record metadata | When you need full record details |
|
| 56 |
+
| `entities-lite.db` | Lite version without record data | Default - faster download, smaller size |
|
| 57 |
+
| `entities.db.gz` | Compressed full database | When bandwidth is limited |
|
| 58 |
+
| `entities-lite.db.gz` | Compressed lite database | Smallest download size |
|
| 59 |
+
|
| 60 |
+
## Schema
|
| 61 |
+
|
| 62 |
+
### organizations table
|
| 63 |
+
```sql
|
| 64 |
+
CREATE TABLE organizations (
|
| 65 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 66 |
+
name TEXT NOT NULL,
|
| 67 |
+
name_normalized TEXT NOT NULL,
|
| 68 |
+
source TEXT NOT NULL, -- 'gleif', 'sec_edgar', 'companies_house', 'wikipedia'
|
| 69 |
+
source_id TEXT NOT NULL,
|
| 70 |
+
region TEXT NOT NULL DEFAULT '',
|
| 71 |
+
entity_type TEXT NOT NULL DEFAULT 'unknown',
|
| 72 |
+
record TEXT NOT NULL, -- JSON with full source record (empty in lite version)
|
| 73 |
+
UNIQUE(source, source_id)
|
| 74 |
+
);
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
### organization_embeddings table (sqlite-vec)
|
| 78 |
+
```sql
|
| 79 |
+
CREATE VIRTUAL TABLE organization_embeddings USING vec0(
|
| 80 |
+
org_id INTEGER PRIMARY KEY,
|
| 81 |
+
embedding float[768]
|
| 82 |
+
);
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
## Usage with corp-extractor
|
| 86 |
+
|
| 87 |
+
```bash
|
| 88 |
+
# Install
|
| 89 |
+
pip install corp-extractor
|
| 90 |
+
|
| 91 |
+
# Download the database (lite version by default)
|
| 92 |
+
corp-extractor db download
|
| 93 |
+
|
| 94 |
+
# Download full version
|
| 95 |
+
corp-extractor db download --full
|
| 96 |
+
|
| 97 |
+
# Search for an organization
|
| 98 |
+
corp-extractor db search "Microsoft"
|
| 99 |
+
|
| 100 |
+
# Check database status
|
| 101 |
+
corp-extractor db status
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
### Python API
|
| 105 |
+
|
| 106 |
+
```python
|
| 107 |
+
from statement_extractor.database import OrganizationDatabase, CompanyEmbedder
|
| 108 |
+
|
| 109 |
+
# Load database
|
| 110 |
+
database = OrganizationDatabase()
|
| 111 |
+
embedder = CompanyEmbedder()
|
| 112 |
+
|
| 113 |
+
# Search by embedding similarity
|
| 114 |
+
query_embedding = embedder.embed("Microsoft Corporation")
|
| 115 |
+
results = database.search(query_embedding, top_k=5)
|
| 116 |
+
|
| 117 |
+
for record, similarity in results:
|
| 118 |
+
print(f"{record.name} ({record.source}:{record.source_id}) - {similarity:.3f}")
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
## Building Your Own Database
|
| 122 |
+
|
| 123 |
+
```bash
|
| 124 |
+
# Import from authoritative sources
|
| 125 |
+
corp-extractor db import-gleif --download
|
| 126 |
+
corp-extractor db import-sec --download
|
| 127 |
+
corp-extractor db import-companies-house --download
|
| 128 |
+
corp-extractor db import-wikidata --limit 50000
|
| 129 |
+
|
| 130 |
+
# Upload to HuggingFace
|
| 131 |
+
export HF_TOKEN="hf_..."
|
| 132 |
+
corp-extractor db upload
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
## License
|
| 136 |
+
|
| 137 |
+
MIT License - the database structure and embedding generation code are MIT licensed.
|
| 138 |
+
|
| 139 |
+
Individual data sources have their own licenses:
|
| 140 |
+
- GLEIF: Open license for LEI data
|
| 141 |
+
- SEC Edgar: Public domain (US government)
|
| 142 |
+
- Companies House: Open Government Licence
|
| 143 |
+
- Wikidata: CC0 (public domain)
|
| 144 |
+
|
| 145 |
+
## Links
|
| 146 |
+
|
| 147 |
+
- [Corp-Extractor on PyPI](https://pypi.org/project/corp-extractor/)
|
| 148 |
+
- [Corp-Extractor GitHub](https://github.com/corp-o-rate/statement-extractor)
|
| 149 |
+
- [Statement Extractor Model](https://huggingface.co/Corp-o-Rate-Community/statement-extractor)
|