This commit is contained in:
46
docs/snippets/swift/plugins/pdf_only_processor.md
Normal file
46
docs/snippets/swift/plugins/pdf_only_processor.md
Normal file
@@ -0,0 +1,46 @@
|
||||
```swift title="Swift"
|
||||
import Kreuzberg
|
||||
|
||||
final class PdfOnlyProcessor: PostProcessor {
|
||||
func name() -> String {
|
||||
"pdf-only-processor"
|
||||
}
|
||||
|
||||
func version() -> String {
|
||||
"1.0.0"
|
||||
}
|
||||
|
||||
func processingStage() -> String {
|
||||
"middle" // ProcessingStage enum name
|
||||
}
|
||||
|
||||
func priority() -> Int32 {
|
||||
50 // Default priority
|
||||
}
|
||||
|
||||
func process(result: ExtractionResult, config: ExtractionConfig) -> String {
|
||||
// Returns JSON-encoded Result<(), String>
|
||||
// No-op post-processor for PDF-only processing
|
||||
"{\"ok\": null}"
|
||||
}
|
||||
|
||||
func shouldProcess(result: ExtractionResult, config: ExtractionConfig) -> Bool {
|
||||
result.mimeType() == "application/pdf"
|
||||
}
|
||||
|
||||
func estimatedDurationMs(result: ExtractionResult) -> UInt64 {
|
||||
0 // No processing overhead
|
||||
}
|
||||
|
||||
func initialize() -> String {
|
||||
"{\"ok\": null}"
|
||||
}
|
||||
|
||||
func shutdown() -> String {
|
||||
"{\"ok\": null}"
|
||||
}
|
||||
}
|
||||
|
||||
let processor = PdfOnlyProcessor()
|
||||
try Kreuzberg.registerPostProcessor(processor)
|
||||
```
|
||||
Reference in New Issue
Block a user