diff --git a/flask-app/application/modules/routes.py b/flask-app/application/modules/routes.py index 4ae9a9d..c9debe9 100644 --- a/flask-app/application/modules/routes.py +++ b/flask-app/application/modules/routes.py @@ -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) @@ -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: @@ -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) diff --git a/flask-app/application/modules/sparql.py b/flask-app/application/modules/sparql.py index 31bd2ab..8a46f72 100644 --- a/flask-app/application/modules/sparql.py +++ b/flask-app/application/modules/sparql.py @@ -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() @@ -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') diff --git a/flask-app/application/templates/snips/filters-lang.html b/flask-app/application/templates/snips/filters-lang.html index 178a32d..3af5d02 100644 --- a/flask-app/application/templates/snips/filters-lang.html +++ b/flask-app/application/templates/snips/filters-lang.html @@ -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 %} +
+
+ + +
+
+ + +
+
+ + +
+
+{% if scr == 'yes' %} + {% set SCR_YES = 'checked' %} +{% else %} + {% set SCR_NO = 'checked' %} +{% endif %} +
+
+ + +
+
+ + +
+
+{% 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 %} - -
-
- - -
-
- - -
-
- - -
-
- - {% if scr == 'yes' %} - {% set SCR_YES = 'checked' %} - {% else %} - {% set SCR_NO = 'checked' %} - {% endif %} - -
-
- - -
-
- - -
-
- +
+
+ + +
+
+ + +
+
+ + +
+
+{% endif %} diff --git a/flask-app/application/templates/sparql/search.sparql b/flask-app/application/templates/sparql/search.sparql index 4e8a4f1..036b103 100644 --- a/flask-app/application/templates/sparql/search.sparql +++ b/flask-app/application/templates/sparql/search.sparql @@ -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 %} diff --git a/flask-app/application/templates/sparql/tree-browse.sparql b/flask-app/application/templates/sparql/tree-browse.sparql index 9c3a565..1c6914b 100644 --- a/flask-app/application/templates/sparql/tree-browse.sparql +++ b/flask-app/application/templates/sparql/tree-browse.sparql @@ -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 @@ -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 %} } } @@ -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 %} } } @@ -132,4 +138,3 @@ SELECT distinct ?tn ?label ?d ?type ?val ?active ?scn ?scnt ?ntx ?lockedBy { } ORDER BY ?tn - diff --git a/flask-app/application/templates/sparql/tree.sparql b/flask-app/application/templates/sparql/tree.sparql index 5db5936..249f8e6 100644 --- a/flask-app/application/templates/sparql/tree.sparql +++ b/flask-app/application/templates/sparql/tree.sparql @@ -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 { @@ -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 {