Ejemplo n.º 1
0
def getHospital(MinScale, typeList):
    s = "SELECT * FROM tbHospitals WHERE scale >= " + str(
        MinScale) + " and ( type like '%%%%%s%%%%'" % typeList[0]
    for x in typeList:
        s += " or type LIKE '%%%%%s%%%%'" % x
    s += ')'
    return tool_mysql.select_sql(s)
Ejemplo n.º 2
0
def f():
    print('start')
    import tool_mysql
    from snownlp import SnowNLP
    df_com=tool_mysql.select_sql('select id,txt from tbComments where sentiRate is null or sentiRate=\'\'') #读取评论文本  返回<class 'pandas.core.frame.DataFrame'>
    for n in range(df_com.__len__()):
        dt_com=[i for i in df_com.ix[n]]
        if(len(dt_com[1])>0):
            senti=SnowNLP(dt_com[1]).sentiments
            tool_mysql.update('tbComments','sentiRate',senti,'id',str(dt_com[0]))
            print(n,dt_com[1])
            print(senti)
    print('done')
Ejemplo n.º 3
0
def getAnswer(name, s_choice):
    df = tool_mysql.select_sql(
        '''SELECT question,choice FROM tbSickSymp WHERE name = '{}';'''.format(
            name))
    if (df.__len__() == 0):
        return '警告:数据错误,未查到症状' + name
    else:
        s = df.ix[0][0]
        if (type(df.ix[0][1]) == type('1') and len(df.ix[0][1]) > 0):  #存在候选项
            choice = eval(df.ix[0][1])
            for i in choice:
                if (i[0] == s_choice):
                    return i[1]
            return '警告:未查到该快捷回复'
Ejemplo n.º 4
0
def getQuestion(txt):
    df = tool_mysql.select_sql(
        '''SELECT question,choice FROM tbSickSymp WHERE name = '{}';'''.format(
            txt))
    if (df.__len__() == 0):
        return '警告:数据错误,未查到症状' + txt
    else:
        s = df.ix[0][0]
        if (type(df.ix[0][1]) == type('1') and len(df.ix[0][1]) > 0):  #存在候选项
            choice = eval(df.ix[0][1])
            n = 1
            for i in choice:
                s = s + "\n" + '''<a href="weixin://bizmsgmenu?msgmenucontent=''' + i[
                    0] + '''&msgmenuid=''' + str(n) + '''">''' + str(
                        n) + "." + i[0] + '''</a>'''
                n += 1
        return s
Ejemplo n.º 5
0
def getActionByWcid(wcid):
    return tool_mysql.select_sql(
        '''select level from tbUserAction WHERE wcid = '{}';'''.format(wcid))
Ejemplo n.º 6
0
def getUserBySymp(list):
    str = "SELECT * FROM tbUser WHERE characteristics LIKE '%%%%%s%%%%'" % list[
        0]
    for x in list:
        str += " or characteristics LIKE '%%%%%s%%%%'" % x
    return tool_mysql.select_sql(str)
Ejemplo n.º 7
0
def getUser(FromUserName):
    return tool_mysql.select_sql(
        '''select * from tbUser WHERE wcid = '{}';'''.format(FromUserName))
Ejemplo n.º 8
0
def getSicknessByName(name):
    return tool_mysql.select_sql(
        "SELECT * FROM tbSickness WHERE sickName LIKE '%%%%%s%%%%'" % name)
Ejemplo n.º 9
0
def getSickness(txt):
    return tool_mysql.select_sql(
        "SELECT * FROM tbSickness WHERE symptomCha LIKE '%%%%%s%%%%'" % txt)
Ejemplo n.º 10
0
def getUserLocation(FromUserName):
    df = tool_mysql.select_sql(
        '''select * from tbUser WHERE wcid = '{}';'''.format(FromUserName))
    return [df.ix[0][1], df.ix[0][2]]