From 0e8df2be7f0ce86e393cfc32346de32e1931b2a3 Mon Sep 17 00:00:00 2001 From: hakangunturkun Date: Thu, 9 Apr 2020 12:12:25 -0500 Subject: deep learning part for stress related sentences --- server.py | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/server.py b/server.py index 9f68e22..f16d930 100755 --- a/server.py +++ b/server.py @@ -10,6 +10,7 @@ import tempfile import random import string from ratspub import * +from nlp import * import time import os import re @@ -540,6 +541,10 @@ def sentences(): edge=request.args.get('edgeID') (tf_name, gene0, cat0)=edge.split("|") out3="" + out5_pl="" + out5_sn="" + out_pos = "" + out_neg = "" num_abstract = 0 with open(tf_name, "r") as df: all_sents=df.read() @@ -550,13 +555,37 @@ def sentences(): out3+= "
  • "+ text + " PMID:"+pmid+"
    " num_abstract += 1 if(pmid+cat0 not in pmid_list): - pmid_list.append(pmid+cat0) + pmid_list.append(pmid+cat0) + if(cat0=='stress'): + out5_pl = 'These are analyzed by deep learning to seperate the relevant sentences.' + out5_sn = 'This is analyzed by deep learning to see whether it is relevant or not.' + out_pred = "
  • "+ text + " PMID:"+pmid+"
    " + out4 = predict_sent(out_pred) + if(out4 == 'pos'): + out_rel = "Relevant sentences:" + out_pos += out_pred + else: + out_irrel = "



    "+"Irrelevant sentences:" + out_neg += out_pred out1="

    "+gene0 + " and " + cat0 + "

    \n" if len(pmid_list)>1: - out2 = str(num_abstract) + ' sentences in ' + str(len(pmid_list)) + ' studies' "
    \n" + out2 = str(num_abstract) + ' sentences in ' + str(len(pmid_list)) + ' studies' + "
    " + if(out5_pl!=""): + out2 += out5_pl + out2 += "
    \n" else: - out2 = str(num_abstract) + ' sentence in ' + str(len(pmid_list)) + ' study' "
    \n" - out= out1+ out2 +out3 + out2 = str(num_abstract) + ' sentence in ' + str(len(pmid_list)) + ' study' "
    " + if(out5_sn!=""): + out2 += out5_sn + out2 += "
    \n" + if(out_neg == "" and out_pos == ""): + out= out1+ out2 +out3 + elif(out_pos != "" and out_neg!=""): + out = out1 + out2 + out_rel+out_pos + out_irrel + out_neg + elif(out_pos != "" and out_neg ==""): + out= out1+ out2 + out_rel + out_pos + elif(out_neg != "" and out_pos == ""): + out = out1 +out2+out_irrel+out_neg return render_template('sentences.html', sentences="
      "+out+"

    ") ## show the cytoscape graph for one gene from the top gene list -- cgit v1.2.3