mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-12 00:50:40 +00:00
Merge branch 'development' into binarization-threshold
This commit is contained in:
@ -11,7 +11,7 @@ from wtforms import (
|
||||
ValidationError
|
||||
)
|
||||
from wtforms.validators import InputRequired, Length
|
||||
from app.models import TesseractOCRPipelineModel
|
||||
from app.models import TesseractOCRPipelineModel, SpaCyNLPPipelineModel
|
||||
from . import SERVICES
|
||||
|
||||
|
||||
@ -77,11 +77,11 @@ class CreateTesseractOCRPipelineJobForm(CreateJobBaseForm):
|
||||
if 'disabled' in self.binarization.render_kw:
|
||||
del self.binarization.render_kw['disabled']
|
||||
models = [
|
||||
x for x in TesseractOCRPipelineModel.query.filter().all()
|
||||
x for x in TesseractOCRPipelineModel.query.order_by(TesseractOCRPipelineModel.title).all()
|
||||
if version in x.compatible_service_versions and (x.shared == True or x.user == current_user)
|
||||
]
|
||||
self.model.choices = [('', 'Choose your option')]
|
||||
self.model.choices += [(x.hashid, x.title) for x in models]
|
||||
self.model.choices += [(x.hashid, f'{x.title} [{x.version}]') for x in models]
|
||||
self.model.default = ''
|
||||
self.version.choices = [(x, x) for x in service_manifest['versions']]
|
||||
self.version.data = version
|
||||
@ -131,7 +131,7 @@ class CreateSpacyNLPPipelineJobForm(CreateJobBaseForm):
|
||||
encoding_detection = BooleanField('Encoding detection', render_kw={'disabled': True})
|
||||
txt = FileField('File', validators=[FileRequired()])
|
||||
model = SelectField('Model', validators=[InputRequired()])
|
||||
|
||||
|
||||
def validate_encoding_detection(self, field):
|
||||
service_info = SERVICES['spacy-nlp-pipeline']['versions'][self.version.data]
|
||||
if field.data:
|
||||
@ -150,6 +150,7 @@ class CreateSpacyNLPPipelineJobForm(CreateJobBaseForm):
|
||||
version = kwargs.pop('version', service_manifest['latest_version'])
|
||||
super().__init__(*args, **kwargs)
|
||||
service_info = service_manifest['versions'][version]
|
||||
print(service_info)
|
||||
if self.encoding_detection.render_kw is None:
|
||||
self.encoding_detection.render_kw = {}
|
||||
self.encoding_detection.render_kw['disabled'] = True
|
||||
@ -157,8 +158,12 @@ class CreateSpacyNLPPipelineJobForm(CreateJobBaseForm):
|
||||
if 'encoding_detection' in service_info['methods']:
|
||||
if 'disabled' in self.encoding_detection.render_kw:
|
||||
del self.encoding_detection.render_kw['disabled']
|
||||
models = [
|
||||
x for x in SpaCyNLPPipelineModel.query.order_by(SpaCyNLPPipelineModel.title).all()
|
||||
if version in x.compatible_service_versions and (x.shared == True or x.user == current_user)
|
||||
]
|
||||
self.model.choices = [('', 'Choose your option')]
|
||||
self.model.choices += [(x, y) for x, y in service_info['models'].items()] # noqa
|
||||
self.model.choices += [(x.hashid, f'{x.title} [{x.version}]') for x in models]
|
||||
self.model.default = ''
|
||||
self.version.choices = [(x, x) for x in service_manifest['versions']]
|
||||
self.version.data = version
|
||||
|
@ -6,7 +6,8 @@ from app.models import (
|
||||
Job,
|
||||
JobInput,
|
||||
JobStatus,
|
||||
TesseractOCRPipelineModel
|
||||
TesseractOCRPipelineModel,
|
||||
SpaCyNLPPipelineModel
|
||||
)
|
||||
from . import bp, SERVICES
|
||||
from .forms import (
|
||||
@ -173,6 +174,7 @@ def spacy_nlp_pipeline():
|
||||
if version not in service_manifest['versions']:
|
||||
abort(404)
|
||||
form = CreateSpacyNLPPipelineJobForm(prefix='create-job-form', version=version)
|
||||
spacy_nlp_pipeline_models = SpaCyNLPPipelineModel.query.all()
|
||||
if form.is_submitted():
|
||||
if not form.validate():
|
||||
response = {'errors': form.errors}
|
||||
@ -203,6 +205,7 @@ def spacy_nlp_pipeline():
|
||||
return render_template(
|
||||
'services/spacy_nlp_pipeline.html.j2',
|
||||
form=form,
|
||||
spacy_nlp_pipeline_models=spacy_nlp_pipeline_models,
|
||||
title=service_manifest['name']
|
||||
)
|
||||
|
||||
|
@ -45,16 +45,21 @@ spacy-nlp-pipeline:
|
||||
0.1.0:
|
||||
methods:
|
||||
- 'encoding_detection'
|
||||
models:
|
||||
ca: 'Catalan'
|
||||
de: 'German'
|
||||
el: 'Greek'
|
||||
en: 'English'
|
||||
es: 'Spanish'
|
||||
fr: 'French'
|
||||
it: 'Italian'
|
||||
pl: 'Polish'
|
||||
ru: 'Russian'
|
||||
zh: 'Chinese'
|
||||
# models:
|
||||
# ca: 'Catalan'
|
||||
# de: 'German'
|
||||
# el: 'Greek'
|
||||
# en: 'English'
|
||||
# es: 'Spanish'
|
||||
# fr: 'French'
|
||||
# it: 'Italian'
|
||||
# pl: 'Polish'
|
||||
# ru: 'Russian'
|
||||
# zh: 'Chinese'
|
||||
publishing_year: 2022
|
||||
url: 'https://gitlab.ub.uni-bielefeld.de/sfb1288inf/spacy-nlp-pipeline/-/releases/v0.1.0'
|
||||
test:
|
||||
methods:
|
||||
- 'encoding_detection'
|
||||
publishing_year: 2022
|
||||
url: 'https://gitlab.ub.uni-bielefeld.de/sfb1288inf/spacy-nlp-pipeline/'
|
||||
|
Reference in New Issue
Block a user