spacy nlp ner

This commit is contained in:
m
2026-07-12 22:11:57 +02:00
parent 6ed51daa6b
commit 010cb2cb49
22 changed files with 480 additions and 8 deletions
+3
View File
@@ -64,6 +64,7 @@ func (h *FileHandler) List(c *gin.Context) {
CreatedAt string `json:"createdAt"`
MimeType string `json:"mimeType"`
OcrText string `json:"ocrText,omitempty"`
NlpData string `json:"nlpData,omitempty"`
UpdatedAt string `json:"updatedAt"`
}
@@ -78,6 +79,7 @@ func (h *FileHandler) List(c *gin.Context) {
Tags: []string{},
CreatedAt: f.CreatedAt,
OcrText: f.OcrText,
NlpData: f.NlpData,
UpdatedAt: f.UpdatedAt,
MimeType: f.MimeType,
}
@@ -122,6 +124,7 @@ func (h *FileHandler) Get(c *gin.Context) {
"createdAt": file.CreatedAt,
"updatedAt": file.UpdatedAt,
"ocrText": file.OcrText,
"nlpData": file.NlpData,
})
}
+4 -2
View File
@@ -7,13 +7,15 @@ import (
type Handler struct {
File *FileHandler
OCR *OCRHandler
NLP *NLPHandler
Health *HealthHandler
}
func New(fileSvc *service.FileService, ocrSvc *service.OCRService, urlSvc *service.URLService) *Handler {
func New(fileSvc *service.FileService, ocrSvc *service.OCRService, nlpSvc *service.NLPService, urlSvc *service.URLService) *Handler {
return &Handler{
File: &FileHandler{files: fileSvc, urls: urlSvc, ocr: ocrSvc},
OCR: &OCRHandler{ocr: ocrSvc, files: fileSvc},
Health: &HealthHandler{ocr: ocrSvc},
NLP: &NLPHandler{nlp: nlpSvc, files: fileSvc},
Health: &HealthHandler{ocr: ocrSvc, nlp: nlpSvc},
}
}
+16 -1
View File
@@ -7,8 +7,23 @@ import (
type HealthHandler struct {
ocr interface{ HealthCheck() error }
nlp interface{ HealthCheck() error }
}
func (h *HealthHandler) Check(c *gin.Context) {
api.Success(c, gin.H{"status": "healthy"})
status := gin.H{"status": "healthy"}
if err := h.ocr.HealthCheck(); err != nil {
status["ocr"] = err.Error()
} else {
status["ocr"] = "healthy"
}
if err := h.nlp.HealthCheck(); err != nil {
status["nlp"] = err.Error()
} else {
status["nlp"] = "healthy"
}
api.Success(c, status)
}
+22
View File
@@ -0,0 +1,22 @@
package handler
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/vaultdrop/backend/internal/service"
"github.com/vaultdrop/backend/pkg/api"
)
type NLPHandler struct {
nlp *service.NLPService
files *service.FileService
}
func (h *NLPHandler) CreateJob(c *gin.Context) {
api.Error(c, http.StatusNotImplemented, "NOT_IMPLEMENTED", "NLP job creation not yet implemented")
}
func (h *NLPHandler) GetJobStatus(c *gin.Context) {
api.Error(c, http.StatusNotFound, "JOB_NOT_FOUND", "NLP job not found")
}
+3
View File
@@ -18,4 +18,7 @@ func SetupRoutes(r *gin.Engine, h *Handler) {
api.POST("/ocr/jobs", h.OCR.CreateJob)
api.GET("/ocr/jobs/:id", h.OCR.GetJobStatus)
api.POST("/nlp/jobs", h.NLP.CreateJob)
api.GET("/nlp/jobs/:id", h.NLP.GetJobStatus)
}