This commit is contained in:
11
docs/snippets/swift/getting-started/basic_usage.md
Normal file
11
docs/snippets/swift/getting-started/basic_usage.md
Normal file
@@ -0,0 +1,11 @@
|
||||
```swift title="Swift"
|
||||
import Foundation
|
||||
import Kreuzberg
|
||||
import RustBridge
|
||||
|
||||
let config = try extractionConfigFromJson("{}")
|
||||
let result = try extractFileSync("document.pdf", nil, config)
|
||||
|
||||
print(result.content().toString())
|
||||
print("MIME type: \(result.mime_type().toString())")
|
||||
```
|
||||
12
docs/snippets/swift/getting-started/extract_file.md
Normal file
12
docs/snippets/swift/getting-started/extract_file.md
Normal file
@@ -0,0 +1,12 @@
|
||||
```swift title="Swift"
|
||||
import Foundation
|
||||
import Kreuzberg
|
||||
import RustBridge
|
||||
|
||||
let config = try extractionConfigFromJson("{}")
|
||||
let result = try extractFileSync("document.pdf", nil, config)
|
||||
|
||||
print("Content: \(result.content().toString())")
|
||||
print("MIME type: \(result.mime_type().toString())")
|
||||
print("Tables: \(result.tables().count)")
|
||||
```
|
||||
21
docs/snippets/swift/getting-started/extract_with_ocr.md
Normal file
21
docs/snippets/swift/getting-started/extract_with_ocr.md
Normal file
@@ -0,0 +1,21 @@
|
||||
```swift title="Swift"
|
||||
import Foundation
|
||||
import Kreuzberg
|
||||
import RustBridge
|
||||
|
||||
let configJson = """
|
||||
{
|
||||
"force_ocr": true,
|
||||
"ocr": {
|
||||
"backend": "tesseract",
|
||||
"language": "eng"
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
let config = try extractionConfigFromJson(configJson)
|
||||
let result = try extractFileSync("scanned.pdf", nil, config)
|
||||
|
||||
print(result.content().toString())
|
||||
print("MIME type: \(result.mime_type().toString())")
|
||||
```
|
||||
12
docs/snippets/swift/getting-started/hello_world.md
Normal file
12
docs/snippets/swift/getting-started/hello_world.md
Normal file
@@ -0,0 +1,12 @@
|
||||
```swift title="Swift"
|
||||
import Foundation
|
||||
import Kreuzberg
|
||||
import RustBridge
|
||||
|
||||
print("Hello")
|
||||
|
||||
let config = try extractionConfigFromJson("{}")
|
||||
let result = try extractFileSync("document.pdf", nil, config)
|
||||
|
||||
print("MIME type: \(result.mime_type().toString())")
|
||||
```
|
||||
9
docs/snippets/swift/getting-started/install_verify.md
Normal file
9
docs/snippets/swift/getting-started/install_verify.md
Normal file
@@ -0,0 +1,9 @@
|
||||
```swift title="Swift"
|
||||
import Foundation
|
||||
import Kreuzberg
|
||||
import RustBridge
|
||||
|
||||
let config = try extractionConfigFromJson("{}")
|
||||
print("Kreuzberg Swift binding loaded successfully")
|
||||
print("Default config built: \(config)")
|
||||
```
|
||||
31
docs/snippets/swift/getting-started/read_content.md
Normal file
31
docs/snippets/swift/getting-started/read_content.md
Normal file
@@ -0,0 +1,31 @@
|
||||
```swift title="Swift"
|
||||
import Foundation
|
||||
import Kreuzberg
|
||||
import RustBridge
|
||||
|
||||
let configJson = """
|
||||
{
|
||||
"chunking": {
|
||||
"max_characters": 800,
|
||||
"overlap": 100,
|
||||
"chunker_type": "markdown"
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
let config = try extractionConfigFromJson(configJson)
|
||||
let result = try extractFileSync("document.pdf", nil, config)
|
||||
|
||||
let tables = result.tables()
|
||||
print("Tables: \(tables.count)")
|
||||
for (index, _) in tables.enumerated() {
|
||||
print("Table \(index)")
|
||||
}
|
||||
|
||||
if let chunks = result.chunks() {
|
||||
print("Chunks: \(chunks.count)")
|
||||
for (index, _) in chunks.enumerated() {
|
||||
print("Chunk \(index)")
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user