-
Notifications
You must be signed in to change notification settings - Fork 5
Agregar API first_block e identificación automática de elementos del front #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eduranm
wants to merge
11
commits into
scieloorg:main
Choose a base branch
from
eduranm:issue-04
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2614d27
Agregar la app markup_doc para gestión y marcación de documentos DOCX
eduranm e5a6783
Agregar archivos DOCX de ejemplo para pruebas del flujo de marcación
eduranm 3ddf5ca
Registrar markup_doc
eduranm a4d2fa6
Registrar markuplib y agregar utilidades base para lectura estructura…
eduranm adbb38d
Agregar utilidades de etiquetado y marcación automática de referencias
eduranm b3a5141
Integrar procesamiento automático de referencias en las tareas de mar…
eduranm fc28a0b
Disparar el procesamiento automático del DOCX desde el flujo de creac…
eduranm 40ee0cb
Ajustar la respuesta de Gemini en el servicio de inferencia de model_ai
eduranm fb9da61
Agregar API first_block para procesar el bloque inicial del artículo
eduranm 0cd08bb
Agregar utilidades para consultar first_block y extraer palabras clave
eduranm ad725c4
Integrar la identificación de elementos del front en get_labels
eduranm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from django.contrib import admin | ||
|
|
||
| # Register your models here. |
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| from rest_framework import serializers | ||
| from markup_doc.models import ArticleDocx | ||
|
|
||
| class ArticleDocxSerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = ArticleDocx | ||
| fields = "__all__" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| from django.shortcuts import render | ||
| from django.http import JsonResponse | ||
| from rest_framework.permissions import IsAuthenticated | ||
| from rest_framework.viewsets import GenericViewSet | ||
| from rest_framework.mixins import CreateModelMixin | ||
| from rest_framework.response import Response | ||
| from markup_doc.api.v1.serializers import ArticleDocxSerializer | ||
| from markup_doc.marker import mark_article | ||
|
|
||
| import json | ||
|
|
||
| # Create your views here. | ||
|
|
||
| class ArticleViewSet( | ||
| GenericViewSet, # generic view functionality | ||
| CreateModelMixin, # handles POSTs | ||
| ): | ||
| serializer_class = ArticleDocxSerializer | ||
| permission_classes = [IsAuthenticated] | ||
| http_method_names = [ | ||
| "post", | ||
| ] | ||
|
|
||
| def create(self, request, *args, **kwargs): | ||
| return self.api_article(request) | ||
|
|
||
| def api_article(self, request): | ||
| try: | ||
| data = json.loads(request.body) | ||
| post_text = data.get('text') # Obtiene el parámetro | ||
| post_metadata = data.get('metadata') # Obtiene el parámetro | ||
|
|
||
| resp_data = mark_article(post_text, post_metadata) | ||
|
|
||
| response_data = { | ||
| 'message': resp_data, | ||
| } | ||
| except json.JSONDecodeError: | ||
| response_data = { | ||
| 'error': 'Error processing' | ||
| } | ||
|
|
||
| return JsonResponse(response_data) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class MarkupDocConfig(AppConfig): | ||
| default_auto_field = "django.db.models.BigAutoField" | ||
| name = "markup_doc" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| front_labels = [ | ||
| ('<abstract>', '<abstract>'), | ||
| ('<abstract-title>', '<abstract-title>'), | ||
| ('<aff>', '<aff>'), | ||
| ('<article-id>', '<article-id>'), | ||
| ('<article-title>', '<article-title>'), | ||
| ('<author-notes>', '<author-notes>'), | ||
| ('<contrib>', '<contrib>'), | ||
| ('<date-accepted>', '<date-accepted>'), | ||
| ('<date-received>', '<date-received>'), | ||
| ('<fig>', '<fig>'), | ||
| ('<fig-attrib>', '<fig-attrib>'), | ||
| ('<history>', '<history>'), | ||
| ('<kwd-title>', '<kwd-title>'), | ||
| ('<kwd-group>', '<kwd-group>'), | ||
| ('<list>', '<list>'), | ||
| ('<p>', '<p>'), | ||
| ('<sec>', '<sec>'), | ||
| ('<sub-sec>', '<sub-sec>'), | ||
| ('<subject>', '<subject>'), | ||
| ('<table>', '<table>'), | ||
| ('<table-foot>', '<table-foot>'), | ||
| ('<title>', '<title>'), | ||
| ('<trans-abstract>', '<trans-abstract>'), | ||
| ('<trans-title>', '<trans-title>'), | ||
| ('<translate-front>', '<translate-front>'), | ||
| ('<translate-body>', '<translate-body>'), | ||
| ('<disp-formula>', '<disp-formula>'), | ||
| ('<inline-formula>', '<inline-formula>'), | ||
| ('<formula>', '<formula>'), | ||
|
|
||
| ] | ||
|
|
||
| order_labels = { | ||
| '<article-id>':{ | ||
| 'pos' : 1, | ||
| 'next' : '<subject>' | ||
| }, | ||
| '<subject>':{ | ||
| 'pos' : 2, | ||
| 'next' : '<article-title>' | ||
| }, | ||
| '<article-title>':{ | ||
| 'pos' : 3, | ||
| 'next' : '<trans-title>', | ||
| 'lan' : True | ||
| }, | ||
| '<trans-title>':{ | ||
| 'size' : 14, | ||
| 'bold' : True, | ||
| 'lan' : True, | ||
| 'next' : '<contrib>' | ||
| }, | ||
| '<contrib>':{ | ||
| 'reset' : True, | ||
| 'size' : 12, | ||
| 'next' : '<aff>' | ||
| }, | ||
| '<aff>':{ | ||
| 'reset' : True, | ||
| 'size' : 12, | ||
| }, | ||
| '<abstract>':{ | ||
| 'size' : 12, | ||
| 'bold' : True, | ||
| 'lan' : True, | ||
| 'next' : '<p>' | ||
| }, | ||
| '<p>':{ | ||
| 'size' : 12, | ||
| 'next' : '<p>', | ||
| 'repeat' : True | ||
| }, | ||
| '<trans-abstract>':{ | ||
| 'size' : 12, | ||
| 'bold' : True, | ||
| 'lan' : True, | ||
| 'next' : '<p>' | ||
| }, | ||
| '<kwd-group>':{ | ||
| 'size' : 12, | ||
| 'regex' : r'(?i)(palabra.*clave.*:|keyword.*:)', | ||
| }, | ||
| '<history>':{ | ||
| 'size' : 12, | ||
| 'regex' : r'\d{2}/\d{2}/\d{4}', | ||
| }, | ||
| '<corresp>':{ | ||
| 'size' : 12, | ||
| 'regex' : r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' | ||
| }, | ||
| '<sec>':{ | ||
| 'size' : 16, | ||
| 'bold' : True, | ||
| 'next' : None | ||
| }, | ||
| '<sub-sec>':{ | ||
| 'size' : 12, | ||
| 'italic' : True, | ||
| 'next' : None | ||
| }, | ||
| '<sub-sec-2>':{ | ||
| 'size' : 14, | ||
| 'bold' : True, | ||
| 'next' : None | ||
| }, | ||
| } | ||
|
|
||
| order_labels_body = { | ||
| '<sec>':{ | ||
| 'size' : 16, | ||
| 'bold' : True, | ||
| }, | ||
| '<sub-sec>':{ | ||
| 'size' : 12, | ||
| 'italic' : True, | ||
| }, | ||
| '<p>':{ | ||
| 'size' : 12, | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from wagtail.admin.forms.models import WagtailAdminModelForm |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This DRF ViewSet is manually parsing
request.bodywithjson.loadsand doesn’t validate required fields (sopost_text/post_metadatacan beNone, leading to downstream errors). Preferrequest.data+ serializer validation and return a DRFResponsewith appropriate HTTP status codes (e.g., 400 on invalid JSON / missing params) instead of always returning a 200JsonResponse.