feat: expose neural entity extraction APIs (v5.7.6 - Workshop request)
Addresses Workshop team's request for direct access to neural extraction classes.
**Changes:**
1. **New Exports** (src/index.ts):
- `NeuralEntityExtractor` - Full extraction orchestrator
- `SmartExtractor` - Entity type classifier (4-signal ensemble)
- `SmartRelationshipExtractor` - Relationship type classifier
- Types: `ExtractedEntity`, `ExtractionResult`, `RelationshipExtractionResult`, etc.
2. **Package.json Subpath Exports**:
```typescript
// Enable direct imports:
import { NeuralEntityExtractor } from '@soulcraft/brainy/neural/entityExtractor'
import { SmartExtractor } from '@soulcraft/brainy/neural/SmartExtractor'
import { SmartRelationshipExtractor } from '@soulcraft/brainy/neural/SmartRelationshipExtractor'
```
3. **New brain.extractEntities() Method** (brainy.ts:3254):
- Alias for `brain.extract()` with clearer naming
- Documented with examples and architecture details
- 4-signal ensemble: ExactMatch (40%) + Embedding (35%) + Pattern (20%) + Context (5%)
4. **Comprehensive Documentation** (docs/neural-extraction.md):
- Complete neural extraction guide (200+ lines)
- API reference for all extraction classes
- Performance optimization tips
- Import preview mode documentation
- Confidence scoring explanation
- 42 NounType detection methods
- Troubleshooting guide
- Real-world examples
5. **README Updates**:
- Added "Entity Extraction" section with examples
- Links to neural extraction guide
- Import preview mode link
**Features:**
- ⚡ Fast extraction: ~15-20ms per entity
- 🎯 4-signal ensemble architecture
- 📊 Format intelligence (Excel, CSV, PDF, YAML, DOCX, JSON, Markdown)
- 🌍 42 universal noun types + 127 verb types
- 💾 LRU caching built-in
- 🧪 Production-tested in import pipeline
**Usage:**
```typescript
// Simple API (recommended)
const entities = await brain.extractEntities('John Smith founded Acme Corp', {
types: [NounType.Person, NounType.Organization],
confidence: 0.7
})
// Advanced API (custom configuration)
import { SmartExtractor } from '@soulcraft/brainy'
const extractor = new SmartExtractor(brain, { minConfidence: 0.8 })
const result = await extractor.extract('CEO', {
formatContext: { format: 'excel', columnHeader: 'Title' }
})
```
**Backward Compatible:** All existing APIs unchanged. New exports are pure additions.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
201fbed78c
commit
8cca096d7e
5 changed files with 794 additions and 0 deletions
|
|
@ -3228,6 +3228,41 @@ export class Brainy<T = any> implements BrainyInterface<T> {
|
|||
return await this._extractor.extract(text, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract entities from text (alias for extract())
|
||||
* v5.7.6: Added for API clarity and Workshop team request
|
||||
*
|
||||
* Uses NeuralEntityExtractor with SmartExtractor ensemble (4-signal architecture):
|
||||
* - ExactMatch (40%) - Dictionary lookups
|
||||
* - Embedding (35%) - Semantic similarity
|
||||
* - Pattern (20%) - Regex patterns
|
||||
* - Context (5%) - Contextual hints
|
||||
*
|
||||
* @param text - Text to extract entities from
|
||||
* @param options - Extraction options
|
||||
* @returns Array of extracted entities with types and confidence scores
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const entities = await brain.extractEntities('John Smith founded Acme Corp', {
|
||||
* confidence: 0.7,
|
||||
* types: [NounType.Person, NounType.Organization],
|
||||
* neuralMatching: true
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
async extractEntities(
|
||||
text: string,
|
||||
options?: {
|
||||
types?: NounType[]
|
||||
confidence?: number
|
||||
includeVectors?: boolean
|
||||
neuralMatching?: boolean
|
||||
}
|
||||
): Promise<ExtractedEntity[]> {
|
||||
return this.extract(text, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract concepts from text
|
||||
*
|
||||
|
|
|
|||
17
src/index.ts
17
src/index.ts
|
|
@ -70,6 +70,23 @@ export type {
|
|||
NeuralImportOptions
|
||||
} from './cortex/neuralImport.js'
|
||||
|
||||
// Export Neural Entity Extraction (v5.7.6 - Workshop request)
|
||||
export { NeuralEntityExtractor } from './neural/entityExtractor.js'
|
||||
export { SmartExtractor } from './neural/SmartExtractor.js'
|
||||
export { SmartRelationshipExtractor } from './neural/SmartRelationshipExtractor.js'
|
||||
export type {
|
||||
ExtractedEntity
|
||||
} from './neural/entityExtractor.js'
|
||||
export type {
|
||||
ExtractionResult,
|
||||
SmartExtractorOptions,
|
||||
FormatContext
|
||||
} from './neural/SmartExtractor.js'
|
||||
export type {
|
||||
RelationshipExtractionResult,
|
||||
SmartRelationshipExtractorOptions
|
||||
} from './neural/SmartRelationshipExtractor.js'
|
||||
|
||||
// Import Manager removed - use brain.import() instead (available on all Brainy instances)
|
||||
|
||||
// Augmentation types are already exported later in the file
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue