mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
better job form handling
This commit is contained in:
parent
f1677e2931
commit
527ab5ac0f
@ -1,58 +0,0 @@
|
|||||||
class QueryResult(FileMixin, HashidMixin, db.Model):
|
|
||||||
__tablename__ = 'query_results'
|
|
||||||
# Primary key
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
|
||||||
# Foreign keys
|
|
||||||
user_id = db.Column(db.Integer, db.ForeignKey('users.id'))
|
|
||||||
# Fields
|
|
||||||
description = db.Column(db.String(255))
|
|
||||||
query_metadata = db.Column(db.JSON())
|
|
||||||
title = db.Column(db.String(32))
|
|
||||||
# Backrefs: user: User
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
'''
|
|
||||||
String representation of the QueryResult. For human readability.
|
|
||||||
'''
|
|
||||||
return f'<QueryResult {self.title}>'
|
|
||||||
|
|
||||||
@property
|
|
||||||
def download_url(self):
|
|
||||||
return url_for(
|
|
||||||
'corpora.download_query_result', query_result_id=self.id)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def jsonpatch_path(self):
|
|
||||||
return f'{self.user.jsonpatch_path}/query_results/{self.hashid}'
|
|
||||||
|
|
||||||
@property
|
|
||||||
def path(self):
|
|
||||||
return os.path.join(
|
|
||||||
self.user.path, 'query_results', str(self.id), self.filename)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def url(self):
|
|
||||||
return url_for('corpora.query_result', query_result_id=self.id)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def user_hashid(self):
|
|
||||||
return self.user.hashid
|
|
||||||
|
|
||||||
def delete(self):
|
|
||||||
shutil.rmtree(self.path, ignore_errors=True)
|
|
||||||
db.session.delete(self)
|
|
||||||
|
|
||||||
def to_json(self, backrefs=False, relationships=False):
|
|
||||||
_json = {
|
|
||||||
'id': self.hashid,
|
|
||||||
'corpus_title': self.query_metadata['corpus_name'],
|
|
||||||
'description': self.description,
|
|
||||||
'filename': self.filename,
|
|
||||||
'query': self.query_metadata['query'],
|
|
||||||
'query_metadata': self.query_metadata,
|
|
||||||
'title': self.title,
|
|
||||||
**self.file_mixin_to_json(
|
|
||||||
backrefs=backrefs, relationships=relationships)
|
|
||||||
}
|
|
||||||
if backrefs:
|
|
||||||
_json['user'] = self.user.to_json(backrefs=True, relationships=False)
|
|
@ -72,10 +72,8 @@ class CreateTesseractOCRPipelineJobForm(CreateJobBaseForm):
|
|||||||
self.ocropus_nlbin_threshold.render_kw['disabled'] = True
|
self.ocropus_nlbin_threshold.render_kw['disabled'] = True
|
||||||
if 'methods' in service_info:
|
if 'methods' in service_info:
|
||||||
if 'binarization' in service_info['methods']:
|
if 'binarization' in service_info['methods']:
|
||||||
if 'disabled' in self.binarization.render_kw:
|
|
||||||
del self.binarization.render_kw['disabled']
|
del self.binarization.render_kw['disabled']
|
||||||
if 'ocropus_nlbin_threshold' in service_info['methods']:
|
if 'ocropus_nlbin_threshold' in service_info['methods']:
|
||||||
if 'disabled' in self.ocropus_nlbin_threshold.render_kw:
|
|
||||||
del self.ocropus_nlbin_threshold.render_kw['disabled']
|
del self.ocropus_nlbin_threshold.render_kw['disabled']
|
||||||
models = [
|
models = [
|
||||||
x for x in TesseractOCRPipelineModel.query.order_by(TesseractOCRPipelineModel.title).all()
|
x for x in TesseractOCRPipelineModel.query.order_by(TesseractOCRPipelineModel.title).all()
|
||||||
@ -118,7 +116,6 @@ class CreateTranskribusHTRPipelineJobForm(CreateJobBaseForm):
|
|||||||
self.binarization.render_kw['disabled'] = True
|
self.binarization.render_kw['disabled'] = True
|
||||||
if 'methods' in service_info:
|
if 'methods' in service_info:
|
||||||
if 'binarization' in service_info['methods']:
|
if 'binarization' in service_info['methods']:
|
||||||
if 'disabled' in self.binarization.render_kw:
|
|
||||||
del self.binarization.render_kw['disabled']
|
del self.binarization.render_kw['disabled']
|
||||||
self.model.choices = [('', 'Choose your option')]
|
self.model.choices = [('', 'Choose your option')]
|
||||||
self.model.choices += [(x['modelId'], x['name']) for x in transkribus_htr_pipeline_models]
|
self.model.choices += [(x['modelId'], x['name']) for x in transkribus_htr_pipeline_models]
|
||||||
@ -157,7 +154,6 @@ class CreateSpacyNLPPipelineJobForm(CreateJobBaseForm):
|
|||||||
self.encoding_detection.render_kw['disabled'] = True
|
self.encoding_detection.render_kw['disabled'] = True
|
||||||
if 'methods' in service_info:
|
if 'methods' in service_info:
|
||||||
if 'encoding_detection' in service_info['methods']:
|
if 'encoding_detection' in service_info['methods']:
|
||||||
if 'disabled' in self.encoding_detection.render_kw:
|
|
||||||
del self.encoding_detection.render_kw['disabled']
|
del self.encoding_detection.render_kw['disabled']
|
||||||
models = [
|
models = [
|
||||||
x for x in SpaCyNLPPipelineModel.query.order_by(SpaCyNLPPipelineModel.title).all()
|
x for x in SpaCyNLPPipelineModel.query.order_by(SpaCyNLPPipelineModel.title).all()
|
||||||
|
@ -87,6 +87,7 @@
|
|||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<span class="card-title">Preprocessing</span>
|
<span class="card-title">Preprocessing</span>
|
||||||
</div>
|
</div>
|
||||||
|
{% if 'disabled' not in form.encoding_detection.render_kw or not form.encoding_detection.render_kw['disabled'] %}
|
||||||
<div class="col s9">
|
<div class="col s9">
|
||||||
<p>{{ form.encoding_detection.label.text }}</p>
|
<p>{{ form.encoding_detection.label.text }}</p>
|
||||||
<p class="light">If the input files are not created with the nopaque OCR service or you do not know if your text files are UTF-8 encoded, check this switch. We will try to automatically determine the right encoding for your texts to process them.</p>
|
<p class="light">If the input files are not created with the nopaque OCR service or you do not know if your text files are UTF-8 encoded, check this switch. We will try to automatically determine the right encoding for your texts to process them.</p>
|
||||||
@ -99,6 +100,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
<!--
|
<!--
|
||||||
Seperate each setting with the following
|
Seperate each setting with the following
|
||||||
<div class="col s12"><p> </p></div>
|
<div class="col s12"><p> </p></div>
|
||||||
|
@ -72,6 +72,7 @@
|
|||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<span class="card-title">Preprocessing</span>
|
<span class="card-title">Preprocessing</span>
|
||||||
</div>
|
</div>
|
||||||
|
{% if 'disabled' not in form.binarization.render_kw or not form.binarization.render_kw['disabled'] %}
|
||||||
<div class="col s9">
|
<div class="col s9">
|
||||||
<p>{{ form.binarization.label.text }}</p>
|
<p>{{ form.binarization.label.text }}</p>
|
||||||
<p class="light">Based on a brightness threshold pixels are converted into either black or white. It is useful to reduce noise in images. (<b>longer duration</b>)</p>
|
<p class="light">Based on a brightness threshold pixels are converted into either black or white. It is useful to reduce noise in images. (<b>longer duration</b>)</p>
|
||||||
@ -84,56 +85,14 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col s12"><p> </p></div>
|
{% if 'disabled' not in form.ocropus_nlbin_threshold.render_kw or not form.ocropus_nlbin_threshold.render_kw['disabled'] %}
|
||||||
<div class="col s9">
|
<div class="col s9 hide" id="create-job-form-ocropus_nlbin_threshold-container">
|
||||||
|
<br>
|
||||||
<p>Intensity (between 0 and 1)</p>
|
<p>Intensity (between 0 and 1)</p>
|
||||||
<p class="range-field">{{ form.ocropus_nlbin_threshold() }}</p>
|
<p class="range-field">{{ form.ocropus_nlbin_threshold() }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col s12"><p> </p></div>
|
{% endif %}
|
||||||
<div class="col s12 divider"></div>
|
{% endif %}
|
||||||
<div class="col s12"><p> </p></div>
|
|
||||||
<div class="col s9">
|
|
||||||
<p>Page range</p>
|
|
||||||
<p class="light"></p>
|
|
||||||
</div>
|
|
||||||
<div class="col s3 right-align">
|
|
||||||
<div class="switch">
|
|
||||||
<label>
|
|
||||||
<input disabled type="checkbox">
|
|
||||||
<span class="lever"></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col s12"><p> </p></div>
|
|
||||||
<div class="col s12 divider"></div>
|
|
||||||
<div class="col s12"><p> </p></div>
|
|
||||||
<div class="col s9">
|
|
||||||
<p>Page rotation</p>
|
|
||||||
<p class="light"></p>
|
|
||||||
</div>
|
|
||||||
<div class="col s3 right-align">
|
|
||||||
<div class="switch">
|
|
||||||
<label>
|
|
||||||
<input disabled type="checkbox">
|
|
||||||
<span class="lever"></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col s12"><p> </p></div>
|
|
||||||
<div class="col s12 divider"></div>
|
|
||||||
<div class="col s12"><p> </p></div>
|
|
||||||
<div class="col s9">
|
|
||||||
<p>Page split</p>
|
|
||||||
<p class="light"></p>
|
|
||||||
</div>
|
|
||||||
<div class="col s3 right-align">
|
|
||||||
<div class="switch">
|
|
||||||
<label>
|
|
||||||
<input disabled type="checkbox">
|
|
||||||
<span class="lever"></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!--
|
<!--
|
||||||
Seperate each setting with the following
|
Seperate each setting with the following
|
||||||
<div class="col s12"><p> </p></div>
|
<div class="col s12"><p> </p></div>
|
||||||
@ -185,3 +144,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock modals %}
|
{% endblock modals %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
{{ super() }}
|
||||||
|
<script>
|
||||||
|
document.querySelector('#create-job-form-binarization').addEventListener('change', (event) => {
|
||||||
|
document.querySelector('#create-job-form-ocropus_nlbin_threshold-container').classList.toggle('hide');
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock scripts %}
|
||||||
|
@ -76,6 +76,7 @@
|
|||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<span class="card-title">Preprocessing</span>
|
<span class="card-title">Preprocessing</span>
|
||||||
</div>
|
</div>
|
||||||
|
{% if 'disabled' not in form.binarization.render_kw or not form.binarization.render_kw['disabled'] %}
|
||||||
<div class="col s9">
|
<div class="col s9">
|
||||||
<p>{{ form.binarization.label.text }}</p>
|
<p>{{ form.binarization.label.text }}</p>
|
||||||
<p class="light">Based on a brightness threshold pixels are converted into either black or white. It is useful to reduce noise in images. (<b>longer duration</b>)</p>
|
<p class="light">Based on a brightness threshold pixels are converted into either black or white. It is useful to reduce noise in images. (<b>longer duration</b>)</p>
|
||||||
@ -88,51 +89,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col s12"><p> </p></div>
|
{% endif %}
|
||||||
<div class="col s12 divider"></div>
|
|
||||||
<div class="col s12"><p> </p></div>
|
|
||||||
<div class="col s9">
|
|
||||||
<p>Page range</p>
|
|
||||||
<p class="light"></p>
|
|
||||||
</div>
|
|
||||||
<div class="col s3 right-align">
|
|
||||||
<div class="switch">
|
|
||||||
<label>
|
|
||||||
<input disabled type="checkbox">
|
|
||||||
<span class="lever"></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col s12"><p> </p></div>
|
|
||||||
<div class="col s12 divider"></div>
|
|
||||||
<div class="col s12"><p> </p></div>
|
|
||||||
<div class="col s9">
|
|
||||||
<p>Page rotation</p>
|
|
||||||
<p class="light"></p>
|
|
||||||
</div>
|
|
||||||
<div class="col s3 right-align">
|
|
||||||
<div class="switch">
|
|
||||||
<label>
|
|
||||||
<input disabled type="checkbox">
|
|
||||||
<span class="lever"></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col s12"><p> </p></div>
|
|
||||||
<div class="col s12 divider"></div>
|
|
||||||
<div class="col s12"><p> </p></div>
|
|
||||||
<div class="col s9">
|
|
||||||
<p>Page split</p>
|
|
||||||
<p class="light"></p>
|
|
||||||
</div>
|
|
||||||
<div class="col s3 right-align">
|
|
||||||
<div class="switch">
|
|
||||||
<label>
|
|
||||||
<input disabled type="checkbox">
|
|
||||||
<span class="lever"></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!--
|
<!--
|
||||||
Seperate each setting with the following
|
Seperate each setting with the following
|
||||||
<div class="col s12"><p> </p></div>
|
<div class="col s12"><p> </p></div>
|
||||||
|
Loading…
Reference in New Issue
Block a user