spacy nlp ner
This commit is contained in:
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user