Spaces:
Sleeping
Sleeping
Download src/extract.ts from superlinked/document-ocr: direct link, hf CLI and curl.
- Browser
- Download file 477 Bytes
-
https://huggingface.co/spaces/superlinked/document-ocr/resolve/main/src/extract.ts
- Command line
-
hf download hf://spaces/superlinked/document-ocr/src/extract.ts
-
curl -L -o extract.ts https://huggingface.co/spaces/superlinked/document-ocr/resolve/main/src/extract.ts
477 Bytes
| import type { SIEClient } from "@superlinked/sie-sdk"; | |
| import type { ExtractedField } from "./types.js"; | |
| export async function extractFields( | |
| client: SIEClient, | |
| model: string, | |
| text: string, | |
| labels: string[], | |
| ): Promise<ExtractedField[]> { | |
| if (!text.trim()) return []; | |
| const result = await client.extract(model, { text }, { labels, threshold: 0.4 }); | |
| return (result.entities ?? []).map((e) => ({ | |
| label: e.label, | |
| text: e.text, | |
| score: e.score, | |
| })); | |
| } | |