Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
filak committed Jan 23, 2025
1 parent 6d9d795 commit deb6638
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 51 deletions.
11 changes: 9 additions & 2 deletions flask-app/application/modules/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1072,12 +1072,18 @@ def search(dui, action):
if scr in ['yes', 'no']:
session['scr'] = scr

if request.args.get('qtp'):
qtp = request.args.get('qtp').strip()
if qtp in ['def', 'all', 'notes']:
session['qtp'] = qtp

if action == 'clear':
session.pop('q', None)
session.pop('sshow', None)
session.pop('sstatus', None)
session.pop('slang', None)
session.pop('scr', None)
session.pop('qtp', None)
session.pop('dui', None)
session.pop('adui', None)

Expand Down Expand Up @@ -1150,7 +1156,7 @@ def search(dui, action):
if text_query:
data = sparql.getSparqlData('search',
query=text_query, show=session.get('sshow'), status=session.get('sstatus'),
slang=session.get('slang'), scr=session.get('scr'))
slang=session.get('slang'), scr=session.get('scr'), qtp=session.get('qtp'))
# pp.pprint(data)

if data:
Expand Down Expand Up @@ -1180,7 +1186,8 @@ def search(dui, action):

return render_template('search.html',
hits_cnt=hits_cnt, hits=hits, dui=dui, tree=tree, descriptor=descriptor, concepts=concepts, tab=tab,
show=session.get('sshow'), status=session.get('sstatus'), slang=session.get('slang'), scr=session.get('scr'),
show=session.get('sshow'), status=session.get('sstatus'),
slang=session.get('slang'), scr=session.get('scr'), qtp=session.get('qtp'),
audit=audit, dview=dview)


Expand Down
4 changes: 2 additions & 2 deletions flask-app/application/modules/sparql.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def show_elapsed(begin, tag=''):


def getSparqlData(template, query='', show='', status='', top='', tn='', concept='', otype='Descriptor',
output='json', slang=None, lang=None, scr=None, key=None, cache=None):
output='json', slang=None, lang=None, scr=None, qtp=None, key=None, cache=None):

t0 = timer()

Expand All @@ -60,7 +60,7 @@ def getSparqlData(template, query='', show='', status='', top='', tn='', concept

sparql = render_template('sparql/' + template + '.sparql', query=cleanQuery(query), otype=otype,
show=show, status=status, top=top, tn=tn, toptn=toptn, concept=concept,
lang=lang, lang_umls=lang_umls, slang=slang, scr=scr)
lang=lang, lang_umls=lang_umls, slang=slang, scr=scr, qtp=qtp)

if app.debug:
print(sparql, '\n')
Expand Down
95 changes: 57 additions & 38 deletions flask-app/application/templates/snips/filters-lang.html
Original file line number Diff line number Diff line change
@@ -1,40 +1,59 @@
{% if slang == 'target' %}
{% set TRG_CHECKED = 'checked' %}
{% elif slang == 'source' %}
{% set SRC_CHECKED = 'checked' %}
{% if slang == 'target' %}
{% set TRG_CHECKED = 'checked' %}
{% elif slang == 'source' %}
{% set SRC_CHECKED = 'checked' %}
{% else %}
{% set ALL_LANGS = 'checked' %}
{% endif %}
<div class="form-group mb-2">
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="radioLangAll" name="lang" value="all" class="custom-control-input" {{ ALL_LANGS }}>
<label class="custom-control-label" for="radioLangAll">Both langs</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="radioLangSource" name="lang" value="source" class="custom-control-input" {{ SRC_CHECKED }}>
<label class="custom-control-label" for="radioLangSource">Source</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="radioLangTarget" name="lang" value="target" class="custom-control-input" {{ TRG_CHECKED }}>
<label class="custom-control-label text-success" for="radioLangTarget">Target</label>
</div>
</div>
{% if scr == 'yes' %}
{% set SCR_YES = 'checked' %}
{% else %}
{% set SCR_NO = 'checked' %}
{% endif %}
<div class="form-group mb-2">
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input" name="scr" value="no" id="radioScrNo" {{ SCR_NO }}>
<label class="custom-control-label" for="radioScrNo">Exclude SCR</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input" name="scr" value="yes" id="radioScrYes" {{ SCR_YES }}>
<label class="custom-control-label" for="radioScrYes">Include SCR</label>
</div>
</div>
{% if config.USE_PROP_LISTS %}
{% if qtp == 'all' %}
{% set QTYPE_ALL = 'checked' %}
{% elif qtp == 'notes' %}
{% set QTYPE_NOTES = 'checked' %}
{% else %}
{% set ALL_LANGS = 'checked' %}
{% set QTYPE_DEF = 'checked' %}
{% endif %}

<div class="form-group mb-2">
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="radioLangAll" name="lang" value="all" class="custom-control-input" {{ ALL_LANGS }}>
<label class="custom-control-label" for="radioLangAll">Both langs</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="radioLangSource" name="lang" value="source" class="custom-control-input" {{ SRC_CHECKED }}>
<label class="custom-control-label" for="radioLangSource">Source</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="radioLangTarget" name="lang" value="target" class="custom-control-input" {{ TRG_CHECKED }}>
<label class="custom-control-label text-success" for="radioLangTarget">Target</label>
</div>
</div>

{% if scr == 'yes' %}
{% set SCR_YES = 'checked' %}
{% else %}
{% set SCR_NO = 'checked' %}
{% endif %}

<div class="form-group mb-2">
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input" name="scr" value="no" id="radioScrNo" {{ SCR_NO }}>
<label class="custom-control-label" for="radioScrNo">Exclude SCR</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input" name="scr" value="yes" id="radioScrYes" {{ SCR_YES }}>
<label class="custom-control-label" for="radioScrYes">Include SCR</label>
</div>
</div>

<div class="form-group mb-2">
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input" name="qtp" value="def" id="radioQueryDef" {{ QTYPE_DEF }}>
<label class="custom-control-label" for="radioQueryDef">Main terms</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input" name="qtp" value="all" id="radioQueryAll" {{ QTYPE_ALL }}>
<label class="custom-control-label" for="radioQueryAll">All fields</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input" name="qtp" value="notes" id="radioQueryNotes" {{ QTYPE_NOTES }}>
<label class="custom-control-label" for="radioQueryNotes">Notes only</label>
</div>
</div>
{% endif %}
6 changes: 4 additions & 2 deletions flask-app/application/templates/sparql/search.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
{% include 'sparql/_namespaces.sparql' %}

{% if config.USE_PROP_LISTS %}
{% if queryAll == 'yes' %}
{% if qtp == 'all' %}
{% set prop_list = 'mesht:queryAll' %}
{% elif onlyNotes == 'yes' %}
{% elif qtp == 'notes' %}
{% set prop_list = 'mesht:queryNotes' %}
{% elif qtp == 'def' %}
{% set prop_list = 'mesht:queryDef' %}
{% else %}
{% set prop_list = 'mesht:queryDef' %}
{% endif %}
Expand Down
15 changes: 10 additions & 5 deletions flask-app/application/templates/sparql/tree-browse.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

{% include 'sparql/_namespaces.sparql' ignore missing %}

{% if config.USE_PROP_LISTS %}
{% set treeno_field = '' %}
{% else %}
{% set treeno_field = 'meshv:identifier' %}
{% endif %}

SELECT distinct ?tn ?label ?d ?type ?val ?active ?scn ?scnt ?ntx ?lockedBy {

{% if show == 'ntx' %} ## notTranslatable
Expand Down Expand Up @@ -37,10 +43,10 @@ SELECT distinct ?tn ?label ?d ?type ?val ?active ?scn ?scnt ?ntx ?lockedBy {
## status:{{ status }} show:{{ show }} ##
{% if toptn %}
## TOPTN ##
(?tn ?score) text:query (meshv:identifier "{{ tn }} OR {{ toptn }} OR {{ toptn }}.*") .
(?tn ?score) text:query ({{ treeno_field }} "{{ tn }} OR {{ toptn }} OR {{ toptn }}.*") .
{% else %}
## TOP ##
(?tn ?score) text:query (meshv:identifier "{{ top }}??.*") .
(?tn ?score) text:query ({{ treeno_field }} "{{ top }}??.*") .
{% endif %}
}
}
Expand All @@ -54,10 +60,10 @@ SELECT distinct ?tn ?label ?d ?type ?val ?active ?scn ?scnt ?ntx ?lockedBy {
## status:{{ status }} show:{{ show }} ##
{% if toptn %}
## TOPTN ##
(?tn ?score) text:query (meshv:identifier "{{ tn }} OR {{ tn }}.??? OR {{ toptn }} OR {{ toptn }}.???" 1000) .
(?tn ?score) text:query ({{ treeno_field }} "{{ tn }} OR {{ tn }}.??? OR {{ toptn }} OR {{ toptn }}.???" 1000) .
{% else %}
## TOP ##
(?tn ?score) text:query (meshv:identifier "{{ query }}" 1000) .
(?tn ?score) text:query ({{ treeno_field }} "{{ query }}" 1000) .
{% endif %}
}
}
Expand Down Expand Up @@ -132,4 +138,3 @@ SELECT distinct ?tn ?label ?d ?type ?val ?active ?scn ?scnt ?ntx ?lockedBy {
}

ORDER BY ?tn

4 changes: 2 additions & 2 deletions flask-app/application/templates/sparql/tree.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ WHERE {
mesh:{{ query }} meshv:treeNumber ?treeNum .
?treeNum meshv:parentTreeNumber ?parent .
BIND(CONCAT(str(?parent),'.???') as ?q) .
(?tn ?score ?literal) text:query (?q) .
(?tn ?score) text:query (?q) .
?d meshv:treeNumber ?tn .
?d meshv:preferredConcept ?c .
}} UNION {
Expand All @@ -24,7 +24,7 @@ SELECT ?tn ?d ?c
WHERE {
mesh:{{ query }} meshv:treeNumber ?treeNum .
BIND(CONCAT(str(?treeNum),'.???') as ?q) .
(?tn ?score ?literal) text:query (?q) .
(?tn ?score) text:query (?q) .
?d meshv:treeNumber ?tn .
?d meshv:preferredConcept ?c .
}} UNION {
Expand Down

0 comments on commit deb6638

Please sign in to comment.