Nomad changes
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s

This commit is contained in:
Henrik Jess Nielsen
2026-06-01 23:40:55 +02:00
parent 72b1a0a6ed
commit b4c07d3693
5723 changed files with 1130655 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
```r title="R"
library(kreuzberg)
custom_ocr_backend <- function(image_path, language) {
cat(sprintf("Processing image: %s\n", image_path))
return(sprintf("Extracted text from %s", image_path))
}
register_ocr_backend("custom_cloud", custom_ocr_backend)
config <- list(
force_ocr = TRUE,
ocr = list(backend = "custom_cloud", language = "en")
)
json <- extract_file_sync("document.pdf", "application/pdf", config)
result <- jsonlite::fromJSON(json, simplifyVector = FALSE)
cat(sprintf("Custom backend result: %d chars\n", nchar(result$content)))
```

View File

@@ -0,0 +1,16 @@
```r title="R"
library(kreuzberg)
config <- list(
force_ocr = TRUE,
ocr = list(backend = "tesseract", language = "eng")
)
json <- extract_file_sync("scan.png", "image/png", config)
result <- jsonlite::fromJSON(json, simplifyVector = FALSE)
cat("Image extraction via OCR:\n")
cat(sprintf("Content length: %d characters\n", nchar(result$content)))
cat(sprintf("Mime type: %s\n", result$mime_type))
cat(sprintf("Detected language: %s\n", result$detected_language))
```

View File

@@ -0,0 +1,16 @@
```r title="R"
library(kreuzberg)
config <- list(
force_ocr = TRUE,
ocr = list(backend = "tesseract", language = "eng"),
enable_quality_processing = TRUE
)
json <- extract_file_sync("scan.png", "image/png", config)
result <- jsonlite::fromJSON(json, simplifyVector = FALSE)
cat(sprintf("Quality: %.2f, Length: %d\n",
result$quality_score %||% 0,
nchar(result$content)))
```

View File

@@ -0,0 +1,16 @@
```r title="R"
library(kreuzberg)
# Note: EasyOCR backend requires Python to be installed
config <- list(
force_ocr = TRUE,
ocr = list(backend = "easyocr", language = "en")
)
json <- extract_file_sync("document.pdf", "application/pdf", config)
result <- jsonlite::fromJSON(json, simplifyVector = FALSE)
cat("EasyOCR extraction:\n")
cat(sprintf("Content length: %d characters\n", nchar(result$content)))
cat(sprintf("Detected language: %s\n", result$detected_language))
```

View File

@@ -0,0 +1,23 @@
```r title="R"
library(kreuzberg)
# Enable structured OCR elements alongside text extraction
config <- list(
ocr = list(
backend = "paddleocr",
language = "en",
element_config = list(include_elements = TRUE)
)
)
json <- extract_file_sync("scanned.pdf", "application/pdf", config)
result <- jsonlite::fromJSON(json, simplifyVector = FALSE)
if (!is.null(result$ocr_elements)) {
for (element in result$ocr_elements) {
cat(sprintf("Text: %s\n", element$text))
cat(sprintf("Confidence: %.2f\n", element$confidence$recognition))
cat("\n")
}
}
```

View File

@@ -0,0 +1,17 @@
```r title="R"
library(kreuzberg)
# Configure Tesseract OCR
config <- list(
force_ocr = TRUE,
ocr = list(backend = "tesseract", language = "eng")
)
# Extract text from a scanned image
json <- extract_file_sync("scan.png", "image/png", config)
result <- jsonlite::fromJSON(json, simplifyVector = FALSE)
cat(sprintf("Extracted %d characters\n", nchar(result$content)))
cat("Content preview:\n")
cat(substr(result$content, 1, 200))
```

View File

@@ -0,0 +1,12 @@
```r title="R"
library(kreuzberg)
config <- list(force_ocr = TRUE)
json <- extract_file_sync("multipage_document.pdf", "application/pdf", config)
result <- jsonlite::fromJSON(json, simplifyVector = FALSE)
cat(sprintf("Total pages: %d\n", length(result$pages)))
cat(sprintf("Content extracted via OCR: %d characters\n", nchar(result$content)))
cat(sprintf("Detected language: %s\n", result$detected_language))
```

View File

@@ -0,0 +1,18 @@
```r title="R"
library(kreuzberg)
# Configure multi-language OCR (English, French, German)
config <- list(
force_ocr = TRUE,
ocr = list(backend = "tesseract", language = "eng+fra+deu")
)
# Extract from a multilingual document
json <- extract_file_sync("multilingual.png", "image/png", config)
result <- jsonlite::fromJSON(json, simplifyVector = FALSE)
cat(sprintf("Detected language: %s\n", result$detected_language))
cat(sprintf("Extracted %d characters\n", nchar(result$content)))
cat("Content preview:\n")
cat(substr(result$content, 1, 200))
```

View File

@@ -0,0 +1,18 @@
```r title="R"
library(kreuzberg)
# Configure PaddleOCR backend (defaults to mobile tier)
config <- list(
force_ocr = TRUE,
ocr = list(backend = "paddle-ocr", language = "en")
)
# Extract text from an image using PaddleOCR
json <- extract_file_sync("document.jpg", "image/jpeg", config)
result <- jsonlite::fromJSON(json, simplifyVector = FALSE)
cat(sprintf("Extracted %d characters\n", nchar(result$content)))
cat(sprintf("MIME type: %s\n", result$mime_type))
cat("Content preview:\n")
cat(substr(result$content, 1, 200))
```